[Numpy-discussion] numpy scalars and savez -- bug?

Chris Barker - NOAA Federal chris.barker at noaa.gov
Thu Apr 18 11:31:23 EDT 2013

On Thu, Apr 18, 2013 at 4:04 AM, Robert Kern <robert.kern at gmail.com> wrote:

> np.save() and company (and the NPY format itself) are for arrays, not
> for scalars. np.save() uses an np.asanyarray() to coerce its input
> which is why your scalar gets converted to a rank-zero array.

Fair enough -- so a missing feature, not bug -- I'll need to look at
the docs and see if that can be clarified - I note that it never
dawned on me to pass anything other than an array in (like a list),
but I guess if I did, it would likely work, but return an array when
re-loaded. I'm ambivalent about whether I like this feature -- in this
case, it resulted in confusion. If I'd gotten an exception in the
first place, it would have been simple enough to fix, as it was it
took some poking around.

As for numpy scalars -- would it be a major lift to support them directly?


> --
> Robert Kern
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion


Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov

More information about the NumPy-Discussion mailing list