Skip to content

Commit

Permalink
migrated testing of scalers to new testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanBC committed Jan 17, 2024
1 parent 2fec268 commit 7c163ff
Showing 1 changed file with 46 additions and 50 deletions.
96 changes: 46 additions & 50 deletions tests/preprocessing/test_scalers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import numpy as np

import skcriteria
import skcriteria.testing as skct
from skcriteria.preprocessing.scalers import (
CenitDistanceMatrixScaler,
MaxAbsScaler,
Expand Down Expand Up @@ -56,7 +57,7 @@ def test_MinMaxScaler_simple_matrix():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_matrix(decision_matrix):
Expand Down Expand Up @@ -85,7 +86,7 @@ def test_MinMaxScaler_matrix(decision_matrix):
scaler = MinMaxScaler(target="matrix")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_simple_weights():
Expand All @@ -106,7 +107,7 @@ def test_MinMaxScaler_simple_weights():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_weights(decision_matrix):
Expand All @@ -132,7 +133,7 @@ def test_MinMaxScaler_weights(decision_matrix):
scaler = MinMaxScaler(target="weights")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_simple_both():
Expand All @@ -156,7 +157,7 @@ def test_MinMaxScaler_simple_both():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_both(decision_matrix):
Expand Down Expand Up @@ -186,7 +187,7 @@ def test_MinMaxScaler_both(decision_matrix):
scaler = MinMaxScaler(target="both")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MinMaxScaler_no_change_original_dm(decision_matrix):
Expand All @@ -204,9 +205,8 @@ def test_MinMaxScaler_no_change_original_dm(decision_matrix):
scaler = MinMaxScaler(target="both")
dmt = scaler.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected


# =============================================================================
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_StandarScaler_simple_matrix():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_matrix(decision_matrix):
Expand All @@ -262,7 +262,7 @@ def test_StandarScaler_matrix(decision_matrix):
scaler = StandarScaler(target="matrix")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_simple_weights():
Expand All @@ -287,7 +287,7 @@ def test_StandarScaler_simple_weights():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_weights(decision_matrix):
Expand All @@ -312,7 +312,7 @@ def test_StandarScaler_weights(decision_matrix):
scaler = StandarScaler(target="weights")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_simple_both():
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_StandarScaler_simple_both():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_both(decision_matrix):
Expand All @@ -367,7 +367,7 @@ def test_StandarScaler_both(decision_matrix):
scaler = StandarScaler(target="both")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_StandarScaler_no_change_original_dm(decision_matrix):
Expand All @@ -385,9 +385,8 @@ def test_StandarScaler_no_change_original_dm(decision_matrix):
scaler = StandarScaler(target="both")
dmt = scaler.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected


# =============================================================================
Expand Down Expand Up @@ -416,7 +415,7 @@ def test_VectorScaler_simple_matrix():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_matrix(decision_matrix):
Expand All @@ -441,7 +440,7 @@ def test_VectorScaler_matrix(decision_matrix):
scaler = VectorScaler(target="matrix")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_simple_weights():
Expand All @@ -462,7 +461,7 @@ def test_VectorScaler_simple_weights():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_weights(decision_matrix):
Expand All @@ -487,7 +486,7 @@ def test_VectorScaler_weights(decision_matrix):
scaler = VectorScaler(target="weights")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_simple_both():
Expand All @@ -511,7 +510,7 @@ def test_VectorScaler_simple_both():

result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_both(decision_matrix):
Expand All @@ -536,7 +535,7 @@ def test_VectorScaler_both(decision_matrix):
scaler = VectorScaler(target="both")
result = scaler.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_VectorScaler_no_change_original_dm(decision_matrix):
Expand All @@ -554,9 +553,8 @@ def test_VectorScaler_no_change_original_dm(decision_matrix):
scaler = VectorScaler(target="both")
dmt = scaler.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected


# =============================================================================
Expand All @@ -582,7 +580,7 @@ def test_SumScaler_simple_matrix():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_matrix(decision_matrix):
Expand All @@ -608,7 +606,7 @@ def test_SumScaler_matrix(decision_matrix):
scaler = SumScaler(target="matrix")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_simple_weights():
Expand All @@ -629,7 +627,7 @@ def test_SumScaler_simple_weights():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_weights(decision_matrix):
Expand All @@ -654,7 +652,7 @@ def test_SumScaler_weights(decision_matrix):
scaler = SumScaler(target="weights")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_simple_both():
Expand All @@ -675,7 +673,7 @@ def test_SumScaler_simple_both():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_both(decision_matrix):
Expand All @@ -701,7 +699,7 @@ def test_SumScaler_both(decision_matrix):
scaler = SumScaler(target="both")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_SumScaler_no_change_original_dm(decision_matrix):
Expand All @@ -719,9 +717,8 @@ def test_SumScaler_no_change_original_dm(decision_matrix):
scaler = SumScaler(target="both")
dmt = scaler.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected


# =============================================================================
Expand All @@ -747,7 +744,7 @@ def test_MaxAbsScaler_simple_matrix():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_matrix(decision_matrix):
Expand All @@ -773,7 +770,7 @@ def test_MaxAbsScaler_matrix(decision_matrix):
scaler = MaxAbsScaler(target="matrix")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_simple_weights():
Expand All @@ -794,7 +791,7 @@ def test_MaxAbsScaler_simple_weights():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_weights(decision_matrix):
Expand All @@ -819,7 +816,7 @@ def test_MaxAbsScaler_weights(decision_matrix):
scaler = MaxAbsScaler(target="weights")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_simple_both():
Expand All @@ -840,7 +837,7 @@ def test_MaxAbsScaler_simple_both():

result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_both(decision_matrix):
Expand All @@ -866,7 +863,7 @@ def test_MaxAbsScaler_both(decision_matrix):
scaler = MaxAbsScaler(target="both")
result = scaler.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_MaxAbsScaler_no_change_original_dm(decision_matrix):
Expand All @@ -884,9 +881,9 @@ def test_MaxAbsScaler_no_change_original_dm(decision_matrix):
scaler = MaxAbsScaler(target="both")
dmt = scaler.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected



def test_CenitDistanceMatrixScaler_simple_matrix():
Expand All @@ -906,7 +903,7 @@ def test_CenitDistanceMatrixScaler_simple_matrix():

result = tfm.transform(dm)

assert result.equals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_CenitDistanceMatrixScaler_diakoulaki1995determining():
Expand Down Expand Up @@ -950,7 +947,7 @@ def test_CenitDistanceMatrixScaler_diakoulaki1995determining():
tfm = CenitDistanceMatrixScaler()
result = tfm.transform(dm)

assert result.aequals(expected)
skct.assert_dmatrix_equals(result, expected)


def test_CenitDistanceMatrixScaler_no_change_original_dm():
Expand All @@ -965,6 +962,5 @@ def test_CenitDistanceMatrixScaler_no_change_original_dm():
tfm = CenitDistanceMatrixScaler()
dmt = tfm.transform(dm)

assert (
dm.equals(expected) and not dmt.equals(expected) and dm is not expected
)
skct.assert_dmatrix_equals(dm, expected)
assert not dmt.equals(expected) and dm is not expected

0 comments on commit 7c163ff

Please sign in to comment.