Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-03 Thread Christopher Barker
On 8/2/11 1:40 PM, Jeremy Conlin wrote: Thanks for that information. It helps greatly in understanding what is happening. Next time I'll put my data into tuples. I don't remember where they all are, but there are a few places in numpy where tuples and lists are interpreted differently (fancy

[Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Jeremy Conlin
I am trying to create a numpy array from some text I'm reading from a file. Ideally, I'd like to create a structured array with the first element as an int and the remaining as floats. I'm currently unsuccessful in my attempts. I've copied a simple script below that shows what I've done and the

Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Brett Olsen
On Tue, Aug 2, 2011 at 9:44 AM, Jeremy Conlin jlcon...@gmail.com wrote: I am trying to create a numpy array from some text I'm reading from a file. Ideally, I'd like to create a structured array with the first element as an int and the remaining as floats. I'm currently unsuccessful in my

Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Jeremy Conlin
On Tue, Aug 2, 2011 at 9:09 AM, Brett Olsen brett.ol...@gmail.com wrote: On Tue, Aug 2, 2011 at 9:44 AM, Jeremy Conlin jlcon...@gmail.com wrote: I am trying to create a numpy array from some text I'm reading from a file. Ideally, I'd like to create a structured array with the first element as

Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Christopher Barker
On 8/2/11 8:38 AM, Jeremy Conlin wrote: Thanks, Brett. Using StringIO and numpy.loadtxt worked great. I'm still curious why what I was doing didn't work. Everything I can see indicates it should work. In [11]: tfc_dtype Out[11]: dtype([('nps', 'u8'), ('t', 'f8'), ('e', 'f8'), ('fom', 'f8')])

Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Derek Homeier
On 2 Aug 2011, at 19:15, Christopher Barker wrote: In [32]: s = numpy.array(a, dtype=tfc_dtype) --- TypeError Traceback (most recent call last) /Users/cbarker/ipython console in

Re: [Numpy-discussion] Finding many ways to incorrectly create a numpy array. Please advice

2011-08-02 Thread Jeremy Conlin
On Tue, Aug 2, 2011 at 11:15 AM, Christopher Barker chris.bar...@noaa.gov wrote: On 8/2/11 8:38 AM, Jeremy Conlin wrote: Thanks, Brett. Using StringIO and numpy.loadtxt worked great. I'm still curious why what I was doing didn't work. Everything I can see indicates it should work. In [11]: