8000 __contains__: erroneous broadcasting when operand is a list · Issue #10179 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

__contains__: erroneous broadcasting when operand is a list #10179

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

Open
paul-the-noob opened this issue Dec 8, 2017 · 2 comments
Open

__contains__: erroneous broadcasting when operand is a list #10179

paul-the-noob opened this issue Dec 8, 2017 · 2 comments

Comments

@paul-the-noob
Copy link

This may be related to #3016.

As I understand it arr.contains(item) is implemented as (arr == item).any().

Due to spurious broadcasting this leads to

[5] in array([None, 4, [5]) -> False

and

[5] in array([None, 5, [4]) -> True

Surely, that can't be right.

I'm on Python3.6 and numpy1.13.

@eric-wieser
Copy link
Member
eric-wieser commented Dec 8, 2017

Note that this works as expected:

def make_scalar(x):
    a = np.array(None)
    a[()] = x
    return a

make_scalar([5]) in np.array([None, 4, [5]])

The problem here is that make_scalar([5]) and np.array([5]) are not the same thing.

@ahaldane
Copy link
Member

Reviewing this as part of my 10 random issues, as requested in a 3/20/19 request.

This is an object array bug. It can be filed/fixed together with other object-array fixup plans, like #5353 #5933 #6070. Perhaps can be included in #6320.

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

3 participants
0