griddata bug

Hi,

I did a quick search of the archives and didn’t find anything so here’s a post of what I’m pretty sure is a bug in griddata of matplotlib.mlab:
Matplotlib version: 0.99.1.1

mlab.py: Line 2527

if hasattr(z,‘mask’):
x = x.compress(z.mask == False)
y = y.compress(z.mask == False)
z = z.compressed()

This throws up if you have a scalar mask of ‘False’, which would happen for instance after numpy.ma.masked_equal() where no values were masked.

A simple fix would be:

if (hasattr(z, 'mask)):
if (hasattr(z.mask, ‘ndim’)):
x = x.compress(z.mask == False)
y = y.compress(z.mask == False)
z = z.compressed()

Not sure what the best numpy array attribute would be to check for.

Thanks,
James

James Conners wrote:

Hi,

I did a quick search of the archives and didn't find anything so here's a post of what I'm pretty sure is a bug in griddata of matplotlib.mlab:
Matplotlib version: 0.99.1.1

mlab.py: Line 2527

if hasattr(z,'mask'):
    x = x.compress(z.mask == False)
    y = y.compress(z.mask == False)
    z = z.compressed()

This throws up if you have a scalar mask of 'False', which would happen for instance after numpy.ma.masked_equal() where no values were masked.

A simple fix would be:

if (hasattr(z, 'mask)):
    if (hasattr(z.mask, 'ndim')):
        x = x.compress(z.mask == False)
        y = y.compress(z.mask == False)
        z = z.compressed()

Not sure what the best numpy array attribute would be to check for.

Thanks,
James

James: It's fixed now in SVN, thanks for the report.

-Jeff