You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
operator.eq works on string arrays, but not np.equal does not #6122
This is on numpy 1.9.2 (I'm having trouble building on master right now):
In [1]: import numpy as np
In [2]: x = np.array(['foo'])
In [3]: x
Out[3]:
array(['foo'],
dtype='|S3')
In [4]: np.equal(x, x)
Out[4]: NotImplemented
In [5]: x == x
Out[5]: array([ True], dtype=bool)
This is slightly disconcerting, especially given that we were considering delegating all binary operations to the corresponding NumPy ufuncs in #5844.
Yeah, this is because string dtypes are stateful, and as you may have heard
;-), it's not currently possible to define ufuncs for stateful dtypes.
(Instead we have a hack inside ndarray.eq that special cases string
dtypes, quelle awesome.) So this is blocked on fixing ufuncs.
On Jul 26, 2015 9:20 PM, "Stephan Hoyer" [email protected] wrote:
This is on numpy 1.9.2 (I'm having trouble building on master right now):
In [1]: import numpy as np
In [2]: x = np.array(['foo'])
In [3]: x
Out[3]:
array(['foo'],
dtype='|S3')
In [4]: np.equal(x, x)
Out[4]: NotImplemented
In [5]: x == x
Out[5]: array([ True], dtype=bool)
This is slightly disconcerting, especially given that we were considering delegating all binary operations to the corresponding NumPy
ufuncs in #5844#5844.
—
Reply to this email directly or view it on GitHub #6122.
Closing, it works now and the weirdness about NotImplemented has been fixed many years ago (structured dtypes are still special for the moment, admittedly)
Activity
njsmith commentedon Jul 27, 2015
Yeah, this is because string dtypes are stateful, and as you may have heard
;-), it's not currently possible to define ufuncs for stateful dtypes.
(Instead we have a hack inside ndarray.eq that special cases string
dtypes, quelle awesome.) So this is blocked on fixing ufuncs.
On Jul 26, 2015 9:20 PM, "Stephan Hoyer" [email protected] wrote:
seberg commentedon Jun 8, 2023
Closing, it works now and the weirdness about NotImplemented has been fixed many years ago (structured dtypes are still special for the moment, admittedly)