[Numpy-discussion] ZeroRank memmap behavior?
spitskip at gmail.com
Mon Sep 24 10:25:59 EDT 2012
Thanks Sebastian. Casting it to an array would certainly help.
Another oddity of zero-ranked scalars is that they look iterable, but in
fact are not. Because all they do is generate an error.
>>> a = np.array(22)
Test if iterable:
>>> hasattr(a, __iter__)
>>> import collections
>>> isinstance(a, collections.Iterable)
>>> for e in a:
TypeError: iteration over a 0-d array
Wouldn't it be better to have a different type altogether for numpy
scalars? Because scalars don't seem to quack quite like arrays...
(I haven't been following the discussion around scalars, so if this is a
silly remark just ignore it)
Another question. What would be the preferred method of testing for
Something like this?
>>> if a.shape:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion