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

2013-04-19 Thread Chris Barker - NOAA Federal
On Apr 18, 2013, at 11:33 PM, Nathaniel Smith n...@pobox.com wrote: On 18 Apr 2013 01:29, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: This has been annoying, particular as rank-zero scalars are kind of a pain. BTW, while we're on the topic, can you elaborate on this? I tend to

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

2013-04-19 Thread Chris Barker - NOAA Federal
Robert, As I think you wrote the code, you may have a quick answer: Given that numpy scalars do exist, and have their uses -- I found this wiki page to remind me: http://projects.scipy.org/numpy/wiki/ZeroRankArray It would be nice if the .npy format could support them. Would that be a major

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

2013-04-19 Thread Sebastian Berg
On Fri, 2013-04-19 at 08:03 -0700, Chris Barker - NOAA Federal wrote: On Apr 18, 2013, at 11:33 PM, Nathaniel Smith n...@pobox.com wrote: On 18 Apr 2013 01:29, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: This has been annoying, particular as rank-zero scalars are kind

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

2013-04-19 Thread Robert Kern
On Fri, Apr 19, 2013 at 8:45 PM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Robert, As I think you wrote the code, you may have a quick answer: Given that numpy scalars do exist, and have their uses -- I found this wiki page to remind me:

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

2013-04-19 Thread Robert Kern
On Fri, Apr 19, 2013 at 9:40 PM, Sebastian Berg sebast...@sipsolutions.net wrote: Fun fact, array[()] will convert a 0-d array to a scalar, but do nothing (or currently create a view) for other arrays. Which is actually a good question. Should array[()] force a view or not? Another fun fact:

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

2013-04-19 Thread Sebastian Berg
On Fri, 2013-04-19 at 23:02 +0530, Robert Kern wrote: On Fri, Apr 19, 2013 at 9:40 PM, Sebastian Berg sebast...@sipsolutions.net wrote: Fun fact, array[()] will convert a 0-d array to a scalar, but do nothing (or currently create a view) for other arrays. Which is actually a good

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

2013-04-19 Thread Chris Barker - NOAA Federal
On Fri, Apr 19, 2013 at 10:21 AM, Robert Kern robert.k...@gmail.com wrote: On Fri, Apr 19, 2013 at 8:45 PM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Given that numpy scalars do exist, and have their uses -- I found this wiki page to remind me:

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

2013-04-19 Thread Nathaniel Smith
On 19 Apr 2013 19:22, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Anyway -- going to HDF, or netcdf, or role-your-own really seems like overkill for this. I just need something fast and simple and it doesn't need to interchange with anything else. Just use pickle...? -n

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

2013-04-19 Thread Chris Barker - NOAA Federal
On Fri, Apr 19, 2013 at 11:31 AM, Nathaniel Smith n...@pobox.com wrote: On 19 Apr 2013 19:22, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Anyway -- going to HDF, or netcdf, or role-your-own really seems like overkill for this. I just need something fast and simple and it doesn't

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

2013-04-19 Thread Pauli Virtanen
19.04.2013 22:06, Chris Barker - NOAA Federal kirjoitti: On Fri, Apr 19, 2013 at 11:31 AM, Nathaniel Smith n...@pobox.com wrote: On 19 Apr 2013 19:22, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Anyway -- going to HDF, or netcdf, or role-your-own really seems like overkill for

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

2013-04-19 Thread Robert Kern
On Sat, Apr 20, 2013 at 12:36 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: On Fri, Apr 19, 2013 at 11:31 AM, Nathaniel Smith n...@pobox.com wrote: On 19 Apr 2013 19:22, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Anyway -- going to HDF, or netcdf, or role-your-own

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

2013-04-18 Thread Robert Kern
On Thu, Apr 18, 2013 at 5:58 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Folks, I've discovered somethign intertesting (bug?) with numpy scalars ans savz. If I save a numpy scalar, then reload it, ot comes back as rank-0 array -- similar, but not the same thing: In [144]:

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

2013-04-18 Thread Chris Barker - NOAA Federal
On Thu, Apr 18, 2013 at 4:04 AM, Robert Kern robert.k...@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

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

2013-04-18 Thread Chris Barker - NOAA Federal
On Thu, Apr 18, 2013 at 8:31 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Fair enough -- so a missing feature, not bug -- I'll need to look at the docs and see if that can be clarified - All I've found is the docstring docs (which also show up in the Sphinx docs). I suggest

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

2013-04-18 Thread Robert Kern
On Thu, Apr 18, 2013 at 9:20 PM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: On Thu, Apr 18, 2013 at 8:31 AM, Chris Barker - NOAA Federal chris.bar...@noaa.gov wrote: Fair enough -- so a missing feature, not bug -- I'll need to look at the docs and see if that can be clarified -

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

2013-04-17 Thread Chris Barker - NOAA Federal
Folks, I've discovered somethign intertesting (bug?) with numpy scalars ans savz. If I save a numpy scalar, then reload it, ot comes back as rank-0 array -- similar, but not the same thing: In [144]: single_value, type(single_value) Out[144]: (2.0, numpy.float32) In [145]: np.savez('test.npz',