[Numpy-discussion] Need help for the migration from Numeric to numpy

Frank Thommen structures-it@embl-heidelberg...
Thu Oct 14 02:20:37 CDT 2010


Hi,

I'm trying to help a user to migrate from Numeric to numpy.  I found 
reference to alter_code1.py on 
http://numpy.scipy.org/old_array_packages.html.


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 
Python:

# 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
>>> noa.convertfile("test.py")
>>> ^D
#

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
0a1,2
> ## Automatically adapted for numpy.numarray Oct 06, 2010 by
>
49c51
< 		pyfid.byteswap()
---
> 		pyfid.byteswap(True)
74c76
< 		databin.byteswap()
---
> 		databin.byteswap(True)
#


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>
     combineser3D(td3,td2,td1,ser,ser1,fidnum)
   File "./test.py", line 21, in combineser3D
     allser1=readBrukerSer(tdall,td3,ser)
   File "./test.py", line 51, in readBrukerSer
     pyfid.byteswap(True)
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

     frank


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 ;-)


More information about the NumPy-Discussion mailing list