Red Hat Bugzilla – Bug 472087

Can't import scipy.stsci.image

Last modified: 2009-05-12 00:06:10 EDT

A new stsci bug. I can't import scipy.stsci.image $ python >>> import scipy >>> import scipy.stsci >>> import scipy.stsci.image Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.5/site-packages/scipy/stsci/image/__init__.py", line 2, in <module> from _image import * File "/usr/lib64/python2.5/site-packages/scipy/stsci/image/_image.py", line 2, in <module> import convolve ImportError: No module named convolve >>> scipy.stsci provides convolve, but it seems the import sentences in _image.py aren't correct

that looks like an upstream relevant bug. If you can get the import calls sorted out and send a patch in to me I'm incorporate it and send it upstream if its still necessary in scipy trunk. -jef

Created attachment 324072 [details] Stsci import patch Well, I have just started learning python and I don't quite understand the magic behind import. Anyway, I have found two ways of fixing the problem, either use full paths in the imports: import scipy.stsci.convolve as convolve or use relative imports: from .. import convolve this last one only works in python 2.5 though I have found another problem, a sentence with a.type(), where a is a numpy array. I have changed it by a.dtype

great I'll take a look at that patch and poke upstream about what they think of it. -jef

This bug isn't completely fixed in scipy-0.7.0-0.1.b1.fc10 This code fails: import scipy.stsci.image as im import numpy a = numpy.zeros((4,4)) im.translate(a, 1, 1) With this traceback: /usr/lib64/python2.5/site-packages/scipy/stsci/image/_image.pyc in translate(a, sdx, sdy, output, mode, cval) 51 b = np.rot90(a, rotation) 52 c = _correlate.Shift2d(b, int(dx), int(dy), ---> 53 mode=convolve.pix_modes[mode]) 54 d = _translate(c, dx % 1, dy % 1, output, mode, cval) 55 if output is not None: NameError: global name 'convolve' is not defined

And if you fix the previous error, you get the following: import scipy.stsci.image as im import numpy a = numpy.zeros((4,4)) im.translate(a, 1, 1) /usr/lib64/python2.5/site-packages/scipy/stsci/image/_image.py in translate(a, sdx, sdy, output, mode, cval) 54 d = _translate(c, dx % 1, dy % 1, output, mode, cval) 55 if output is not None: 56 output._copyFrom(np.rot90(output, -rotation%4)) 57 else: ---> 58 return np.rot90(d, -rotation % 4).astype(a.type()) AttributeError: 'numpy.ndarray' object has no attribute 'type'

Created attachment 333340 [details] Fixes problems with translate function in scipy.stsci.image

0.7 was released a couple of weeks ago. If I build packages of that release will you test them for me. I hate applying a patch if I can move from a beta release to the final release and get it fixed. -jef

Yeah, I will test the packages

Freshly built 0.7 release rpms can be found from the appropriate architecture links here: http://koji.fedoraproject.org/koji/taskinfo?taskID=1205853 Please download and test these packages. If the scipy.stsci.image implementation still needs to be patched, let me know and I can try to drive that patch upstream as well. -jef

I've tested the package and it's still broken in the same place. The patch will be probably valid

patched scipy binarys now available http://koji.fedoraproject.org/koji/taskinfo?taskID=1212116 Please test these and if they pass your initial testing I'll push these to updates-testing repository. -jef

Seems to work, please push the update

scipy-0.7.0-2.fc10 has been submitted as an update for Fedora 10. http://admin.fedoraproject.org/updates/scipy-0.7.0-2.fc10

scipy-0.7.0-2.fc10 has been pushed to the Fedora 10 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update scipy'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2009-2251

scipy-0.7.0-2.fc10 has been pushed to the Fedora 10 stable repository. If problems still persist, please make note of it in this bug report.