Bug 472087

Summary: Can't import scipy.stsci.image
Product: [Fedora] Fedora Reporter: Sergio Pascual <sergio.pasra>
Component: scipyAssignee: Jef Spaleta <jspaleta>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 10CC: jspaleta
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.7.0-2.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-05-12 04:06:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Stsci import patch
none
Fixes problems with translate function in scipy.stsci.image none

Description Sergio Pascual 2008-11-18 17:08:40 UTC
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 18:23:14 UTC
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 16:29:00 UTC
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 17:22:51 UTC
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 15:36:27 UTC
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 15:38:31 UTC
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 15:46:22 UTC
Created attachment 333340 [details]
Fixes problems with translate function in scipy.stsci.image

Comment 7 Jef Spaleta 2009-02-26 22:50:44 UTC
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 08:22:15 UTC
Yeah, I will test the packages

Comment 9 Jef Spaleta 2009-02-27 19:41:56 UTC
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 21:57:18 UTC
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-02 03:02:23 UTC
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 10:19:46 UTC
Seems to work, please push the update

Comment 13 Fedora Update System 2009-03-03 03:11:18 UTC
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 15:25:15 UTC
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 04:06:05 UTC
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.