[Numpy-discussion] ZeroRank memmap behavior?
Mon Sep 24 09:25:59 CDT 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