[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Apr 6 11:31:40 PDT 2016
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/bb5f7b3d9590/
Changeset: bb5f7b3d9590
Branch: yt
User: brittonsmith
Date: 2016-03-26 12:59:05+00:00
Summary: Take each field, value pair in data dict one at a time instead of doing the same thing for all of them.
Affected #: 1 file
diff -r a776e67368c5629296b1e365dfca0b68b41ef1d5 -r bb5f7b3d9590072b02628b47c8eebebdf6571c3e yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -464,36 +464,46 @@
ds.stream_handler.particle_count[gi] = npart
def unitify_data(data):
- if all([hasattr(val, 'units') for val in data.values()]):
- new_data, field_units = {}, {}
- for k, v in data.items():
- field_units[k] = v.units
- new_data[k] = v.copy().d
- data = new_data
- elif all([((not isinstance(val, np.ndarray)) and (len(val) == 2))
- for val in data.values()]):
- new_data, field_units = {}, {}
- for field in data:
+ new_data, field_units = {}, {}
+ for field, val in data.items():
+ # val is a data array
+ if isinstance(val, np.ndarray):
+ # val is a YTArray
+ if hasattr(val, "units"):
+ field_units[field] = val.units
+ new_data[field] = val.copy().d
+ # val is a numpy array
+ else:
+ field_units[field] = ""
+ new_data[field] = val.copy()
+
+ # val is a tuple of (data, units)
+ elif isinstance(val, tuple) and len(val) == 2:
try:
assert isinstance(field, (string_types, tuple)), \
"Field name is not a string!"
- assert isinstance(data[field][0], np.ndarray), \
+ assert isinstance(val[0], np.ndarray), \
"Field data is not an ndarray!"
- assert isinstance(data[field][1], string_types), \
+ assert isinstance(val[1], string_types), \
"Unit specification is not a string!"
- field_units[field] = data[field][1]
- new_data[field] = data[field][0]
+ field_units[field] = val[1]
+ new_data[field] = val[0]
except AssertionError as e:
- raise RuntimeError("The data dict appears to be invalid.\n" +
- str(e))
- data = new_data
- elif all([iterable(val) for val in data.values()]):
- field_units = {field:'' for field in data.keys()}
- data = dict((field, np.asarray(val)) for field, val in iteritems(data))
- else:
- raise RuntimeError("The data dict appears to be invalid. "
- "The data dictionary must map from field "
- "names to (numpy array, unit spec) tuples. ")
+ raise RuntimeError(
+ "The data dict appears to be invalid.\n" + str(e))
+
+ # val is a list of data to be turned into an array
+ elif iterable(val):
+ field_units[field] = ""
+ new_data[field] = np.asarray(val)
+
+ else:
+ raise RuntimeError("The data dict appears to be invalid. "
+ "The data dictionary must map from field "
+ "names to (numpy array, unit spec) tuples. ")
+
+ data = new_data
+
# At this point, we have arrays for all our fields
new_data = {}
for field in data:
https://bitbucket.org/yt_analysis/yt/commits/76d5bf8b5d9e/
Changeset: 76d5bf8b5d9e
Branch: yt
User: brittonsmith
Date: 2016-03-26 14:04:18+00:00
Summary: Removing import.
Affected #: 1 file
diff -r bb5f7b3d9590072b02628b47c8eebebdf6571c3e -r 76d5bf8b5d9efa4631c929a2b7c587cd7fafe39b yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -66,7 +66,7 @@
from yt.data_objects.unstructured_mesh import \
SemiStructuredMesh, \
UnstructuredMesh
-from yt.extern.six import string_types, iteritems
+from yt.extern.six import string_types
from .fields import \
StreamFieldInfo
https://bitbucket.org/yt_analysis/yt/commits/2b15ed4adb92/
Changeset: 2b15ed4adb92
Branch: yt
User: xarthisius
Date: 2016-04-06 18:31:25+00:00
Summary: Merged in brittonsmith/yt (pull request #2086)
Treat each field, value pair in data dict individually in load_particles (closes #1026)
Affected #: 1 file
diff -r 112f06b287d902edabae84e430696e4fd40bcd96 -r 2b15ed4adb92292dc18d50f778b813f7e003cfc3 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -66,7 +66,7 @@
from yt.data_objects.unstructured_mesh import \
SemiStructuredMesh, \
UnstructuredMesh
-from yt.extern.six import string_types, iteritems
+from yt.extern.six import string_types
from .fields import \
StreamFieldInfo
@@ -464,36 +464,46 @@
ds.stream_handler.particle_count[gi] = npart
def unitify_data(data):
- if all([hasattr(val, 'units') for val in data.values()]):
- new_data, field_units = {}, {}
- for k, v in data.items():
- field_units[k] = v.units
- new_data[k] = v.copy().d
- data = new_data
- elif all([((not isinstance(val, np.ndarray)) and (len(val) == 2))
- for val in data.values()]):
- new_data, field_units = {}, {}
- for field in data:
+ new_data, field_units = {}, {}
+ for field, val in data.items():
+ # val is a data array
+ if isinstance(val, np.ndarray):
+ # val is a YTArray
+ if hasattr(val, "units"):
+ field_units[field] = val.units
+ new_data[field] = val.copy().d
+ # val is a numpy array
+ else:
+ field_units[field] = ""
+ new_data[field] = val.copy()
+
+ # val is a tuple of (data, units)
+ elif isinstance(val, tuple) and len(val) == 2:
try:
assert isinstance(field, (string_types, tuple)), \
"Field name is not a string!"
- assert isinstance(data[field][0], np.ndarray), \
+ assert isinstance(val[0], np.ndarray), \
"Field data is not an ndarray!"
- assert isinstance(data[field][1], string_types), \
+ assert isinstance(val[1], string_types), \
"Unit specification is not a string!"
- field_units[field] = data[field][1]
- new_data[field] = data[field][0]
+ field_units[field] = val[1]
+ new_data[field] = val[0]
except AssertionError as e:
- raise RuntimeError("The data dict appears to be invalid.\n" +
- str(e))
- data = new_data
- elif all([iterable(val) for val in data.values()]):
- field_units = {field:'' for field in data.keys()}
- data = dict((field, np.asarray(val)) for field, val in iteritems(data))
- else:
- raise RuntimeError("The data dict appears to be invalid. "
- "The data dictionary must map from field "
- "names to (numpy array, unit spec) tuples. ")
+ raise RuntimeError(
+ "The data dict appears to be invalid.\n" + str(e))
+
+ # val is a list of data to be turned into an array
+ elif iterable(val):
+ field_units[field] = ""
+ new_data[field] = np.asarray(val)
+
+ else:
+ raise RuntimeError("The data dict appears to be invalid. "
+ "The data dictionary must map from field "
+ "names to (numpy array, unit spec) tuples. ")
+
+ data = new_data
+
# At this point, we have arrays for all our fields
new_data = {}
for field in data:
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160406/bc8bc62f/attachment.html>
More information about the yt-svn
mailing list