예제 #1
0
    def test_pickle(self):
        """Test if pickler works correctly with FilePaths.
        """
        t = Test()
        t.f.set('t.vtk')
        cwd = os.getcwd()

        # Create a dummy file in the parent dir.
        s = StringIO.StringIO()
        # Spoof its location.
        s.name = abspath(join(cwd, os.pardir, 't.mv2'))
        # Dump into it
        state_pickler.dump(t, s)

        # Rewind the stream
        s.seek(0)
        # "Move" the file elsewhere
        s.name = join(cwd, 'foo', 'test', 't.mv2')
        state = state_pickler.load_state(s)
        self.assertEqual(state.f.abs_pth,
                         join(cwd, 'foo', 'test', 'tests', 't.vtk'))

        # Create a dummy file in a subdir.
        s = StringIO.StringIO()
        # Spoof its location.
        s.name = abspath(join(cwd, 'data', 't.mv2'))
        # Dump into it.
        state_pickler.dump(t, s)

        # Rewind the stream
        s.seek(0)
        # "Move" the file elsewhere
        s.name = join(cwd, 'foo', 'test', 't.mv2')
        state = state_pickler.load_state(s)
        self.assertEqual(state.f.abs_pth, join(cwd, 'foo', 't.vtk'))
예제 #2
0
 def save_visualization(self, file_or_fname):
     """Given a file or a file name, this saves the current
     visualization to the file.
     """
     # Save the state of VTK's global warning display.
     o = vtk.vtkObject
     w = o.GetGlobalWarningDisplay()
     o.SetGlobalWarningDisplay(0)  # Turn it off.
     try:
         state_pickler.dump(self, file_or_fname)
     finally:
         # Reset the warning state.
         o.SetGlobalWarningDisplay(w)
예제 #3
0
 def save_visualization(self, file_or_fname):
     """Given a file or a file name, this saves the current
     visualization to the file.
     """
     # Save the state of VTK's global warning display.
     o = vtk.vtkObject
     w = o.GetGlobalWarningDisplay()
     o.SetGlobalWarningDisplay(0) # Turn it off.
     try:
         state_pickler.dump(self, file_or_fname)
     finally:
         # Reset the warning state.
         o.SetGlobalWarningDisplay(w)
예제 #4
0
    def test_pickle(self):
        """Test if pickler works correctly with FilePaths.
        """
        t = Test()
        t.f.set('t.vtk')
        cwd = os.getcwd()

        # Create a dummy file in the parent dir.
        s = StringIO.StringIO()
        # Spoof its location.
        s.name = abspath(join(cwd, os.pardir, 't.mv2'))
        # Dump into it
        state_pickler.dump(t, s)

        # Rewind the stream
        s.seek(0)
        # "Move" the file elsewhere
        s.name = join(cwd, 'foo', 'test', 't.mv2')
        state = state_pickler.load_state(s)
        self.assertEqual(state.f.abs_pth,
                         join(cwd, 'foo', 'test', 'tests', 't.vtk'))


        # Create a dummy file in a subdir.
        s = StringIO.StringIO()
        # Spoof its location.
        s.name = abspath(join(cwd, 'data', 't.mv2'))
        # Dump into it.
        state_pickler.dump(t, s)

        # Rewind the stream
        s.seek(0)
        # "Move" the file elsewhere
        s.name = join(cwd, 'foo', 'test', 't.mv2')
        state = state_pickler.load_state(s)
        self.assertEqual(state.f.abs_pth,
                         join(cwd, 'foo', 't.vtk'))
예제 #5
0
#!/usr/bin/env python
"""
Script used to create lut lists used by mayavi from matplotlib colormaps.
This requires matlplotlib to be installed and should not be ran by the
user, but only once in a while to synchronize with MPL developpement.
"""
# Authors: Frederic Petit <*****@*****.**>,
#          Gael Varoquaux <*****@*****.**>
# Copyright (c) 2007-2009, Enthought, Inc.
# License: BSD Style.

import os
import numpy as np

from matplotlib.cm import datad, get_cmap
from enthought.mayavi.core import lut as destination_module
from enthought.persistence import state_pickler
target_dir = os.path.dirname(destination_module.__file__)

values = np.linspace(0., 1., 256)

lut_dic = {}

for name in datad.keys():
    if name.endswith('_r'):
        continue
    lut_dic[name] = get_cmap(name)(values.copy())

out_name = os.path.join(target_dir, 'pylab_luts.pkl')
state_pickler.dump(lut_dic, out_name)
예제 #6
0
"""
Script used to create lut lists used by mayavi from matplotlib colormaps.
This requires matlplotlib to be installed and should not be ran by the
user, but only once in a while to synchronize with MPL developpement.
"""
# Authors: Frederic Petit <*****@*****.**>, 
#          Gael Varoquaux <*****@*****.**>
# Copyright (c) 2007-2009, Enthought, Inc.
# License: BSD Style.

import os
import numpy as np 

from matplotlib.cm import datad, get_cmap
from enthought.mayavi.core import lut as destination_module
from enthought.persistence import state_pickler
target_dir = os.path.dirname(destination_module.__file__)

values = np.linspace(0., 1., 256)

lut_dic = {}

for name in datad.keys():
    if name.endswith('_r'):
        continue
    lut_dic[name] = get_cmap(name)(values.copy())

out_name = os.path.join(target_dir, 'pylab_luts.pkl')
state_pickler.dump(lut_dic, out_name)