[yt-svn] commit/yt: MatthewTurk: Ensure that Stream data outputs get added to the _cached_pfs.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Mar 16 07:35:25 PDT 2013
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/5b79077a918d/
changeset: 5b79077a918d
branch: yt
user: MatthewTurk
date: 2013-03-16 15:34:30
summary: Ensure that Stream data outputs get added to the _cached_pfs.
Also and check for them during pickle reconstruction. Fixes test_pickle.
affected #: 3 files
diff -r e59b164d12e5fd6547e92a02f6333b4868bc4b87 -r 5b79077a918d2c91fd74b734946138d81dbd83d5 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -4628,11 +4628,19 @@
narg = [_check_nested_args(a, ref_pf) for a in arg]
return narg
+def _get_pf_by_hash(hash):
+ from yt.data_objects.static_output import _cached_pfs
+ for pf in _cached_pfs.values():
+ if pf._hash() == hash: return pf
+ return None
+
def _reconstruct_object(*args, **kwargs):
pfid = args[0]
dtype = args[1]
- pfs = ParameterFileStore()
- pf = pfs.get_pf_hash(pfid)
+ pf = _get_pf_by_hash(pfid)
+ if not pf:
+ pfs = ParameterFileStore()
+ pf = pfs.get_pf_hash(pfid)
field_parameters = args[-1]
# will be much nicer when we can do pfid, *a, fp = args
args = args[2:-1]
diff -r e59b164d12e5fd6547e92a02f6333b4868bc4b87 -r 5b79077a918d2c91fd74b734946138d81dbd83d5 yt/data_objects/tests/test_pickle.py
--- a/yt/data_objects/tests/test_pickle.py
+++ b/yt/data_objects/tests/test_pickle.py
@@ -1,5 +1,6 @@
from yt.testing import fake_random_pf, assert_equal
from yt.analysis_modules.level_sets.api import identify_contours
+import yt.data_objects.api
import cPickle
import os
@@ -11,7 +12,7 @@
def test_save_load_pickle():
- test_pf = fake_random_pf(64)
+ pf = fake_random_pf(64)
# create extracted region from boolean (fairly complex object)
center = (pf.domain_left_edge + pf.domain_right_edge) / 2
diff -r e59b164d12e5fd6547e92a02f6333b4868bc4b87 -r 5b79077a918d2c91fd74b734946138d81dbd83d5 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -25,6 +25,7 @@
import weakref
import numpy as np
+import uuid
from yt.utilities.io_handler import io_registry
from yt.funcs import *
@@ -302,7 +303,10 @@
#self._conversion_override = conversion_override
self.stream_handler = stream_handler
- StaticOutput.__init__(self, "InMemoryParameterFile", self._data_style)
+ name = "InMemoryParameterFile_%s" % (uuid.uuid4().hex)
+ from yt.data_objects.static_output import _cached_pfs
+ _cached_pfs[name] = self
+ StaticOutput.__init__(self, name, self._data_style)
self.units = {}
self.time_units = {}
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