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 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 post them so we can add them.
As it is not dependent on the string appearing before or after the numbers, numerical values appear to always be processed first before any string transformation, even if you explicitly specify the string format - consider the following (1.6.1): >>> np.array((2, 12,0.1+2j)) array([ 2.0+0.j, 12.0+0.j, 0.1+2.j]) >>> np.array((2, 12,0.001+2j)) array([ 2.00000000e+00+0.j, 1.20000000e+01+0.j, 1.00000000e-03+2.j]) >>> 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 Python treats the input. Cheers, Derek _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion