enthought / enthought/mayavi

Visualisation saved by EnvisageEngine cannot be loaded by mayavi core Engine

Open
#287 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.4k
Forks
316
Avg merge
7h 44m
Merged PRs (30d)
5

Description

Say you have a visualisation saved using Mayavi2 and that the visualisaton file can be loaded by Mayavi2.

However, if you try loading it using the mayavi python library, outside of Mayavi2, you get `StateSetterError` complaining that the class name of the `MayaviScene` is not the same as the saved one. Is this restriction intended? Or is there any plan for resolving the restriction?

```
>>> from mayavi import mlab
>>> mlab.get_engine()

# "saved_viz_file.mv2" is created from Mayavi2
>>> mlab.get_engine().load_visualization("saved_viz_file.mv2")
```

Traceback:

```
in ()
----> 1 mlab.get_engine().load_visualization("saved_viz_file.mv2")

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/scripting/recordable.pyc in _wrapper(*args, **kw)
43 if not record:
44 # If the method was not recorded, just call it.

---> 45 result = func(*args, **kw)
46
47 return result

/home/kit/mayavi-test/mayavi/mayavi/core/engine.pyc in load_visualization(self, file_or_fname)
293 # Update the state.

294 state_pickler.update_state(scene_state)
--> 295 scene.__set_pure_state__(scene_state)
296 # Setting the state will automatically reset the

297 # disable_render.

/home/kit/mayavi-test/mayavi/mayavi/core/scene.pyc in __set_pure_state__(self, state)
73 # Now set our complete state. Doing the scene last ensures

74 # that the camera view is set right.

---> 75 set_state(self, state, last=['scene'])
76
77 ######################################################################

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in set_state(obj, state, ignore, first, last)
953
954 def set_state(obj, state, ignore=None, first=None, last=None):
--> 955 StateSetter().set(obj, state, ignore, first, last)
956 set_state.__doc__ = StateSetter.set.__doc__
957

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in set(self, obj, state, ignore, first, last)
747 # Do the last ones in order.

748 for key in last:
--> 749 self._do(obj, key, state[key])
750
751 ######################################################################

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in _do(self, obj, key, value)
824 setattr(obj, key, self._do_tuple(getattr(obj, key), value))
825 else:
--> 826 self._do_object(getattr(obj, key), value)
827 else:
828 setattr(obj, key, value)

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in _do_object(self, obj, state)
829
830 def _do_object(self, obj, state):
--> 831 self.type_map[state.__class__](obj, state)
832
833 def _do_instance(self, obj, state):

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in _do_instance(self, obj, state)
848 else:
849 # No need to update or check since `set` does it for us.

--> 850 self.set(obj, state)
851
852 def _do_tuple(self, obj, state):

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in set(self, obj, state, ignore, first, last)
707
708 # Upgrade the state to the latest using the registry.

--> 709 self._update_and_check_state(obj, state)
710
711 self._register(obj)

/home/kit/simphony/local/lib/python2.7/site-packages/apptools/persistence/state_pickler.pyc in _update_and_check_state(self, obj, state)
803 raise StateSetterError, \
804 'Instance (%s) and state (%s) do not have the same class'\
--> 805 ' name!'%(cls.__name__, metadata['class_name'])
806 if (metadata['module'] != cls.__module__):
807 raise StateSetterError, \

StateSetterError: Instance (MayaviScene) and state (DecoratedScene) do not have the same class name!
```

Branch: master
apptools: version 4.3.0
OS: Ubuntu 12.04 LTS 64 bit

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.