Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: assert_allclose cannot handle object arrays #25496

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

Open
h-vetinari opened this issue Dec 26, 2023 · 1 comment
Open

BUG: assert_allclose cannot handle object arrays #25496

h-vetinari opened this issue Dec 26, 2023 · 1 comment

Comments

@h-vetinari
Copy link
Contributor

This is similar to #9023 but worse, because it's less of a corner case, and more of a full edge.

Whereas assert_equal "only" treats nans in object arrays incorrectly, its not even possible to put object arrays into assert_allclose at the most basic level:

>>> from numpy.testing import assert_allclose
>>> n = np.array([1], dtype=object)
>>> assert_allclose(n.astype(int), n)
[...]
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

This makes it unnecessarily hard to write parametric tests for various corner cases (which are already hard to write at the best of times...).

@ngoldbaum
Copy link
Member

Presumably if #9009 were fixed this would "just work".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants