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

Charles R Harris charlesr.harris at gmail.com
Sun Jan 27 03:16:36 EST 2008


On Jan 26, 2008 11:30 PM, Eric Firing <efiring at hawaii.edu> wrote:

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

Works here.

In [6]: for i in range(100):fromstring('23:19:01', dtype=int, sep=':')

In [7]: numpy.__version__
Out[7]: '1.0.5.dev4730'


produces no failures. The fact that it fails for you sometimes and not
others is very odd. It's like some sort of bizarre race condition or bit
flip. What architecture/OS/compiler are you using? Have you tested memory?

Chuck


>
> 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
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080127/d410979f/attachment.html>


More information about the NumPy-Discussion mailing list