[yt-svn] commit/yt: MatthewTurk: Removing some old, unused variable mesh panner objects. So long Celerita, so long MultiEngineClient, so long the rest of you.

Bitbucket commits-noreply at bitbucket.org
Mon Nov 14 14:25:25 PST 2011


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/6619cb2d4d46/
changeset:   6619cb2d4d46
branch:      yt
user:        MatthewTurk
date:        2011-11-14 23:25:16
summary:     Removing some old, unused variable mesh panner objects.  So long Celerita, so long MultiEngineClient, so long the rest of you.
affected #:  1 file

diff -r fd365f05b4f7ee1cd0e68f3ff7bc8dd6e85148e5 -r 6619cb2d4d462054a054efe1c113f7e9862357b9 yt/visualization/image_panner/vm_panner.py
--- a/yt/visualization/image_panner/vm_panner.py
+++ b/yt/visualization/image_panner/vm_panner.py
@@ -262,176 +262,6 @@
     def set_limits(self, xlim, ylim):
         for w in self.windows: w.set_limits(xlim, ylim)
 
-class RemoteWindowedVariableMeshController(MultipleWindowVariableMeshPanner):
-    def __init__(self, source, mec = None):
-        """
-        This panner controls remote windowed panners.  It requires a *source*,
-        which will be pickled and sent to the remote panners, which it will
-        create as requested.  If not supplied with a *mec* (an IPython
-        MultiEngineClient) it will create one itself.
-        """
-        if mec is None:
-            from IPython.kernel.client import get_multiengine_client
-            mec = get_multiengine_client()
-        self.mec = mec
-        self.mec.execute("import yt.extensions.image_panner")
-        self._var_name = "_image_panner_%s" % (id(self))
-        self._pf_name = "_pf_%s" % (id(self))
-        self._source_name = "_source_%s" % (id(self))
-        self.source = source
-        self.mec.execute("from yt.mods import *")
-        self.mec.execute("from yt.funcs import iterable")
-        self.mec.push({self._pf_name: self.pf})
-        self.mec.execute("%s.h" % self._pf_name)
-        self.mec.push({self._source_name: self.source})
-        # Now, because the double pickling tosses a PF hash reference inside
-        # the unpickled object, we work around it a little
-        self.mec.execute("while iterable(%s): %s = %s[1]" % (
-            self._source_name, self._source_name, self._source_name))
-        self.windows = []
-
-    def add_window(self, *args, **kwargs):
-        """
-        This will create a new remote WindowedVariableMeshImagePanner.  The
-        *args* and *kwargs* supplied here will be passed over, but the *source*
-        argument is implicitly handled by this routine.
-        """
-        engine_id = len(self.windows)
-        an = "_args_%s" % id(self)
-        kn = "_kwargs_%s" % id(self)
-        if 'callback' not in kwargs:
-            kwargs['callback'] = ImageSaver(engine_id)
-        self.mec.push({an: args, kn: kwargs}, engine_id)
-        exec_string = "%s = %s.h.windowed_image_panner(%s, *%s, **%s)" % (
-            self._var_name, self._pf_name, self._source_name, an, kn)
-        self.mec.execute(exec_string, engine_id)
-        self.windows.append(WindowedVariableMeshPannerProxy(
-            self.mec, engine_id, self._var_name, id(self)))
-
-data_object_registry["remote_image_panner"] = RemoteWindowedVariableMeshController
-
-_wrapped_methods = ["zoom", "pan", "pan_x", "pan_y", "pan_rel",
-                     "pan_rel_x", "pan_rel_y", "set_limits"]
-
-class WindowedVariableMeshPannerProxy(object):
-    class __metaclass__(type):
-        def __new__(cls, name, b, d):
-            # We add on a bunch of proxy functions
-            def return_proxy(fname):
-                def func(self, *args, **kwargs):
-                    vn = "_ret_%s" % self._cid
-                    an = "_args_%s" % self._cid
-                    kn = "_kwargs_%s" % self._cid
-                    self.mec.push({an: args, kn: kwargs}, self.engine_id)
-                    exec_string = "%s = %s.%s(*%s, **%s)" % (
-                        vn, self._var_name, fname, an, kn)
-                    print "Executing %s on %s" % (exec_string, self.engine_id)
-                    self.mec.execute(exec_string, self.engine_id)
-                    return self.mec.pull(vn, self.engine_id)
-                return func
-            new_dict = {}
-            new_dict.update(d)
-            for f in _wrapped_methods:
-                new_dict[f] = return_proxy(f)
-            return type.__new__(cls, name, b, new_dict)
-
-    def __init__(self, mec, engine_id, var_name, cid):
-        # mec here is, optionally, an instance of MultiEngineClient
-        self._var_name = var_name
-        self._cid = cid
-        self.engine_id = engine_id
-        self.mec = mec
-
-    @property
-    def bounds(self):
-        vn = "_ret_%s" % self._cid
-        self.mec.execute("%s = %s.bounds" % (vn, self._var_name),
-                         self.engine_id)
-        return self.mec.pull(vn, self.engine_id)
-
-    @property
-    def width(self):
-        vn = "_ret_%s" % self._cid
-        self.mec.execute("%s = %s.width" % (vn, self._var_name),
-                         self.engine_id)
-        return self.mec.pull(vn, self.engine_id)
-
-    @property
-    def buffer(self):
-        vn = "_ret_%s" % self._cid
-        self.mec.execute("%s = %s.buffer" % (vn, self._var_name),
-                         self.engine_id)
-        return self.mec.pull(vn, self.engine_id)
-
-    def _regenerate_buffer(self):
-        return
-
-    def _run_callback(self):
-        self.mec.execute("%s._regenerate_buffer()" % self._var_name,
-                         self.engine_id)
-        self.mec.execute("%s.callback(%s.buffer)" % (
-            self._var_name, self._var_name), self.engine_id)
-
-class ProxySource(object):
-    # This proxies only the things we know we need
-    # Note that we assume we will only have a single engine.
-    def __init__(self, mec, idnum, source_varname):
-        self.mec = mec
-        self.idnum = idnum
-        self.source_varname = source_varname
-        self.mec.execute("_tmp_%s = %s.axis" % (
-            self.idnum, self.source_varname))
-        self.axis = self.mec.pull("_tmp_%s" % self.idnum)[0]
-
-    def keys(self):
-        self.mec.execute("_tmp_%s = %s.keys()" % (
-            self.idnum, self.source_varname))
-        keys = self.mec.pull("_tmp_%s" % self.idnum)[0]
-        dd = dict( (k, None) for k in keys )
-        return dd
-
-    @property
-    def pf(self):
-        self.mec.execute("_tmp_%s = %s.pf.domain_left_edge" % (
-            self.idnum, self.source_varname))
-        DLE = self.mec.pull("_tmp_%s" % self.idnum)[0]
-        self.mec.execute("_tmp_%s = %s.pf.domain_right_edge" % (
-            self.idnum, self.source_varname))
-        DRE = self.mec.pull("_tmp_%s" % self.idnum)[0]
-        return dict(DomainLeftEdge = DLE, DomainRightEdge = DRE)
-
-class ProxyFixedResolutionBuffer(dict):
-    pass
-
-class NonLocalDataImagePanner(VariableMeshPanner):
-    def __init__(self, mec, source_varname, size, field,
-                 callback = None, viewport_callback = None):
-        self.source_varname = source_varname
-        self._var_name = "_image_panner_%s" % (id(self))
-        self.mec = mec
-        self.mec.execute("import yt.extensions.image_panner")
-        self.mec.execute("%s = yt.extensions.image_panner.VariableMeshPanner(" % (
-                        self._var_name) +
-                          "%s, (%s, %s), '%s')" % (
-                        source_varname, size[0], size[1], field))
-
-        ps = ProxySource(mec, id(self), source_varname)
-        self._prfb = ProxyFixedResolutionBuffer()
-
-        VariableMeshPanner.__init__(self, ps, size, field,
-                        callback, viewport_callback)
-
-    def _regenerate_buffer(self):
-        args = (self.xlim, self.ylim)
-        self.mec.push({'_tmp_%s' % id(self) : args}, block=False)
-        self.mec.execute("%s.set_limits(*_tmp_%s)" % (self._var_name, id(self)),
-                         block=False)
-        self.mec.execute("_tmp_%s = %s.buffer" % (id(self), self._var_name),
-                         block=False)
-        self._prfb[self.field] = self.mec.pull("_tmp_%s" % (id(self)))[0]
-        self._prfb.bounds = self.xlim + self.ylim
-        self._buffer = self._prfb
-
 class ImageSaver(object):
     def __init__(self, tile_id):
         """
@@ -479,43 +309,3 @@
         tf.close()
         self.transport.append(response_body)
 
-class PanningCeleritasStreamer(object):
-    _initialized = False
-    def __init__(self, tile_id, cmap = "algae", port = 9988,
-                 zlim = (0.0, 1.0), take_log = True):
-        """
-        This is an in-development mechanism for supplying buffers to a
-        Celeritas server.
-        """
-        self.tile_id = tile_id
-        self._port = port
-        self.cmap = cmap
-        self.zlim = zlim
-        self.take_log = True
-
-    def initialize(self, shape):
-        if isinstance(self.cmap, types.StringTypes):
-            import matplotlib.cm
-            self.cmap = matplotlib.cm.get_cmap(self.cmap)
-
-        import celeritas_streamer
-        self.cs = celeritas_streamer.CeleritasStream()
-        #print "Setting shape: %s and port: %s in %s" % (
-        #    shape, self._port, os.getpid())
-        self.cs.setSize(*shape)
-        self.cs.setLocalPort(self._port)
-        self.cs.initialize()
-        self._initialized = True
-
-    def __call__(self, val):
-        if not self._initialized: self.initialize(val.shape)
-        if self.take_log:
-            vv = na.log10(val)
-        else:
-            vv = val.copy()
-        na.subtract(vv, self.zlim[0], vv)
-        na.divide(vv, (self.zlim[1]-self.zlim[0]), vv)
-        new_buf = self.cmap(vv)[:,:,:3]
-        na.multiply(new_buf, 255.0, new_buf)
-        new_buf = new_buf.astype('uint8')
-        self.cs.readFromRGBMemAndSend(new_buf)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list