Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-05 Thread Thouis Jones
On Fri, Dec 2, 2011 at 18:53, Charles R Harris wrote: > After sleeping on this, I think an object array in this situation would be > the better choice and wouldn't result in lost information. This might change > the behavior of > some functions though, so would need testing. I tried to come up w

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-02 Thread Charles R Harris
On Fri, Dec 2, 2011 at 8:23 AM, Thouis (Ray) Jones wrote: > On Thu, Dec 1, 2011 at 17:39, Charles R Harris > wrote: > > Given that strings should be the result, this looks like a bug. It's a > bit > > of a corner case that probably slipped through during the recent work on > > casting. There nee

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-02 Thread Thouis (Ray) Jones
On Thu, Dec 1, 2011 at 17:39, Charles R Harris wrote: > Given that strings should be the result, this looks like a bug. It's a bit > of a corner case that probably slipped through during the recent work on > casting. There needs to be tests for these sorts of things, so if you find > more oddities

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Derek Homeier
On 1 Dec 2011, at 21:35, Chris Barker wrote: > On 12/1/2011 9:15 AM, Derek Homeier wrote: > np.array((2, 12,0.001+2j), dtype='|S8') >> array(['2', '12', '(0.001+2'], dtype='|S8') >> >> - notice the last value is only truncated because it had first been >> converted into >> a "standard" comp

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Chris Barker
On 12/1/2011 9:15 AM, Derek Homeier wrote: np.array((2, 12,0.001+2j), dtype='|S8') > array(['2', '12', '(0.001+2'], dtype='|S8') > > - notice the last value is only truncated because it had first been converted > into > a "standard" complex representation, so maybe the problem is already in

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Derek Homeier
On 1 Dec 2011, at 17:39, Charles R Harris wrote: > On Thu, Dec 1, 2011 at 6:52 AM, Thouis (Ray) Jones wrote: > Is this expected behavior? > > >>> np.array([-345,4,2,'ABC']) > array(['-34', '4', '2', 'ABC'], dtype='|S3') > > > > Given that strings should be the result, this looks like a bug. I

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Charles R Harris
On Thu, Dec 1, 2011 at 6:52 AM, Thouis (Ray) Jones wrote: > Is this expected behavior? > > >>> np.array([-345,4,2,'ABC']) > array(['-34', '4', '2', 'ABC'], dtype='|S3') > > > Given that strings should be the result, this looks like a bug. It's a bit of a corner case that probably slipped through

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Thouis Jones
On Thu, Dec 1, 2011 at 16:29, Benjamin Root wrote: > Does the same problem occur if -345 comes after "ABC"? Yes. >>> np.array(list(reversed([-345,4,2,'ABC']))) array(['ABC', '2', '4', '-34'], dtype='|S3') ___ NumPy-Discussion mailing list NumPy-D

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Benjamin Root
On Thursday, December 1, 2011, Thouis Jones wrote: > On Thu, Dec 1, 2011 at 15:47, Pierre Haessig wrote: >> Le 01/12/2011 14:52, Thouis (Ray) Jones a écrit : >>> Is this expected behavior? >>> >> np.array([-345,4,2,'ABC']) >>> array(['-34', '4', '2', 'ABC'], dtype='|S3') >>> >>> >> With my nu

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Thouis Jones
On Thu, Dec 1, 2011 at 15:47, Pierre Haessig wrote: > Le 01/12/2011 14:52, Thouis (Ray) Jones a écrit : >> Is this expected behavior? >> > np.array([-345,4,2,'ABC']) >> array(['-34', '4', '2', 'ABC'], dtype='|S3') >> >> > With my numpy 1.5.1, I got indeed a different result: > > In [1]: np.arr

Re: [Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Pierre Haessig
Le 01/12/2011 14:52, Thouis (Ray) Jones a écrit : > Is this expected behavior? > np.array([-345,4,2,'ABC']) > array(['-34', '4', '2', 'ABC'], dtype='|S3') > > With my numpy 1.5.1, I got indeed a different result: In [1]: np.array([-345,4,2,'ABC']) Out[1]: array(['-345', '4', '2', 'ABC'],

[Numpy-discussion] numpy.array() of mixed integers and strings can truncate data

2011-12-01 Thread Thouis (Ray) Jones
Is this expected behavior? >>> np.array([-345,4,2,'ABC']) array(['-34', '4', '2', 'ABC'], dtype='|S3') >>> np.version.full_version '1.6.1' >>> np.version.git_revision '68538b74483009c2c2d1644ef00397014f95a696' Ray Jones ___ NumPy-Discussion mailing l