[Numpy-discussion] Need help for the migration from Numeric to numpy
Thu Oct 14 08:53:11 CDT 2010
On 10/14/2010 02:20 AM, Frank Thommen wrote:
> I'm trying to help a user to migrate from Numeric to numpy. I found
> reference to alter_code1.py on
> First I tried the conversion script:
> # python2.6 /path/to/alter_code1.py test.py
> and alternatively
> # python2.6 /path/to/alter_code1.py ./
> This didn't modify test.py at all. Then I tried to convert from within
> # python2.6
> Python 2.6.2 (r262:71600, Aug 5 2010, 14:21:11)
> [GCC 4.4.4] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import numpy.numarray.alter_code1 as noa
> This modified test.py, but only partially. E.g. the import line was
> still untouched, meaning that it still imported Numeric instead of numpy:
> # diff ../test-original.py test.py
>> ## Automatically adapted for numpy.numarray Oct 06, 2010 by
> < pyfid.byteswap()
> < databin.byteswap()
> After I've changed 'import os, string, array, Numeric' to 'import os,
> string, array, numpy' I realized, that the conversion had introduced errors:
> # python2.6 ./test.py<command line parameters>
> Traceback (most recent call last):
> File "./test.py", line 115, in<module>
> File "./test.py", line 21, in combineser3D
> File "./test.py", line 51, in readBrukerSer
> TypeError: byteswap() takes no arguments (1 given)
> So either this method doesn't work (any more) or I am doing something
> wrong. Are there other ways for a transition from Numeric to numpy?
> The numpy version we are using is 1.4.1 with Python 2.6.2 from python.org.
> Any help regarding this is highly appreciated.
> Thanks in advance
> P.S.: I've posted almost the same request as "alter_code1.py doesn't
> convert (any more)?" on October 6. Since I haven't received any answer
> I'm trying again with a - hopefully - more attracting subject ;-)
> NumPy-Discussion mailing list
Are you converting from Numeric or numarray?
These are slightly different versions of 'alter_code1.py '.
Anyhow I would not use it because these are likely to be very out of
date (over 2 years ago).
There used to be documentation on this but I do not see it anymore. This
is an useful one for numarray:
A lot depends on the size of code and complexity of code - it will
difficult to address the API changes. Essentially I just rewrote my code
changing numarray functions to numpy functions (I really only used
numarray). Sure my code was small and not complex but it also helped
improve the code. From what I recall, the only things I was doing was
changing the array declarations - especially dtypes. After those, you
have to watch for function changes and new features.
Also I would suggest that you have a Numeric/numarray working with some
older version of Python. This enables you to check intermediate results
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion