0

When I do something like:

points = np.array([[0.,0.],[1.,1.],[2.,2.]])

and attempt to check if a point is in the array such as:

[1.,2.] in points it returns:

True

When I would want it to return False. Why is this happening?

1 Answer 1

1
import numpy as np
points = np.array([[0.,0.],[1.,1.],[2.,2.]])
[np.array_equal([1,2],x) for x in points]

array_equal would be the method you are looking for. In case the element exists, it would return to True as one of the elements of this list.

Otherwise it checks whether any of the elements from this list 1 or 2 occurs in the given numpy array anywhere.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.