-
Notifications
You must be signed in to change notification settings - Fork 49
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
Issue with unyt comparison methods via numpy 1.25.0 #431
Comments
I don't understand the purpose of comparing a unyt_array to a string. What context does this pop into ? I'm also not sure this is something we can or should fix, because it was never documented as reliable or tested. |
Yes that's a fair point. We have a package that has used it previously to compare many attributes of an object, some of which are defaulted to a null string, and only write out ones that have been modified. It's easy enough for us to change this comparison to something a little more rigorous, just thought it should be brought to everyone attention in case anyone else has the same bug coming up. |
I think it would probably be ok to just universally return False for equality comparisons with types that aren’t instances of |
this would break any existing comparison between an |
Of course we’d need to treat ndarrays differently, I meant any random python type like string or other unrelated object. |
Makes sense to me. How about comparing scalar arrays (unyt_quantity) with stuff like |
Probably just needs a call to |
strings may need extra care too >>> import numpy as np
>>> np.asanyarray("hello")
array('hello', dtype='<U5') |
Right, that's why I said,
I guess also datetimes too. |
unyt 2.9.2 pyhd8ed1ab_1 conda-forge 101kB
3.10.0
MacOS
Description
Comparing unyt arrays to strings has been deprecated by 1.25.0 release of numpy. According to the patch notes, universal functions for numpy arrays can be overwritten by a subclass, causing differences in comparison. This comes into play by raising an error if you try to compare a
unyt_array
object to a null string, which works with numpy 1.24.2 and below as far as we've tested.What I Did
Outputs
Working code
Outputs
The text was updated successfully, but these errors were encountered: