-1

Basically i am trying out boolean expressions with numpy arrays , for example something like this:

import numpy as np
a = np.array([1,0,1])
b = np.array([0,1,1])
c = np.array([1,0,1])

if (a ==b) or (a==c):
    d = [2,5,5]
else : d = [1,5,5]
print d

This returns an error

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

What would be the correct way to code this?

0

1 Answer 1

0

the condition should read:

if (a==b).all() or (a==c).all():

see this question

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.