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

tests: fix comparison on numpy 1.25 #234

Merged
merged 1 commit into from
Jun 19, 2023
Merged

Conversation

alexfikl
Copy link
Collaborator

Before comparing two ndarray([DOFArray, DOFArray]) would just return ndarray([False, False]), but it doesn't work anymore. Couldn't find an explanation in the release notes as to why that changed.

I changed it to use actx.np.equal, but I'm not sure if this was supposed to test __eq__?

@inducer
Copy link
Owner

inducer commented Jun 19, 2023

Thanks for working on this. The following:

import numpy as np


class MyContainer:
    def __eq__(self, other):
        return self

    def __bool__(self):
        raise ValueError("not defined")


a = np.zeros(2, dtype=object)
a[0] = MyContainer()
a[1] = MyContainer()

b = np.zeros(2, dtype=object)
b[0] = MyContainer()
b[1] = MyContainer()

a == b

says

/home/andreas/tmp/numpy-obj-array-equal.py:20: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
  a == b

so it seems that this may have been an intentional change.

@inducer
Copy link
Owner

inducer commented Jun 19, 2023

I think this may be the bit about == in https://numpy.org/doc/stable/release/1.25.0-notes.html#expired-deprecations.

@inducer
Copy link
Owner

inducer commented Jun 19, 2023

This means that == is no longer really a thing for array containers involving numpy object arrays, which I guess is just as well. I think your change is more or less the only option here.

@inducer inducer merged commit b3d9bb5 into inducer:main Jun 19, 2023
10 of 11 checks passed
@alexfikl alexfikl deleted the fix-numpy-1.25 branch June 19, 2023 20:08
@alexfikl
Copy link
Collaborator Author

I think this may be the bit about == in numpy.org/doc/stable/release/1.25.0-notes.html#expired-deprecations.

Oh yeah, I totally missed that. Thanks for hunting it down!

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

Successfully merging this pull request may close these issues.

2 participants