[yt-svn] commit/yt: xarthisius: Merged in brittonsmith/yt (pull request #2005)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Mar 2 09:31:52 PST 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/0ebb7e886c4f/
Changeset: 0ebb7e886c4f
Branch: yt
User: xarthisius
Date: 2016-03-02 17:31:44+00:00
Summary: Merged in brittonsmith/yt (pull request #2005)
[BUGFIX] fixing a couple corner cases in gadget_fof frontend
Affected #: 3 files
diff -r 5cde4c82ad67e298a3df60962bd0607fd274145f -r 0ebb7e886c4fd7deed72db2980741dcb65b8e130 yt/frontends/gadget_fof/data_structures.py
--- a/yt/frontends/gadget_fof/data_structures.py
+++ b/yt/frontends/gadget_fof/data_structures.py
@@ -334,9 +334,10 @@
dict([(ptype, False)
for ptype, pnum in self.particle_count.items()
if pnum > 0])
+ has_ids = False
for data_file in self.data_files:
- fl, sl, _units = self.io._identify_fields(data_file)
+ fl, sl, idl, _units = self.io._identify_fields(data_file)
units.update(_units)
field_list.extend([f for f in fl
if f not in field_list])
@@ -344,7 +345,8 @@
if f not in scalar_field_list])
for ptype in found_fields:
found_fields[ptype] |= data_file.total_particles[ptype]
- if all(found_fields.values()): break
+ has_ids |= len(idl) > 0
+ if all(found_fields.values()) and has_ids: break
self.field_list = field_list
self.scalar_field_list = scalar_field_list
diff -r 5cde4c82ad67e298a3df60962bd0607fd274145f -r 0ebb7e886c4fd7deed72db2980741dcb65b8e130 yt/frontends/gadget_fof/io.py
--- a/yt/frontends/gadget_fof/io.py
+++ b/yt/frontends/gadget_fof/io.py
@@ -258,6 +258,7 @@
start_index = dobj.field_data_start[i]
end_index = dobj.field_data_end[i]
pcount = end_index - start_index
+ if pcount == 0: continue
field_end = field_start + end_index - start_index
with h5py.File(data_file.filename, "r") as f:
for ptype, field_list in sorted(member_fields.items()):
@@ -298,11 +299,9 @@
def _identify_fields(self, data_file):
fields = []
scalar_fields = []
- pcount = data_file.total_particles
- if sum(pcount.values()) == 0: return fields, scalar_fields, {}
+ id_fields = {}
with h5py.File(data_file.filename, "r") as f:
for ptype in self.ds.particle_types_raw:
- if data_file.total_particles[ptype] == 0: continue
fields.append((ptype, "particle_identifier"))
scalar_fields.append((ptype, "particle_identifier"))
my_fields, my_offset_fields = \
@@ -311,8 +310,9 @@
scalar_fields.extend(my_fields)
if "IDs" not in f: continue
- fields.extend([(ptype, field) for field in f["IDs"]])
- return fields, scalar_fields, {}
+ id_fields = [(ptype, field) for field in f["IDs"]]
+ fields.extend(id_fields)
+ return fields, scalar_fields, id_fields, {}
def subfind_field_list(fh, ptype, pcount):
fields = []
diff -r 5cde4c82ad67e298a3df60962bd0607fd274145f -r 0ebb7e886c4fd7deed72db2980741dcb65b8e130 yt/frontends/gadget_fof/tests/test_outputs.py
--- a/yt/frontends/gadget_fof/tests/test_outputs.py
+++ b/yt/frontends/gadget_fof/tests/test_outputs.py
@@ -86,3 +86,29 @@
# as the array of all masses. This will test getting
# scalar fields for halos correctly.
yield assert_array_equal, ad[ptype, "particle_mass"], mass
+
+# fof/subhalo catalog with no member ids in first file
+g56 = "gadget_halos/data/groups_056/fof_subhalo_tab_056.0.hdf5"
+
+# This dataset has halos in one file and ids in another,
+# which can confuse the field detection.
+ at requires_file(g56)
+def test_unbalanced_dataset():
+ ds = data_dir_load(g56)
+ halo = ds.halo("Group", 0)
+ halo["member_ids"]
+ assert True
+
+# fof/subhalo catalog with no member ids in first file
+g76 = "gadget_halos/data/groups_076/fof_subhalo_tab_076.0.hdf5"
+
+# This dataset has one halo with particles distributed over 3 files
+# with the 2nd file being empty.
+ at requires_file(g76)
+def test_3file_halo():
+ ds = data_dir_load(g76)
+ # this halo's particles are distributed over 3 files with the
+ # middle file being empty
+ halo = ds.halo("Group", 6)
+ halo["member_ids"]
+ assert True
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