[Numpy-discussion] numpy scalars and savez -- bug?
Chris Barker - NOAA Federal
chris.barker at noaa.gov
Fri Apr 19 11:03:18 EDT 2013
On Apr 18, 2013, at 11:33 PM, Nathaniel Smith <njs at pobox.com> wrote:
On 18 Apr 2013 01:29, "Chris Barker - NOAA Federal" <chris.barker at noaa.gov>
> This has been annoying, particular as rank-zero scalars are kind of a
BTW, while we're on the topic, can you elaborate on this? I tend to think
scalars (as opposed to 0d ndarrays) are kind of a pain, so I'm curious if
you have specific issues you've run into with 0d ndarrays.
Well, I suppose what's really a pain is that we have both, and they are not
the same, and neither can be used in all cases one may want.
In the case at hand, I really wanted a datetime64 scalar. By saving and
re-loading in an npz, it got converted to a rank-zero array, which had
different behavior. In this case, the frustrating bit was how to extract a
scalar again ( which I really wanted to turn into a datetime object).
After the fact, I discovered .item(), which seems to do what I want.
On a phone now, so sorry about the lack of examples.
Note: I've lost track of why we need both scalers and rank-zero arrays. I
can't help thinking that there could be an object that acts like a scalar
in most contexts, but also has the array methods that make sense.
But I know it's far from simple.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion