Re: [Numpy-discussion] genloadtxt: dtype=None and unpack=True

2009-02-12 Thread Ryan May
On Wed, Feb 11, 2009 at 10:47 PM, Pierre GM pgmdevl...@gmail.com wrote:


 On Feb 11, 2009, at 11:38 PM, Ryan May wrote:

  Pierre,
 
  I noticed that using dtype=None with a heterogeneous set of data,
  trying to use unpack=True to get the columns into separate arrays
  (instead of a structured array) doesn't work.  I've attached a patch
  that, in the case of dtype=None, unpacks the fields in the final
  array into a list of separate arrays.  Does this seem like a good
  idea to you?

 Nope, as it breaks consistency: depending on some input parameters,
 you either get an array or a list. I think it's better to leave it as
 it is, maybe adding an extra line in the doc precising that
 unpack=True doesn't do anything for structured arrays.


Ah, I hadn't thought of that.  I was only thinking in terms of the behavior
of unpacking on return, not in the actual returned object.  You're right,
it's a bad idea.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] genloadtxt: dtype=None and unpack=True

2009-02-11 Thread Ryan May
Pierre,

I noticed that using dtype=None with a heterogeneous set of data, trying to
use unpack=True to get the columns into separate arrays (instead of a
structured array) doesn't work.  I've attached a patch that, in the case of
dtype=None, unpacks the fields in the final array into a list of separate
arrays.  Does this seem like a good idea to you?

Here's a test case:

from cStringIO import StringIO
s = '2,1950-02-27,35.55\n2,1951-02-19,35.27\n'
a,b,c = np.genfromtxt(StringIO(s), delimiter=',', unpack=True, missing=' ',
dtype=None)

Ryan

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma


genloadtxt_unpack_fields.diff
Description: Binary data
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] genloadtxt: dtype=None and unpack=True

2009-02-11 Thread Pierre GM

On Feb 11, 2009, at 11:38 PM, Ryan May wrote:

 Pierre,

 I noticed that using dtype=None with a heterogeneous set of data,  
 trying to use unpack=True to get the columns into separate arrays  
 (instead of a structured array) doesn't work.  I've attached a patch  
 that, in the case of dtype=None, unpacks the fields in the final  
 array into a list of separate arrays.  Does this seem like a good  
 idea to you?

Nope, as it breaks consistency: depending on some input parameters,  
you either get an array or a list. I think it's better to leave it as  
it is, maybe adding an extra line in the doc precising that  
unpack=True doesn't do anything for structured arrays. 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion