[Numpy-discussion] major bug in fromstring, ascii mode
Pauli Virtanen
pav@iki...
Sun Jan 27 05:50:14 CST 2008
su, 2008-01-27 kello 01:16 -0700, Charles R Harris kirjoitti:
>
>
> On Jan 26, 2008 11:30 PM, Eric Firing <efiring@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.
I think it's that some numbers work, and some don't. Consider:
>>> npy.fromstring('23:06:01', dtype=int, sep=':')
array([23, 6, 1])
>>> npy.fromstring('23:07:01', dtype=int, sep=':')
array([23, 7, 1])
>>> npy.fromstring('23:08:01', dtype=int, sep=':')
array([23, 0])
>>> npy.fromstring('23:09:01', dtype=int, sep=':')
array([23, 0])
and
>>> npy.fromstring('23:010:01', dtype=int, sep=':')
array([23, 8, 1])
>>> npy.fromstring('23:011:01', dtype=int, sep=':')
array([23, 9, 1])
and
>>> npy.fromstring('23:0xff:01', dtype=int, sep=':')
array([ 23, 255, 1])
Smells like some scanf function is interpreting numbers beginning with
zero as octal, and recognizing also hexadecimals.
This is a bit surprising, and whether this is the desired behavior is
questionable.
--
Pauli Virtanen
More information about the Numpy-discussion
mailing list