[SciPy-user] Array functions
Christian Kristukat
ckkart at hoc.net
Mon Aug 8 07:27:02 EDT 2005
Howey, David A wrote:
> I guess this is a numpy question, but how do I do truth tests on arrays?
> I'm trawling around the documentation but struggling to find an answer..
>
> I want to test if any array contains ONLY zeros.
>
> Originally I had:
> if a == 0:
> # code in here
>
> I need this to be true both for
> a = 0 # ie a is just a number
>
> and for
> a = array((0,0,0,0,0))
Have a look at sometrue/alltrue:
e.g. alltrue(a==0.0) returns True if all elements are zero.
Christian
More information about the SciPy-User
mailing list