[Numpy-discussion] bug: wrong itemsizes between NumPy strings and numarray
Francesc Altet
faltet at carabos.com
Tue May 2 09:27:10 EDT 2006
Hi,
The PyTables test suite has just discovered a subtle bug when doing
conversions between NumPy strings and numarray. In principle I'd say
that this is a problem with numarray, but as this problem raised when
updating numpy to the latest SVN version, I don't know what to think,
frankly.
The problem can be seen in:
In [1]: import numpy
In [2]: numpy.__version__
Out[2]: '0.9.7.2466'
In [3]: from numarray import strings
In [4]: strings.array(numpy.array(['aa'],'S1')).itemsize()
Out[4]: 1
In [5]: strings.array(numpy.array(['aa'],'S2')).itemsize()
Out[5]: 2
In [6]: strings.array(numpy.array(['aa'],'S3')).itemsize()
Out[6]: 2
In [7]: strings.array(numpy.array(['aa'],'S30')).itemsize()
Out[7]: 2
i.e. the numarray element size out of the conversion is always 2 (i.e.
the actual size of the element in the list), despite that the original
NumPy object can have bigger sizes.
However, with another NumPy version (dated from 3 weeks ago or so):
In [1]: import numpy
In [2]: numpy.__version__
Out[2]: '0.9.7.2278'
In [3]: from numarray import strings
In [4]: strings.array(numpy.array(['aa'],'S1')).itemsize()
Out[4]: 1
In [5]: strings.array(numpy.array(['aa'],'S2')).itemsize()
Out[5]: 2
In [6]: strings.array(numpy.array(['aa'],'S3')).itemsize()
Out[6]: 3
In [7]: strings.array(numpy.array(['aa'],'S30')).itemsize()
Out[7]: 30
i.e. it works as intended.
I report the bug here because I don't know who is the actual culprit.
Cheers,
--
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
"-"
More information about the NumPy-Discussion
mailing list