4

I am trying to use numpy.where function as follows:

x= np.where(segments==1000 and segments == 0)

and I get a ValueError:

ValueError: The truth value of an array with more than one element is ambiguous. 
Use a.any() or a.all()

Browsing through some other threads, seems this is the expected behaviour. However, I am not sure how to reformulate this using numpy.any(). I cannot get the syntax correct.

0

1 Answer 1

5

You can build your condition using parenthesis and & or np.logical_and instead of and:

(segments == 1000) & (segments == 0)

or:

np.logical_and(segments == 1000, segments == 0)
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.