Segmentation fault when calling imshow with complex array

Hi,

I have a problem with pyplot. When I'm passing an numpy array with complex
entries to imshow I receive the error message:
TypeError: array cannot be safely cast to required type
Which is ok, when I thereafter call imshow with a valid image (i)python
segfaults. Sometimes it even segfaults instead of the above error message:

Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from matplotlib.pyplot import *

/usr/lib/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module
dateutil was already imported from
/var/lib/python-support/python2.5/dateutil/__init__.py, but
/var/lib/python-support/python2.5 is being added to sys.path
from pkg_resources import resource_stream

from numpy import *
X = random.uniform(size=(10,10))
Xc = X*1j
imshow(X)

<matplotlib.image.AxesImage object at 0x295e2d0>

imshow(X)

<matplotlib.image.AxesImage object at 0x253efd0>

imshow(X)

<matplotlib.image.AxesImage object at 0x2970f90>

imshow(X)

<matplotlib.image.AxesImage object at 0x296d790>

imshow(X)

<matplotlib.image.AxesImage object at 0x2973ed0>

imshow(X)

<matplotlib.image.AxesImage object at 0x29752d0>

imshow(X)

<matplotlib.image.AxesImage object at 0x2975610>

imshow(X)

<matplotlib.image.AxesImage object at 0x29758d0>

imshow(X)

<matplotlib.image.AxesImage object at 0x2975b90>

imshow(X)

<matplotlib.image.AxesImage object at 0x2975e50>

imshow(X)

<matplotlib.image.AxesImage object at 0x2975a50>

imshow(X)

<matplotlib.image.AxesImage object at 0x297b390>

imshow(X)

<matplotlib.image.AxesImage object at 0x297b6d0>

imshow(X)

<matplotlib.image.AxesImage object at 0x297b990>

imshow(X)

<matplotlib.image.AxesImage object at 0x297bc50>

imshow(X)

<matplotlib.image.AxesImage object at 0x297bf10>

imshow(X)

<matplotlib.image.AxesImage object at 0x297bb10>

imshow(X)

<matplotlib.image.AxesImage object at 0x297f4d0>

imshow(X)

<matplotlib.image.AxesImage object at 0x297f790>

imshow(X)

<matplotlib.image.AxesImage object at 0x297fa50>

imshow(X)

<matplotlib.image.AxesImage object at 0x297fd10>

imshow(Xc)

Segmentation fault

The only deterministic behaviour after calling imshow with a complex array
is that it segfaults anytime. Quite annoying because I forget to convert to
real quite often 8-).

I use matplotlib, python, and numpy with the latest backport version
available in Ubuntu Intrepid 8.10 amd64 (numpy 1.1.1, python 2.5.2,
matplotlib
0.98.3). Does also crash in ipython 0.9.1 with and without -pylab flag
started.

I filed a bug but so far no one responded, so maybe here's some help.
http://sourceforge.net/tracker2/?func=detail&aid=2502029&group_id=80706&atid=560720

Cheers

Phil

···

--
View this message in context: http://www.nabble.com/Segmentation-fault-when-calling-imshow-with-complex-array-tp21473274p21473274.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Thanks for the report.

This issue is actually already fixed in matplotlib SVN as of r6283:

You can use the above patch to patch your local copy if you don't want to install entirely from SVN.

Mike

Philipp Lies wrote:

···

Hi,

I have a problem with pyplot. When I'm passing an numpy array with complex
entries to imshow I receive the error message:
TypeError: array cannot be safely cast to required type
Which is ok, when I thereafter call imshow with a valid image (i)python
segfaults. Sometimes it even segfaults instead of the above error message:

Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  

from matplotlib.pyplot import *
        

/usr/lib/python2.5/site-packages/pytz/__init__.py:29: UserWarning: Module
dateutil was already imported from
/var/lib/python-support/python2.5/dateutil/__init__.py, but
/var/lib/python-support/python2.5 is being added to sys.path
from pkg_resources import resource_stream
  

from numpy import *
X = random.uniform(size=(10,10))
Xc = X*1j
imshow(X)
        

<matplotlib.image.AxesImage object at 0x295e2d0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x253efd0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2970f90>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x296d790>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2973ed0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x29752d0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2975610>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x29758d0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2975b90>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2975e50>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x2975a50>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297b390>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297b6d0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297b990>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297bc50>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297bf10>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297bb10>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297f4d0>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297f790>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297fa50>
  

imshow(X)
        

<matplotlib.image.AxesImage object at 0x297fd10>
  

imshow(Xc)
        

Segmentation fault

The only deterministic behaviour after calling imshow with a complex array
is that it segfaults anytime. Quite annoying because I forget to convert to
real quite often 8-).

I use matplotlib, python, and numpy with the latest backport version
available in Ubuntu Intrepid 8.10 amd64 (numpy 1.1.1, python 2.5.2,
matplotlib
0.98.3). Does also crash in ipython 0.9.1 with and without -pylab flag
started.

I filed a bug but so far no one responded, so maybe here's some help.
http://sourceforge.net/tracker2/?func=detail&aid=2502029&group_id=80706&atid=560720

Cheers

Phil
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA