problem in 86.2 cvs

I just updated this morning, and the following script fails:

import pylab as pl
pl.plot(xrange(10), xrange(10))

Here's the traceback:

···

---------------------------------------------------------------------------
exceptions.ValueError Traceback (most recent
call last)

/home/darren/<ipython console>

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py
in plot(*args, **kwargs)
   2077 def plot(*args, **kwargs):
   2078 # allow callers to override the hold state by passing hold=True|
False
-> 2079 b = ishold()
   2080 h = popd(kwargs, 'hold', None)
   2081 if h is not None:

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py
in ishold()
    938 Return the hold status of the current axes
    939 """
--> 940 return gca().ishold()
    941
    942 def isinteractive():

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py
in gca(**kwargs)
    889 """
    890
--> 891 ax = gcf().gca(**kwargs)
    892 return ax
    893

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/figure.py
in gca(self, **kwargs)
    613 ax = self._axstack()
    614 if ax is not None: return ax
--> 615 return self.add_subplot(111, **kwargs)
    616
    617 def sca(self, a):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/figure.py
in add_subplot(self, *args, **kwargs)
    463 a = PolarSubplot(self, *args, **kwargs)
    464 else:
--> 465 a = Subplot(self, *args, **kwargs)
    466
    467

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py
in __init__(self, fig, *args, **kwargs)
   4094 def __init__(self, fig, *args, **kwargs):
   4095 SubplotBase.__init__(self, fig, *args)
-> 4096 Axes.__init__(self, fig, [self.figLeft, self.figBottom,
   4097 self.figW, self.figH], **kwargs)
   4098

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py
in __init__(self, fig, rect, axisbg, frameon, sharex, sharey, label,
**kwargs)
    329
    330 # this call may differ for non-sep axes, eg polar
--> 331 self._init_axis()
    332
    333

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py
in _init_axis(self)
    358 def _init_axis(self):
    359 "move this out of __init__ because non-separable axes don't
use it"
--> 360 self.xaxis = XAxis(self)
    361 self.yaxis = YAxis(self)
    362

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py
in __init__(self, axes)
    499 self.minorTicks = []
    500
--> 501 self.cla()
    502
    503 def cla(self):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py
in cla(self)
    522 popall(self.minorTicks)
    523
--> 524 self.majorTicks.extend([self._get_tick(major=True) for i in
range(1)])
    525 self.minorTicks.extend([self._get_tick(major=False) for i in
range(1)])
    526

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py
in _get_tick(self, major)
    832
    833 def _get_tick(self, major):
--> 834 return XTick(self.axes, 0, '', major=major)
    835
    836 def _get_label(self):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py
in __init__(self, axes, loc, label, size, gridOn, tick1On, tick2On, label1On,
label2On, major)
     98
     99
--> 100 self.tick1line = self._get_tick1line(loc)
    101 self.tick2line = self._get_tick2line(loc)
    102 self.gridline = self._get_gridline(loc)

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py
in _get_tick1line(self, loc)
    274 antialiased=False,
    275 marker = self._xtickmarkers[0],
--> 276 markersize=self._size,
    277 )
    278

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py
in __init__(self, xdata, ydata, linewidth, linestyle, color, marker,
markersize, markeredgewidth, markeredgecolor, markerfacecolor, antialiased,
dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, **kwargs)
    209 self.verticalOffset = None
    210
--> 211 self.set_data(xdata, ydata)
    212
    213 if not self._lineStyles.has_key(linestyle):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py
in set_data(self, *args)
    280 x = ma.masked_array(x, mask=mask).compressed()
    281 y = ma.masked_array(y, mask=mask).compressed()
--> 282 self._segments = unmasked_index_ranges(mask)
    283 else:
    284 self._segments = None

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py
in unmasked_index_ranges(mask, compressed)
     67
     68 '''
---> 69 m = concatenate(((1,), mask, (1,)))
     70 indices = arange(len(mask) + 1)
     71 mdif = m[1:] - m[:-1]

ValueError: arrays must have same number of dimensions

Darren,

I just tried it with (numpy imported as n)
In [23]:n.__version__
Out[23]:'0.9.4.1914'

and I don't get the error. Are you using a newer version of numpy?

Eric

Darren Dale wrote:

···

I just updated this morning, and the following script fails:

import pylab as pl
pl.plot(xrange(10), xrange(10))

Here's the traceback:

---------------------------------------------------------------------------
exceptions.ValueError Traceback (most recent call last)

/home/darren/<ipython console>

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py in plot(*args, **kwargs)
   2077 def plot(*args, **kwargs):
   2078 # allow callers to override the hold state by passing hold=True|
False
-> 2079 b = ishold()
   2080 h = popd(kwargs, 'hold', None)
   2081 if h is not None:

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py in ishold()
    938 Return the hold status of the current axes
    939 """
--> 940 return gca().ishold()
    941
    942 def isinteractive():

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/pylab.py in gca(**kwargs)
    889 """
    890
--> 891 ax = gcf().gca(**kwargs)
    892 return ax
    893

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/figure.py in gca(self, **kwargs)
    613 ax = self._axstack()
    614 if ax is not None: return ax
--> 615 return self.add_subplot(111, **kwargs)
    616
    617 def sca(self, a):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/figure.py in add_subplot(self, *args, **kwargs)
    463 a = PolarSubplot(self, *args, **kwargs)
    464 else:
--> 465 a = Subplot(self, *args, **kwargs)
    466
    467

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py in __init__(self, fig, *args, **kwargs)
   4094 def __init__(self, fig, *args, **kwargs):
   4095 SubplotBase.__init__(self, fig, *args)
-> 4096 Axes.__init__(self, fig, [self.figLeft, self.figBottom,
   4097 self.figW, self.figH], **kwargs)
   4098

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py in __init__(self, fig, rect, axisbg, frameon, sharex, sharey, label, **kwargs)
    329
    330 # this call may differ for non-sep axes, eg polar
--> 331 self._init_axis()
    332
    333

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axes.py in _init_axis(self)
    358 def _init_axis(self):
    359 "move this out of __init__ because non-separable axes don't use it"
--> 360 self.xaxis = XAxis(self)
    361 self.yaxis = YAxis(self)
    362

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py in __init__(self, axes)
    499 self.minorTicks = []
    500
--> 501 self.cla()
    502
    503 def cla(self):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py in cla(self)
    522 popall(self.minorTicks)
    523
--> 524 self.majorTicks.extend([self._get_tick(major=True) for i in range(1)])
    525 self.minorTicks.extend([self._get_tick(major=False) for i in range(1)])
    526

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py in _get_tick(self, major)
    832
    833 def _get_tick(self, major):
--> 834 return XTick(self.axes, 0, '', major=major)
    835
    836 def _get_label(self):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py in __init__(self, axes, loc, label, size, gridOn, tick1On, tick2On, label1On, label2On, major)
     98
     99
--> 100 self.tick1line = self._get_tick1line(loc)
    101 self.tick2line = self._get_tick2line(loc)
    102 self.gridline = self._get_gridline(loc)

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/axis.py in _get_tick1line(self, loc)
    274 antialiased=False,
    275 marker = self._xtickmarkers[0],
--> 276 markersize=self._size,
    277 )
    278

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py in __init__(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, **kwargs)
    209 self.verticalOffset = None
    210
--> 211 self.set_data(xdata, ydata)
    212
    213 if not self._lineStyles.has_key(linestyle):

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py in set_data(self, *args)
    280 x = ma.masked_array(x, mask=mask).compressed()
    281 y = ma.masked_array(y, mask=mask).compressed()
--> 282 self._segments = unmasked_index_ranges(mask)
    283 else:
    284 self._segments = None

/usr/lib64/python2.4/site-packages/matplotlib-0.86.2cvs-py2.4-linux-x86_64.egg/matplotlib/lines.py in unmasked_index_ranges(mask, compressed)
     67
     68 '''
---> 69 m = concatenate(((1,), mask, (1,)))
     70 indices = arange(len(mask) + 1)
     71 mdif = m[1:] - m[:-1]

ValueError: arrays must have same number of dimensions

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Eric Firing wrote:

Darren,

I just tried it with (numpy imported as n)
In [23]:n.__version__
Out[23]:'0.9.4.1914'

and I don't get the error. Are you using a newer version of numpy?

This is a problem with masked arrays in the newer version of numpy. Someone is doing a lot of work on masked arrays and probably not aware of their use in matplotlib. Recently, for example, the return type for no mask was changed from None to False (I'm not sure why...I'm asking him right now). That is causing the problem because there is a check for None in the matplotlib code (but not for False...). We'll get this cleared up, thanks for the report...

-Travis

Travis Oliphant wrote:

Eric Firing wrote:

Darren,

I just tried it with (numpy imported as n)
In [23]:n.__version__
Out[23]:'0.9.4.1914'

and I don't get the error. Are you using a newer version of numpy?

This is a problem with masked arrays in the newer version of numpy. Someone is doing a lot of work on masked arrays and probably not aware of their use in matplotlib. Recently, for example, the return type for no mask was changed from None to False (I'm not sure why...I'm asking him right now). That is causing the problem because there is a check for None in the matplotlib code (but not for False...). We'll get this cleared up, thanks for the report...

Travis,

I remember seeing some discussion of this, but I did not pay enough attention to it. If it turns out that returning False is a good idea in general, then I think it will be easy to modify the mpl code to handle that, and I don't mind doing it. Just let me know what the outcome is.

Eric

Eric Firing wrote:

I remember seeing some discussion of this, but I did not pay enough attention to it. If it turns out that returning False is a good idea in general, then I think it will be easy to modify the mpl code to handle that, and I don't mind doing it. Just let me know what the outcome is.

I've committed a change to matplotlib that should fix this. Basically, the check is changed to "mask is not ma.nomask" (defined in numpy and which I defined in the numerix.ma module for numarray and Numeric to be None).

I think this should fix the problem and be more future-proof.

-Travis

Travis,

That sounds like a good solution, thanks. A change in either or both of contour.py and cntr.c will still be needed, because cntr.c is checking for Py_None.

If you want to do it, fine; otherwise I can do it this evening or tomorrow morning.

Eric

Travis Oliphant wrote:

···

Eric Firing wrote:

I remember seeing some discussion of this, but I did not pay enough attention to it. If it turns out that returning False is a good idea in general, then I think it will be easy to modify the mpl code to handle that, and I don't mind doing it. Just let me know what the outcome is.

I've committed a change to matplotlib that should fix this. Basically, the check is changed to "mask is not ma.nomask" (defined in numpy and which I defined in the numerix.ma module for numarray and Numeric to be None).

I think this should fix the problem and be more future-proof.

-Travis

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel