[Numpy-discussion] preferred way of testing empty arrays

Bartosz Telenczuk b.telenczuk@biologie.hu-berlin...
Fri Jan 27 15:37:32 CST 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)


More information about the NumPy-Discussion mailing list