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

Skip to content

np.equal can still return NotImplemented #6479

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
shoyer opened this issue Oct 15, 2015 · 3 comments
Closed

np.equal can still return NotImplemented #6479

shoyer opened this issue Oct 15, 2015 · 3 comments

Comments

@shoyer
Copy link
Member

shoyer commented Oct 15, 2015

It looks like this didn't make it into the clean up in #5864/#5964.

In [3]: np.equal(np.array(['a', 'b']), 123)
/Users/shoyer/miniconda/envs/numpy-dev-py3/bin/ipython:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  #!/bin/bash /Users/shoyer/miniconda/envs/numpy-dev-py3/bin/python.app
Out[3]: NotImplemented

In [4]: np.array(['a', 'b']) == 123
/Users/shoyer/miniconda/envs/numpy-dev-py3/bin/ipython:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  #!/bin/bash /Users/shoyer/miniconda/envs/numpy-dev-py3/bin/python.app
Out[4]: False

There's a good chance @njsmith is already aware of this, but I thought I would note it for future reference. In any case, this will probably be easier to cleanup once we remove the deprecated behavior.

As reported by @amueller on Gitter.

@njsmith
Copy link
Member

njsmith commented Oct 17, 2015

Indeed, see the commit message on: charris@6bf0e41
and also the giant comment that starts at https://github.com/numpy/numpy/blob/master/numpy/core/src/umath/ufunc_object.c#L871

@tyrion
Copy link

tyrion commented Nov 14, 2018

Is there any update on this? I am still seeing the same behaviour with 1.15.4.

Is there a way to force numpy.equals or == to perform an elementwise comparison? It would be great to have a workaround while waiting for the "Future" mentioned in the warning to approach 😄

@seberg
Copy link
Member

seberg commented Mar 31, 2019

Seems this was at least partially fixed by: 6c25ca1, it now raises an error for the first (np.equal) version. Not quite sure that all things around it are fixed, but closing since the initial problem seems gone.

@seberg seberg closed this as completed Mar 31, 2019
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

No branches or pull requests

4 participants