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

Skip to content

BUG: np.equal does not work where == does #4470

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

Closed
abalkin opened this issue Mar 10, 2014 · 4 comments
Closed

BUG: np.equal does not work where == does #4470

abalkin opened this issue Mar 10, 2014 · 4 comments

Comments

@abalkin
Copy link
Contributor

abalkin commented Mar 10, 2014

>>> import numpy as np
>>> x = np.array('abc', 'c')
>>> x == x
array([ True,  True,  True], dtype=bool)
>>> np.equal(x, x)
NotImplemented
@ddasilva
Copy link
Contributor

I took a look at this. Both use the equal ufunc. However, x==x goes through array_richcompare() first, and array_richcompare() has extra code that is recovering from the failure.

The end of array_richcompare() (arrayobject.c, line 1433):

    if (result == Py_NotImplemented) {
        /* Try to handle string comparisons */
        ...
    }
    return result;

@abalkin
Copy link
Contributor Author

abalkin commented Apr 7, 2014

So it appears that the underlying problem is that ufuncs do not work with flex arrays. For example,

>>> x = numpy.zeros(1, dtype='d,d')
>>> numpy.add(x, x)
NotImplemented

@charris
Copy link
Member

charris commented Aug 16, 2019

See also

#4470
#3322
#3015

@seberg
Copy link
Member

seberg commented Jan 28, 2024

Going to close this, while still true in some other cases, it isn't for strings since 1.25 or so.

@seberg seberg closed this as completed Jan 28, 2024
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

5 participants