Skip to content

Commit

Permalink
fix numpy test failing
Browse files Browse the repository at this point in the history
  • Loading branch information
ASEM000 committed Mar 27, 2024
1 parent 173aaf7 commit 3f4b5dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions sepes/_src/backend/arraylib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
class NoImplError(NamedTuple):
op: Callable

def __call__(self, *_, **__):
raise NotImplementedError(f"No implementation for {self.op}")
def __call__(self, *args, **kwargs):
raise NotImplementedError(f"No implementation for {self.op}"
f" with {args=} {kwargs=}")


tobytes = ft.singledispatch(NoImplError("tobytes"))
Expand Down
7 changes: 5 additions & 2 deletions sepes/_src/tree_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,17 @@ def is_array_like(node) -> bool:
return hasattr(node, "shape") and hasattr(node, "dtype")


def _is_leaf_rhs_equal(leaf, rhs) -> bool:
def _is_leaf_rhs_equal(leaf, rhs):
if is_array_like(leaf):
if is_array_like(rhs):
if leaf.shape != rhs.shape:
return False
if leaf.dtype != rhs.dtype:
return False
verdict = arraylib.all(leaf == rhs)
try:
verdict = arraylib.all(leaf == rhs)
except NotImplementedError:
verdict = leaf == rhs
try:
return bool(verdict)
except Exception:
Expand Down

0 comments on commit 3f4b5dd

Please sign in to comment.