1

Why does:

[3] == np.arange(10) 

return:

([False, False, False,  True, False, False, False, False, False, False], dtype=bool) 

Instead of simply False?

1 Answer 1

1

Why does np.arange(10)+3 return an array? The comparison [3] == np.arange(10) is treating the arguments in the same way, element by element (with broadcasting as needed).

If it can't broadcast and do element wise comparison it does return a False or an error.

In [285]: np.arange(10)==[1,2]
/usr/local/bin/ipython3:1: DeprecationWarning: elementwise == comparison failed; this will raise an error in the future.
  #!/usr/bin/python3
Out[285]: False
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.