I'm adaptying the code of a guy that studies with me, for my problem.
This is his code:
if not((paux1 == paux2).all()):
pop[int(saidaFO[pos,0]),:] = paux2
pos -= 1
And it works, and when I give a print, I have this result by paux1: [-2.3668 1.3174]. I'm working in a different problem, and in my case, when I print paux1, I have this: [0.2107491848569726, 443, 3]
So, when I try to do the same comparation:
if not((paux1 == paux2).all()):
I got this error: "AttributeError: 'bool' object has no attribute 'all' " I'm not understand what is going on... Could someone help me, please? I didn't understand so well how the .all() works... Maybe a equivalent code can work...
In your guy's code, paux1 and paux2 are probably numpy arrays, so paux1 == paux2 returns an array representing booleans (whether the tested equality is true or false), and that array does have a .all() method.
It sounds like you are working with lists, so paux1 == paux2 does not compare elements by elements like numpy arrays do. You are only checking if both lists are equal, with returns a single boolean. This boolean does not have a .all() method and that's what causes your error.
Convert your lists of values beforehand to numpy arrays and the error should be fixed.
paux1 = np.array(paux1)
paux2 = np.array(paux2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With