[Numpy-discussion] major bug in fromstring, ascii mode

Eric Firing efiring@hawaii....
Sun Jan 27 00:30:01 CST 2008


In the course of trying to parse ascii times, I ran into a puzzling bug. 
  Sometimes it works as expected:

In [31]:npy.fromstring('23:19:01', dtype=int, sep=':')
Out[31]:array([23, 19,  1])

But sometimes it doesn't:

In [32]:npy.fromstring('23:09:01', dtype=int, sep=':')
Out[32]:array([23,  0])

In [33]:npy.__version__
Out[33]:'1.0.5.dev4742'

In [34]:npy.fromstring('23:09:01', dtype=int, sep=':', count=3)
Out[34]:array([23,  0, 16])

In [35]:npy.fromstring('23 09 01', dtype=int, sep=' ', count=3)
Out[35]:array([23,  0,  9])

In [36]:npy.fromstring('23 09 01', dtype=int, sep=' ')
Out[36]:array([23,  0,  9,  1])

Maybe it is a problem specific to int conversion; examples that fail 
with int work with float:

In [37]:npy.fromstring('23 09 01', dtype=float, sep=' ')
Out[37]:array([ 23.,   9.,   1.])

In [38]:npy.fromstring('23:09:01', dtype=float, sep=':')
Out[38]:array([ 23.,   9.,   1.])


Eric


More information about the Numpy-discussion mailing list