Skip to content

Commit

Permalink
style and coverage done
Browse files Browse the repository at this point in the history
  • Loading branch information
juanbc committed Jan 17, 2024
1 parent 2dee98e commit 2fec268
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
7 changes: 6 additions & 1 deletion skcriteria/agg/_agg_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ def __len__(self):

@doc_inherit(DiffEqualityMixin.diff)
def diff(
self, other, rtol=1e-05, atol=1e-08, equal_nan=False, check_dtypes=False
self,
other,
rtol=1e-05,
atol=1e-08,
equal_nan=False,
check_dtypes=False,
):
def array_allclose(left_value, right_value):
return np.allclose(
Expand Down
1 change: 0 additions & 1 deletion skcriteria/cmp/ranks_cmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from sklearn import metrics as _skl_metrics

from ..agg import RankResult
from ..core import SKCMethodABC
from ..utils import (
AccessorABC,
Bunch,
Expand Down
4 changes: 2 additions & 2 deletions skcriteria/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def assert_result_equals(left, right, **diff_kws):
AssertionError if the two results are not equal.
"""

# Check if left is a ResultABC
_assert(
isinstance(left, ResultABC),
Expand Down Expand Up @@ -199,7 +198,8 @@ def assert_rcmp_equals(left, right, **diff_kws):
# check if right is a RanksComparator
_assert(
diff.different_types is False,
f"'right' is not a RanksComparator instance. Found {diff.right_type!r}",
"'right' is not a RanksComparator instance. "
f"Found {diff.right_type!r}",
)

# check if left and right have the same length
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/test_dict_cmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@


def test_dict_allclose():
left = {"a": np.array([1, 2, 3]), "b": np.array([4, 5, 6]), "c": 1}
right = {"a": np.array([1, 2, 3]), "b": np.array([4, 5, 6]), "c": 1}
left = {"a": np.array([1, 2, 3]), "b": np.array([4, 5, 6]), "c": {}}
right = {"a": np.array([1, 2, 3]), "b": np.array([4, 5, 6]), "c": {}}
assert dict_cmp.dict_allclose(left, right)


Expand Down
32 changes: 32 additions & 0 deletions tests/utils/test_object_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
# =============================================================================


def test_MISSING():
assert object_diff.MISSING is object_diff._Missing()
assert repr(object_diff.MISSING) == "<MISSING>"


def test_diff():
class SomeClass:
def __init__(self, **kws):
Expand Down Expand Up @@ -197,6 +202,33 @@ def diff(
assert obj_a.aequals(obj_b) is False


def test_DiffEqualityMixin_diff_not_implemented():
class SomeClass(object_diff.DiffEqualityMixin):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)

def diff(
self,
other,
rtol=1e-05,
atol=1e-08,
equal_nan=True,
check_dtypes=False,
):
return super().diff(
other,
rtol=rtol,
atol=atol,
equal_nan=equal_nan,
check_dtypes=check_dtypes,
)

obj_a = SomeClass(a=1, b=2, d=5)

with pytest.raises(NotImplementedError):
obj_a.diff(1)


def test_DiffEqualityMixin_invalid_diff_parameters():
with pytest.raises(TypeError):

Expand Down

0 comments on commit 2fec268

Please sign in to comment.