Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread Robert Kern
On Fri, May 13, 2011 at 09:58, Bruce Southey wrote: > Hi, > How do you create a 'single' structured array using np.array()? > Basically I am attempting to do something like this that does not work: > a=np.array([1,2, 3,4, 5,6], dtype=np.dtype([('foo', int)])) > > I realize that this is essentially

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread josef . pktd
On Fri, May 13, 2011 at 5:03 PM, Bruce Southey wrote: > On 05/13/2011 03:04 PM, josef.p...@gmail.com wrote: >> On Fri, May 13, 2011 at 3:11 PM, Derek Homeier >>  wrote: >>> Hi, >>> >>> just a comment since I first thought the solution below might not be >>> what Bruce >>> was looking for, but hav

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread Bruce Southey
On 05/13/2011 03:04 PM, josef.p...@gmail.com wrote: > On Fri, May 13, 2011 at 3:11 PM, Derek Homeier > wrote: >> Hi, >> >> just a comment since I first thought the solution below might not be >> what Bruce >> was looking for, but having realised it's probably what he's been >> asking for... >> >>

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread Derek Homeier
On 13 May 2011, at 22:04, josef.p...@gmail.com wrote: >> Thus I am wondering why broadcasting should not be possible in this >> case, > > Even a 1 column table is still a table (or a list of records), and a 1 > item row is still a row. > True, but even multiplying the shape (6, ) array e.g. with a

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread josef . pktd
On Fri, May 13, 2011 at 3:11 PM, Derek Homeier wrote: > Hi, > > just a comment since I first thought the solution below might not be > what Bruce > was looking for, but having realised it's probably what he's been > asking for... > > On 13 May 2011, at 17:20, josef.p...@gmail.com wrote: > >> On Fr

Re: [Numpy-discussion] Trying to turn warning to errors

2011-05-13 Thread Ondrej Marsalek
On Fri, May 13, 2011 at 18:54, Pauli Virtanen wrote: > Fri, 13 May 2011 17:39:26 +0200, Ondrej Marsalek wrote: > [clip] >> while this does not (i.e. still produces just a warning): >> >> $ python -W error -c 'import numpy; x=numpy.ones(2); x+=1j' >> numpy.core.numeric.ComplexWarning: Casting compl

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread Derek Homeier
Hi, just a comment since I first thought the solution below might not be what Bruce was looking for, but having realised it's probably what he's been asking for... On 13 May 2011, at 17:20, josef.p...@gmail.com wrote: > On Fri, May 13, 2011 at 10:58 AM, Bruce Southey > wrote: >> Hi, >> Ho

Re: [Numpy-discussion] Trying to turn warning to errors

2011-05-13 Thread Pauli Virtanen
Fri, 13 May 2011 17:39:26 +0200, Ondrej Marsalek wrote: [clip] > while this does not (i.e. still produces just a warning): > > $ python -W error -c 'import numpy; x=numpy.ones(2); x+=1j' > numpy.core.numeric.ComplexWarning: Casting complex values to real > discards the imaginary part > > This is

[Numpy-discussion] Trying to turn warning to errors

2011-05-13 Thread Ondrej Marsalek
Dear all, I am trying to turn Python warnings to errors, but it does not work as expected with numpy. The following two piece of code work: $ python -W error -c 'import warnings; import numpy; warnings.warn("test", numpy.core.numeric.ComplexWarning)' Traceback (most recent call last): File "",

Re: [Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread josef . pktd
On Fri, May 13, 2011 at 10:58 AM, Bruce Southey wrote: > Hi, > How do you create a 'single' structured array using np.array()? > Basically I am attempting to do something like this that does not work: > a=np.array([1,2, 3,4, 5,6], dtype=np.dtype([('foo', int)])) > > I realize that this is essentia

[Numpy-discussion] Creating a 1-d structured array

2011-05-13 Thread Bruce Southey
Hi, How do you create a 'single' structured array using np.array()? Basically I am attempting to do something like this that does not work: a=np.array([1,2, 3,4, 5,6], dtype=np.dtype([('foo', int)])) I realize that this is essentially redundant as if A is an 1-d array then a structured array with