[Numpy-discussion] Tests for empty arrays

Timothy Hochberg tim.hochberg at ieee.org
Tue May 6 12:43:13 EDT 2008


On Tue, May 6, 2008 at 9:31 AM, Andy Cheesman <Andy.cheesman at bristol.ac.uk>
wrote:

> Hi nice numpy people
>
> I was wondering if anyone could shed some light on how to distinguish an
> empty array of a given shape and an zeros array of the same dimensions.


An empty array is just uninitialized, while a zeros array is initialized to
zeros. Short of checking whether the zeros array is all zeros, which only
tells you that it looks like it was coming from zeros; it still could have
created by by empty or zeros or some other method.

Why do you need to know? If the array is coming from an unknown source, why
not just use a.fill(0) to force everything to be zero and start from a known
state?




>
>
> Thanks
> Andy
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



-- 
. __
. |-\
.
. tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080506/4aac1d6e/attachment.html>


More information about the NumPy-Discussion mailing list