[Numpy-discussion] Truth value of an array
Alan G Isaac
aisaac at american.edu
Fri Apr 18 16:42:39 EDT 2008
On Fri, 18 Apr 2008, Joe Harrington apparently wrote:
> For that matter, is there a reason logical operations don't work on
> arrays other than booleans? What about:
> import numpy
> x = numpy.ones((10), dtype='Bool')
> y = numpy.ones((10), dtype='Bool')
> y[6] = False
> z = x and y # logical AND: this one fails with an error about arrays
It's the same reason.
(See the other comments in this thread.)
Do this::
x = numpy.ones((10), dtype='Bool')
y = numpy.ones((10), dtype='Bool')
y[6] = False
z= x&y
hth,
Alan Isaac
More information about the NumPy-Discussion
mailing list