Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/matplotlib/pcolor.vt fails on matplotlib 1.4.3 #1132

Closed
rexissimus opened this issue Oct 7, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@rexissimus
Copy link
Member

commented Oct 7, 2015

It looks like the arguments to pcolor are now stricter but I am not sure how to create valid input data.

  errorTrace: Traceback (most recent call last):
  File "C:\Program Files\VisTrails x64 gdal\vistrails\core\modules\vistrails_module.py", line 573, in update
    self.compute()
  File "C:\Program Files\VisTrails x64 gdal\vistrails\packages\matplotlib\bases.py", line 107, in compute
    plot(self.figInstance)
  File "C:\Program Files\VisTrails x64 gdal\vistrails\packages\matplotlib\plots.py", line 3037, in <lambda>
    args, kwargs))
  File "C:\Program Files\VisTrails x64 gdal\vistrails\packages\matplotlib\plots.py", line 3040, in plot_figure
    polyCollection = matplotlib.pyplot.pcolor(*args, **kwargs)
  File "C:\Program Files\VisTrails x64 gdal\Python27_64\lib\site-packages\matplotlib\pyplot.py", line 3018, in pcolor
    ret = ax.pcolor(*args, **kwargs)
  File "C:\Program Files\VisTrails x64 gdal\Python27_64\lib\site-packages\matplotlib\axes\_axes.py", line 4889, in pcolor
    X, Y, C = self._pcolorargs('pcolor', *args, allmatch=False)
  File "C:\Program Files\VisTrails x64 gdal\Python27_64\lib\site-packages\matplotlib\axes\_axes.py", line 4692, in _pcolorargs
    numRows, numCols = C.shape
AttributeError: 'list' object has no attribute 'shape'
@tacaswell

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2015

This might be a regression on the mpl side.

I have a vague memory of something about this going by, can you check if it works on master?

@rexissimus

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2015

It does not work on mpl master. This is the code used to create the input to pcolor(X, Y, Z):

import numpy as np

def func3(x,y):
    return (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)


# make these smaller to increase the resolution
dx, dy = 0.05, 0.05

x = np.arange(-3.0, 3.0001, dx)
y = np.arange(-3.0, 3.0001, dy)
X, Y = np.meshgrid(x, y)

Z = func3(X, Y)

Googling the problem turns up a few suggestions, but nothing that fixes the problem.

@tacaswell

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2015

This works correctly.

import matplotlib.pyplot as plt
import numpy as np

def func3(x, ):
    return (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)


# make these smaller to increase the resolution
dx, dy = 0.05, 0.05

x = np.arange(-3.0, 3.0001, dx)
y = np.arange(-3.0, 3.0001, dy)
X, Y = np.meshgrid(x, y)

Z = func3(X, Y)

plt.pcolor(X, Y, Z)

I suspect that you can fix this on the vt side by calling np.asarray or np.vstack on the data before passing it off to pcolor. I have a rough recollection that vt passes arrays between nodes as lists?

@dakoop

This comment has been minimized.

Copy link
Member

commented Oct 7, 2015

It looks like the issue may be some list handling on the VT side.

rexissimus added a commit that referenced this issue Oct 7, 2015

get_input: Do not convert lists if it can be avoided
core/modules/vistrails_module.py:
 - get_input:
   Only merge lists if there are more than one.

Fixes #1132
@rexissimus

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2015

Fixed by 11db25b. VisTrails converted the array into a list when reading module inputs. This was both bad for performance and could cause errors when sending data other than lists on List ports.

This problem still exists if you pass arrays on 2 connections to a single List port. But there is no reason you would expect that to work anyway.

This issue was introduced when list handling was updated. It has probably never been possible to use a lists as the C argument to pcolor.

@rexissimus rexissimus closed this Oct 7, 2015

@tacaswell

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2015

Well, we also have a PR open to make it work matplotlib/matplotlib#5206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.