[NumPy-Tickets] [NumPy] #1444: numpy.array fails to change a list of tuples with float and string, whith to large string of number

NumPy Trac numpy-tickets@scipy....
Wed Mar 30 06:26:56 CDT 2011


#1444: numpy.array fails to change a list of tuples with float and string, whith
to large string of number
------------------------------------+---------------------------------------
 Reporter:  mario                   |       Owner:  somebody   
     Type:  defect                  |      Status:  new        
 Priority:  normal                  |   Milestone:  Unscheduled
Component:  numpy.core              |     Version:             
 Keywords:  array str float lenght  |  
------------------------------------+---------------------------------------
Changes (by rgommers):

 * cc: mwiebe (added)
  * component:  Other => numpy.core
  * milestone:  1.5.1 => Unscheduled


Old description:

> In [39]: c
> Out[39]:
> [(-0.017527029320000002, 'TD_C3_0.440sec'),
>  (9.0204180442999995e-06, 'TD_C3_0.920sec')]
>
> In [40]: numpy.array(c)
> Out[40]:
> array([['-0.01752702932', 'TD_C3_0.440sec'],
>        ['9.0204180443e-', 'TD_C3_0.920sec']],
>       dtype='|S14')
>
> So it seems that the length of the number is restricted by the lenght of
> the string. Proof:
> In [71]: e=[]
>
> In [72]: e.append((a,'TD_C3_0.920second'))
>
> In [73]: e.append((b,'TD_C3_0.920sec'))
>
> In [74]: numpy.array(e)
> Out[74]:
> array([['9.0204180443e-06', 'TD_C3_0.920second'],
>        ['-0.01752702932', 'TD_C3_0.920sec']],
>       dtype='|S17')
>
>  A way out was to set the dtype to '|S17' but thats no real solution.

New description:

 {{{
 In [39]: c
 Out[39]:
 [(-0.017527029320000002, 'TD_C3_0.440sec'),
  (9.0204180442999995e-06, 'TD_C3_0.920sec')]

 In [40]: numpy.array(c)
 Out[40]:
 array([['-0.01752702932', 'TD_C3_0.440sec'],
        ['9.0204180443e-', 'TD_C3_0.920sec']],
       dtype='|S14')
 }}}
 So it seems that the length of the number is restricted by the lenght of
 the string. Proof:
 {{{
 In [71]: e=[]

 In [72]: e.append((a,'TD_C3_0.920second'))

 In [73]: e.append((b,'TD_C3_0.920sec'))

 In [74]: numpy.array(e)
 Out[74]:
 array([['9.0204180443e-06', 'TD_C3_0.920second'],
        ['-0.01752702932', 'TD_C3_0.920sec']],
       dtype='|S17')
 }}}
 A way out was to set the dtype to '|S17' but thats no real solution.

--

Comment:

 <reformat description>

 Another corner case casting issue for you Mark.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1444#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list