-
-
Notifications
You must be signed in to change notification settings - Fork 12.3k
BUG: broken comparison between ndarray subclass (unyt) and strings #22744
Copy link
Copy link
Closed
Labels
00 - Bug57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued
Description
Describe the issue:
19ba7c4 (#22707) broke string comparison between unyt.unyt_quantity object (fancy 0d numpy arrays with unit data), and strings.
The following minimal example used to be fine, but it crashes on the main branch of numpy
Reproduce the code example:
import unyt as un
a = 1 * un.cm
assert a != "hello"Error message:
-traceback
Traceback (most recent call last):
File "/Users/robcleme/dev/numpy/t.py", line 4, in <module>
assert a != "hello"
^^^^^^^^^^^^
File "/Users/robcleme/.pyenv/versions/numpy-dev/lib/python3.11/site-packages/unyt/array.py", line 1850, in __array_ufunc__
new_dtype = np.dtype("f" + str(inp1.dtype.itemsize))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: data type 'f20' not understoodNumPy/Python version information:
Python 3.11.0
Context for the issue:
This change of behaviour breaks yt, see yt-project/yt#4241
I note that we haven't captured this regression via (edit: this is yt-project/unyt#333)unyt's on CI, so I'll add a test there.
It is unclear to me why this is happening, and I am not sure which of numpy or unyt this bug should be fixed in.
Ping @ngoldbaum for information
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
00 - Bug57 - Close?Issues which may be closable unless discussion continuedIssues which may be closable unless discussion continued