Re: [Numpy-discussion] Need help for the migration from Numeric to numpy
Bruce Southey wrote: [...] It took me a while to track it down, but there used to be a module/file called 'convertcode.py' for conversion. It was mentioned as tip in Travis's 'Guide to Numpy' page 31 in Jan 6 2005 version. But the alter_code path is in Dec 7 2006 (linked at http://docs.scipy.org/doc/). It is advisable to read it as it address differences between Numeric and old numpy ie section 2.6! Thanks for the hint. I'm currently reading through this document. I'm sure this will help a lot. convertcode.py doesn't seem to provided with current numpy releases. Travis said in the thread: http://mail.scipy.org/pipermail/numpy-discussion/2006-August/010085.html The transition approach is to use the compatibility layer first by running oldnumeric.alter_code1.py and then running alter_code2.py which will take you from the compatibility layer to NumPy (but alter_code2 is not completed yet). My experience is, that these scripts don't work at all (any more). frank Hi, Yeah I never had much success with using such codes. Anyhow, I have attached the last version of convertcode.py I have (came with numpy 0.9.6). If you want that numpy version as does not seem to be on sourceforge please let me know (the gzipped tar file is about 930K). Bruce Hi, thanks a lot for digging this out, but `python convertcode.py ./test.py` only adds a line '## Automatically adapted for numpy Oct 18, 2010 by convertcode.py' on top of the file. That's all. All other Numeric code in the script (including impoerts) are unchanged. I think it's the most timesaving and nerve-conserving way to let the user change his scripts manually (with the help of Travis's 'Guide to Numpy') and providing Numeric in the meantime ;-) Thanks to all respondents for the hints and links frank ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need help for the migration from Numeric to numpy
Christopher Barker wrote: On 10/14/10 9:46 AM, Frank Thommen wrote: We are speaking of potentially several hundred files. It's part of the scientific work of the user of the last nine years... Let's hope he's got some tests! Yes, we can compare the outputs with the existing results of the old version. Which conversion script do you mean? I couldn't find any conversion script that works or comes close to working. I don't know anything you don't know -- I thought you got a script to work, it just didn't do the full job -- it may well have done some of the simple scut work, though. The script I mentioned was the conversion script which is distributed with numpy (alter_code1.py). But this script doesn't seem to be maintained any more. Anyway, hundreds of files sounds like a lot, but while it's boring work, it's probably less than you'd think once you get started. You'd want a multiple-file search and replace tool, though. I've tried with some sample scripts. Simply replacing Numeric by numpy leads to other errors (wrong attributes etc.). However since I don't have the resources to do this for the user, I've now installed the historical Numeric 24.2 and the user is warned, not to use Numeric for any new script and that Numeric will be removed in the future. That should give him enough time to go through his old scripts and change them. frank ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need help for the migration from Numeric to numpy
Bruce Southey wrote: On 10/14/2010 12:55 PM, Christopher Barker wrote: On 10/14/10 9:46 AM, Frank Thommen wrote: We are speaking of potentially several hundred files. It's part of the scientific work of the user of the last nine years... Let's hope he's got some tests! Which conversion script do you mean? I couldn't find any conversion script that works or comes close to working. I don't know anything you don't know -- I thought you got a script to work, it just didn't do the full job -- it may well have done some of the simple scut work, though. Anyway, hundreds of files sounds like a lot, but while it's boring work, it's probably less than you'd think once you get started. You'd want a multiple-file search and replace tool, though. -Chris It took me a while to track it down, but there used to be a module/file called 'convertcode.py' for conversion. It was mentioned as tip in Travis's 'Guide to Numpy' page 31 in Jan 6 2005 version. But the alter_code path is in Dec 7 2006 (linked at http://docs.scipy.org/doc/). It is advisable to read it as it address differences between Numeric and old numpy ie section 2.6! Thanks for the hint. I'm currently reading through this document. I'm sure this will help a lot. convertcode.py doesn't seem to provided with current numpy releases. Travis said in the thread: http://mail.scipy.org/pipermail/numpy-discussion/2006-August/010085.html The transition approach is to use the compatibility layer first by running oldnumeric.alter_code1.py and then running alter_code2.py which will take you from the compatibility layer to NumPy (but alter_code2 is not completed yet). My experience is, that these scripts don't work at all (any more). frank ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Need help for the migration from Numeric to numpy
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 ;-) ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need help for the migration from Numeric to numpy
Christopher Barker wrote: On 10/14/10 12: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 http://numpy.scipy.org/old_array_packages.html. How much code is this? We are speaking of potentially several hundred files. It's part of the scientific work of the user of the last nine years... Part of the problem is, that his Python/Numeric installation is 32bit and he has the last 32bit computer in the department. This installation doesn't work with a 64bit Linux even with all 32bit compatibility libraries installed. :-] I always just did the conversion by hand (with search and replace, of course!) -- it was never a big deal. It gave me the opportunity to tweak the code to ways that work better in numpy anyway. Unless you've got a LOT of code to do, I'd just change Numeric to numpy and start testing. Or run the conversion script, then test -- but I'd look at a diff too, just to make sure you understand what the script did. Which conversion script do you mean? I couldn't find any conversion script that works or comes close to working. Cheers frank -- Frank Thommen - Structures IT Management and Support - EMBL Heidelberg structures...@embl-heidelberg.de - +49 6221 387 8353 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] alter_code1.py doesn't convert (any more)?
Hi, I'm trying to help a user to migrate from Numeric - which he used up to now - 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. 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 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion