[Numpy-discussion] preferred way of testing empty arrays

Bartosz Telenczuk b.telenczuk at biologie.hu-berlin.de
Fri Jan 27 16:37:32 EST 2012


This will be indeed very helpful. Thanks.

> Well, if you really need to do this in more than one place, define a
> utility function and call it a day.
> 
> def should_not_plot(x):
>    if x is None:
>        return True
>    elif isinstance(x, np.ndarray):
>        return x.size == 0
>    else:
>        return bool(x)

Bartosz



More information about the NumPy-Discussion mailing list