-
Notifications
You must be signed in to change notification settings - Fork 282
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
mlab.test_imshow() fail #52
Comments
The original code causing the problem is here (mayavi/tools/modules.py:72):
It turns out that when "line_width" is not an attribute of whatever object is actor.property or _target.property, a TraitError is thrown (for at least some items) and not an AttributeError, which is what would be handled by the exception handlers above. TraitError is defined in another package called traits, which is in a separate folder to mayavi. I have modified my local copy of modules.py:72 to look like this:
Basically, I am explicitly testing for the presence of the desired attributes. I have nowhere near enough knowledge about the mayavi codebase to know whether this is the right way to approach this problem or not. Adding an import (from traits.api import TraitError) and adding TraitError to the exception handlers in the original code feels icky to me. |
I'm having the same problem. |
A also have this problem, my environment Windows 7, python(x,y) distribution. Thank you for your patch, it solve this problem in my environment! |
Same here on Mac OS X 10.8.4, with MacPorts Python 2.7.6, |
Fixed with #96. |
Mac OSX 10.8, current macports build of Python 2.7.3 and vtk 5.10, and mayavi++ built through ets.py cloned from github, gives me the following error:
In [2]: mlab.test_imshow()
TraitError Traceback (most recent call last)
in ()
----> 1 mlab.test_imshow()
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/helper_functions.pyc in test_imshow()
620 """
621 s = numpy.random.random((10, 10))
--> 622 return imshow(s, colormap='gist_earth')
623
624
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/helper_functions.pyc in the_function(_args, *_kwargs)
34
35 def the_function(_args, *_kwargs):
---> 36 return pipeline(_args, *_kwargs)
37
38 if hasattr(pipeline, 'doc'):
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/helper_functions.pyc in call(self, _args, *_kwargs)
79 scene.disable_render = True
80 # Then call the real logic
---> 81 output = self.call_internal(_args, *_kwargs)
82 # And re-enable the rendering, if needed.
83 if scene is not None:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/helper_functions.pyc in call_internal(self, _args, *_kwargs)
92 # Copy the pipeline so as not to modify it for the next call
93 self.pipeline = self._pipeline[:]
---> 94 return self.build_pipeline()
95
96 def store_kwargs(self, kwargs):
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/helper_functions.pyc in build_pipeline(self)
120 if key in keywords:
121 this_kwargs[key] = value
--> 122 object = pipe(object, **this_kwargs)._target
123 return object
124
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/modules.pyc in init(self, _args, *_kwargs)
153
154 def init(self, _args, *_kwargs):
--> 155 super(DataModuleFactory, self).init(_args, *_kwargs)
156 # We are adding data to the scene, reset the zoom:
157 scene = self._scene.scene
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/pipe_base.pyc in init(self, parent, **kwargs)
161 # Now calling the traits setter, so that traits handlers are
162 # called
--> 163 self.set(**traits)
164 if scene is not None:
165 scene.disable_render = not self._do_redraw
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/pipe_base.pyc in set(self, trait_change_notify, **traits)
177 try:
178 if callback is not None:
--> 179 callback()
180 self._anytrait_changed(trait, value)
181 except TraitError:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mayavi-4.2.1-py2.7-macosx-10.8-x86_64.egg/mayavi/tools/modules.pyc in _line_width_changed(self)
73 def _line_width_changed(self):
74 try:
---> 75 self._target.actor.property.line_width = self.line_width
76 except AttributeError:
77 try:
TraitError: Cannot set the undefined 'line_width' attribute of a 'ImageProperty' object.
The text was updated successfully, but these errors were encountered: