Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] safer comparison in deep_equals if np.any(x != y) does not result in boolean #323

Merged
merged 5 commits into from
May 9, 2024

Conversation

fkiraly
Copy link
Contributor

@fkiraly fkiraly commented May 8, 2024

This PR replaces a comparison in deep_equals with a defensive alternative.

Namely, np.any(x != y) and similar expressions are assumed to result in a boolean, but this may be false in pathological cases, e.g., nested lists or nested numpy arrays with non-numpy objects inside.

The defensive replacement should catch any case where the expressions assumed boolean are not boolean, and in that case have the same effect as skipping the test.

If deep_equals cannot determine equality via the condition, it returns True at the end, so when in doubt objects and estimators are deemed to comply with sklearn or sktime contracts, in dependent tests.

@fkiraly fkiraly added the bug Something isn't working label May 8, 2024
skbase/utils/deep_equals/_deep_equals.py Dismissed Show dismissed Hide dismissed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant