[Numpy-discussion] major bug in fromstring, ascii mode
Gabriel J.L. Beckers
beckers at orn.mpg.de
Sun Jan 27 06:14:34 EST 2008
Doesn't work here:
In [1]: import numpy as npy
In [2]: npy.fromstring('23:09:01', dtype=int, sep=':')
Out[2]: array([23, 0])
In [3]: npy.__version__
Out[3]: '1.0.5.dev4722'
In [4]: npy.fromstring('23:09:01', dtype=int, sep=':', count=3)
Out[4]: array([ 23, 0, 151904160])
...
Pentium Dual Core, Ubuntu Linux 7.10, I have both gcc-3.4 and gcc-4.1 on
my system; don't know which one the setup.py uses. Default is 4.1.3
Gabriel
On Sun, 2008-01-27 at 01:16 -0700, Charles R Harris wrote:
>
>
> 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
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
--
Dr. Gabriël J.L. Beckers
Max Planck Institute for Ornithology
Group Neurobiology of Behaviour
Postfach 1564, 82305 Starnberg, Germany
Web: http://www.gbeckers.nl
Phone: +49-8157932273, Fax: +49-8157932285
More information about the NumPy-Discussion
mailing list