[SciPy-dev] numpyio.io problem
Travis Oliphant
oliphant at ee.byu.edu
Wed Oct 19 22:24:44 CDT 2005
Stephen Walton wrote:
>My last Bug of the Day, which is also triggered by the first test in
>test_array_import.py, shows that numpyio.fwrite will not convert a real
>array to shorts before writing them out. Note the last line succeeds in
>writing ints. Is this new/old/desired behavior?
>
>In [1]:import scipy
>Importing io to scipy
>Importing special to scipy
>Importing utils to scipy
>Importing interpolate to scipy
>Importing optimize to scipy
>Importing linalg to scipy
>
>In [2]:import scipy.io.numpyio as numpyio
>
>In [3]:a=255*scipy.rand(20)
>
>In [4]:fid=open('foo','wb+')
>
>In [5]:numpyio.fwrite(fid,20,a,'s')
>---------------------------------------------------------------------------
>exceptions.ValueError Traceback (most
>recent call last)
>
>/home/swalton/<console>
>
>ValueError: Invalid type for array
>
>
's' is no longer the typecode character for "short". You are looking
for 'h' here. This is the character used by the struct module. I guess
it means 'half' or something.
numpyio needs to be updated to take actual type objects and not just
character. It is not a difficult fix, since PyArray_TypecodeConverter
is available in the new C-API.
-Travis
More information about the Scipy-dev
mailing list