Bug 472087 - Can't import scipy.stsci.image
Can't import scipy.stsci.image
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: scipy (Show other bugs)
10
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jef Spaleta
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-11-18 12:08 EST by Sergio Pascual
Modified: 2009-05-12 00:06 EDT (History)
1 user (show)

See Also:
Fixed In Version: 0.7.0-2.fc10
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-05-12 00:06:10 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Stsci import patch (833 bytes, patch)
2008-11-19 11:29 EST, Sergio Pascual
no flags Details | Diff
Fixes problems with translate function in scipy.stsci.image (743 bytes, patch)
2009-02-26 10:46 EST, Sergio Pascual
no flags Details | Diff

  None (edit)
Description Sergio Pascual 2008-11-18 12:08:40 EST
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
Comment 1 Jef Spaleta 2008-11-18 13:23:14 EST
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
Comment 2 Sergio Pascual 2008-11-19 11:29:00 EST
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
Comment 3 Jef Spaleta 2008-11-19 12:22:51 EST
great I'll take a look at that patch and poke upstream about what they think of it.  

-jef
Comment 4 Sergio Pascual 2009-02-26 10:36:27 EST
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
Comment 5 Sergio Pascual 2009-02-26 10:38:31 EST
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'
Comment 6 Sergio Pascual 2009-02-26 10:46:22 EST
Created attachment 333340 [details]
Fixes problems with translate function in scipy.stsci.image
Comment 7 Jef Spaleta 2009-02-26 17:50:44 EST
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
Comment 8 Sergio Pascual 2009-02-27 03:22:15 EST
Yeah, I will test the packages
Comment 9 Jef Spaleta 2009-02-27 14:41:56 EST
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
Comment 10 Sergio Pascual 2009-02-27 16:57:18 EST
I've tested the package and it's still broken in the same place. The patch will be probably valid
Comment 11 Jef Spaleta 2009-03-01 22:02:23 EST
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
Comment 12 Sergio Pascual 2009-03-02 05:19:46 EST
Seems to work, please push the update
Comment 13 Fedora Update System 2009-03-02 22:11:18 EST
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
Comment 14 Fedora Update System 2009-03-03 10:25:15 EST
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
Comment 15 Fedora Update System 2009-05-12 00:06:05 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.