[yt-svn] commit/yt: ngoldbaum: Merged in brittonsmith/yt (pull request #2541)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Mar 13 11:59:54 PDT 2017
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/207d62a00399/
Changeset: 207d62a00399
Branch: yt
User: ngoldbaum
Date: 2017-03-13 18:59:48+00:00
Summary: Merged in brittonsmith/yt (pull request #2541)
Allow cut regions to work with save_as_dataset (closes Issue #1330)
Approved-by: Nathan Goldbaum
Approved-by: Kacper Kowalik
Affected #: 3 files
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 207d62a0039957c5adb7e07fe7d0bcf73ab3e8c7 yt/frontends/ytdata/data_structures.py
--- a/yt/frontends/ytdata/data_structures.py
+++ b/yt/frontends/ytdata/data_structures.py
@@ -275,7 +275,7 @@
# since this is now particle-like data.
data_type = self.parameters.get("data_type")
container_type = self.parameters.get("container_type")
- ex_container_type = ["cutting", "proj", "ray", "slice"]
+ ex_container_type = ["cutting", "proj", "ray", "slice", "cut_region"]
if data_type == "yt_light_ray" or container_type in ex_container_type:
mylog.info("Returning an all_data data container.")
return self.all_data()
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 207d62a0039957c5adb7e07fe7d0bcf73ab3e8c7 yt/frontends/ytdata/tests/test_outputs.py
--- a/yt/frontends/ytdata/tests/test_outputs.py
+++ b/yt/frontends/ytdata/tests/test_outputs.py
@@ -100,6 +100,12 @@
assert isinstance(sphere_ds, YTDataContainerDataset)
yield YTDataFieldTest(full_fn, ("grid", "density"))
yield YTDataFieldTest(full_fn, ("all", "particle_mass"))
+ cr = ds.cut_region(sphere, ['obj["temperature"] > 1e4'])
+ fn = cr.save_as_dataset(fields=["temperature"])
+ full_fn = os.path.join(tmpdir, fn)
+ cr_ds = load(full_fn)
+ assert isinstance(cr_ds, YTDataContainerDataset)
+ assert (cr["temperature"] == cr_ds.data["temperature"]).all()
os.chdir(curdir)
shutil.rmtree(tmpdir)
diff -r 1088ca4ac8d84017d1809a6f114c852297286350 -r 207d62a0039957c5adb7e07fe7d0bcf73ab3e8c7 yt/frontends/ytdata/utilities.py
--- a/yt/frontends/ytdata/utilities.py
+++ b/yt/frontends/ytdata/utilities.py
@@ -239,4 +239,9 @@
val = np.array(val)
if val.dtype.kind == 'U':
val = val.astype('|S')
- fh.attrs[str(attr)] = val
+ try:
+ fh.attrs[str(attr)] = val
+ # This is raised if no HDF5 equivalent exists.
+ # In that case, save its string representation.
+ except TypeError:
+ fh.attrs[str(attr)] = str(val)
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