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 charlesr.har...@gmail.com 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.

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 charlesr.har...@gmail.com 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

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 tho...@gmail.com wrote: On Thu, Dec 1, 2011 at 17:39, Charles R Harris charlesr.har...@gmail.com 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

[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 list

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'],

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 pierre.haes...@crans.org 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]:

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 thouis.jo...@curie.fr wrote: On Thu, Dec 1, 2011 at 15:47, Pierre Haessig pierre.haes...@crans.org 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'],

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 ben.r...@ou.edu 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

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 tho...@gmail.com 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

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 tho...@gmail.com 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

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 the way

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 complex