numpy conversion

0 views
Skip to first unread message

Chris

unread,
Sep 7, 2007, 10:48:42 PM9/7/07
to wcs2kml
I've made a quick first crack of converting the Python code from using
Numeric to numpy. I've uploaded the two files that I have modified.

jeremy....@gmail.com

unread,
Sep 7, 2007, 11:51:18 PM9/7/07
to wcs2kml
Thanks for the numpy port, Chris. I think the best way to integrate
your changes is probably to abstract all of the code that uses Numeric/
numpy so that users can have either installed, but preferentially load
numpy since it's faster and still actively developed. I only used
Numeric because most Linux distributions don't include numpy yet, but
this should change soon.

Jeremy

Chris

unread,
Sep 7, 2007, 11:58:34 PM9/7/07
to wcs2kml
How do you want users to decide between the Numeric and numpy
versions? Check to see if numpy is installed and if not use Numeric?
Check some environment variable? Import a specific version?


Chris

jeremy....@gmail.com

unread,
Sep 8, 2007, 9:45:28 AM9/8/07
to wcs2kml
I was thinking of doing something like this:

try:
import numpy
read_data = numpy_read_data
...
except ImportError:
try:
import Numeric
read_data = numeric_read_data
...
except ImportError:
raise ImportError("no module named 'numpy' or 'Numeric'")

where numpy_read_data and numeric_read_data have the same signature
and do the same thing (read data from disk), but they do it however is
best for each module. Additional functions like this would be needed,
but if we specified all of them users could use either numpy or
Numeric transparently.

Jeremy

Chris

unread,
Sep 8, 2007, 12:18:55 PM9/8/07
to wcs2kml
Shouldn't be a problem doing it that way. I've already done the same
thing for a different project to support numarray and numpy.

Just something to think about. It may not be necessary to support
both Numeric and numpy and complicate you code in this way. Your
target audience probably already has numpy installed. Both the Gemini
Observatories and the Hubble Space Telescope people now require numpy
to be installed to use their software. Also, SciSoft now comes with
with numpy in its distribution for Mac OSX.

Just let me know.

Cheers,
Chris

Reply all
Reply to author
Forward
0 new messages