Mayavi: mlab.axes() causes exception in Mayavi 4.5.0

Created on 6 Jan 2017  ·  9Comments  ·  Source: enthought/mayavi

Hi, recently, I updated Mayavi from 4.4.4 to 4.5.0. Following the update, I am observing an exception when I use the mlab function axes(). Here is a test code (the line causing error is indicated by the comment):

from mayavi import mlab
from numpy import pi, sin, cos, mgrid
dphi, dtheta = pi/250.0, pi/250.0
[phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta]
m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4;
r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7
x = r*sin(phi)*cos(theta)
y = r*cos(phi)
z = r*sin(phi)*sin(theta)
s = mlab.mesh(x, y, z)
mlab.axes(color=(0.9,0.9,0.9))       # LINE CAUSING ERROR
mlab.show()

When the run the above code in Windows and anaconda environment, I see the following error messages:

Pop-up message (box):

Exception
In c:\anaconda\lib\site-packages\mayavi-4.5.0-py2.7-win-amd64.egg\tvtk\tvtk_base.py:569
TypeError: SetInputData argument 1:method requires a vtkDataSet, a vtkPolyDataNormals was provided. (in _wrap_call)

Message in console window:

No handlers could be found for logger "mayavi.core.common"
Exception occurred in traits notification handler.
Please check the log file for details.
Exception occurred in traits notification handler for object: <mayavi.tools.decorations.Axes object at 0x0000000011AC00A0>, trait: extent, old value: [0 0 0 0 0 0], new value: [-1.53801118  1.53801118 -2.          2.27326963 -1.53801118  1.53801118]
Traceback (most recent call last):
  File "C:\Anaconda\lib\site-packages\traits\trait_notifiers.py", line 340, in __call__
    self.handler( *args )
  File "C:\Anaconda\lib\site-packages\mayavi-4.5.0-py2.7-win-amd64.egg\mayavi\tools\decorations.py", line 373, in _extent_changed
    axes.module_manager.source.outputs[0].bounds
AttributeError: 'PolyDataNormals' object has no attribute 'bounds'

Extra information

Environment in which the above exception occurs
OS: Windows 10
Python installation: Python 2.7 installed using Anaconda
Mayavi package: mayavi 4.5.0 py27_0 menpo
VTK package: vtk 7.0.0 py27_0 menpo
PyQt package: pyqt 5.6.0 py27_1

Environment in which the above code runs OK
OS: Windows 7
Python installation: Python 2.7 installed using Anaconda
Mayavi package: mayavi 4.4.4 py27_0 menpo
VTK package: vtk 7.0.0 py27_0 menpo
PyQt package: pyqt 4.11.4 py27_5

Most helpful comment

If still of any interest, with a similar configuration to Jeitan's, I just had the same error and quieted it by editing mayavi\modules\axes.py, in update_pipeline, changing:
self.configure_input_data(self.axes, src.outputs[0])
to:
self.configure_input_data(self.axes, src.outputs[0].output)

(Former is type PolyDataNormals, latter is PolyData, which derives from DataSet.)

All 9 comments

For what it's worth, I just duplicated this error under the following conditions:

OS: Windows 10
Python installation: Python 2.7 installed using Anaconda
Mayavi package: mayavi 4.5.0 py27_0
VTK package: vtk 6.3.0 py27_1
PyQt package: pyqt 4.11.4 py27_4

If I downgrade using conda install mayavi=4.4 * the code works
Mayavi -> 4.4.0
VTK -> 5.10.1

*Unrelated note - this downgrades numpy from 1.10 to 1.9.3 which breaks Spyder, so you have to manually re-upgrade it

I have the same problem here. Nobody has a clue?

If still of any interest, with a similar configuration to Jeitan's, I just had the same error and quieted it by editing mayavi\modules\axes.py, in update_pipeline, changing:
self.configure_input_data(self.axes, src.outputs[0])
to:
self.configure_input_data(self.axes, src.outputs[0].output)

(Former is type PolyDataNormals, latter is PolyData, which derives from DataSet.)

I also encountered the issue.

@jdonegan Your suggestions fixed my problems:+1: . I reckon you should post a fix so that it does not have to be done manually

I was also having this issue and the fix from @jdonegan worked well. Was going to submit a PR but looks like @prabhuramachandran has already pushed a commit that fixes this, by instead replacing the line in question with:
self.configure_input(self.axes, src.outputs[0])

Perhaps this issue should be closed to prevent confusion?

Similarly, the same issue and similar fix should be applied to line 373 in decorations.py:
axes.axes.ranges = \
axes.module_manager.source.outputs[0].output.bounds

to solve for the error
"AttributeError: 'PolyDataNormals' object has no attribute 'bounds'"

So I believe the commit 996fb25 only fixed part of the problem.

As @TinghuiWang noted, this needs to be fixed in multiple places. However, depending on your plot call (for me it was plot3d vs points3d), you may need to change it back. I fixed it as follows:

In mayavi\modules\axes.py at line 173, I changed

self.configure_input_data(self.axes, src.outputs[0])

to

data = src.outputs[0] if not hasattr(src.outputs[0], 'output') else src.outputs[0].output
self.configure_input_data(self.axes, data)

Similarly in \mayavi\tools\decorations.py at line 372 I canged

axes.axes.ranges = axes.module_manager.source.outputs[0].bounds

to

src = axes.module_manager.source
data = src.outputs[0] if not hasattr(src.outputs[0], 'output') else src.outputs[0].output
axes.axes.ranges = data.bounds

Please fix it guys. The axes are really needed.

Follows above method, I only solved part of the problem, I still have the exception:
Exception occurred in traits notification handler for object: <mayavi.tools.decorations.Axes object at 0x11a41ce60>, trait: extent, old value: [0 0 0 0 0 0], new value: [ -2. 17. -2. 17. -4.85316642 6.54683358] NoneType: None

and no axes label on the image.

Anyone can help? Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aestrivex picture aestrivex  ·  9Comments

relyativist picture relyativist  ·  16Comments

yassersouri picture yassersouri  ·  5Comments

ktavabi picture ktavabi  ·  15Comments

stefanoborini picture stefanoborini  ·  11Comments