[yt-svn] commit/yt: 7 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 15 13:21:53 PDT 2015
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/357204ed8112/
Changeset: 357204ed8112
Branch: yt
User: ngoldbaum
Date: 2015-09-05 01:18:40+00:00
Summary: Add SPH fields to OWLS answer tests
Affected #: 1 file
diff -r 8cd86c7bb679591ca26c8380f26657b7152a0654 -r 357204ed811215dc9520b9e34ffb8b9d8a6496f3 yt/frontends/owls/tests/test_outputs.py
--- a/yt/frontends/owls/tests/test_outputs.py
+++ b/yt/frontends/owls/tests/test_outputs.py
@@ -14,22 +14,32 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import \
+ assert_equal, \
+ requires_file
from yt.utilities.answer_testing.framework import \
requires_ds, \
- small_patch_amr, \
- big_patch_amr, \
data_dir_load, \
PixelizedProjectionValuesTest, \
FieldValuesTest, \
create_obj
from yt.frontends.owls.api import OWLSDataset
-_fields = (("deposit", "all_density"), ("deposit", "all_count"),
- ("deposit", "PartType0_density"),
- ("deposit", "PartType4_density"))
+os33 = "snapshot_033/snap_033.0.hdf5"
-os33 = "snapshot_033/snap_033.0.hdf5"
+_fields = (
+ ("gas", "density")
+ ("gas", "temperature"),
+ ('gas', 'He_p0_number_density'),
+ ('gas', 'N_p1_number_density'),
+ ('gas', 'velocity_magnitude'),
+ ("deposit", "all_density"),
+ ("deposit", "all_count"),
+ ("deposit", "all_cic")
+ ("deposit", "PartType0_density"),
+ ("deposit", "PartType4_density"))
+
+
@requires_ds(os33, big_data=True)
def test_snapshot_033():
ds = data_dir_load(os33)
https://bitbucket.org/yt_analysis/yt/commits/3ecb2b5d913a/
Changeset: 3ecb2b5d913a
Branch: yt
User: ngoldbaum
Date: 2015-09-05 01:18:46+00:00
Summary: Add gadget answer tests
Affected #: 1 file
diff -r 357204ed811215dc9520b9e34ffb8b9d8a6496f3 -r 3ecb2b5d913ac1532107c7675baf4a17ba083e32 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -1,5 +1,5 @@
"""
-Gadget frontend tests using the IsothermalCollapse dataset
+Gadget frontend tests
@@ -14,15 +14,89 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import requires_file, assert_equal
from yt.utilities.answer_testing.framework import \
+ data_dir_load, \
requires_ds, \
- data_dir_load
-from yt.frontends.gadget.api import GadgetHDF5Dataset
+ PixelizedProjectionValuesTest, \
+ FieldValuesTest, \
+ create_obj
+from yt.frontends.gadget.api import GadgetHDF5Dataset, GadgetDataset
-isothermal = "IsothermalCollapse/snap_505.hdf5"
- at requires_file(isothermal)
+isothermal_h5 = "IsothermalCollapse/snap_505.hdf5"
+isothermal_bin = "IsothermalCollapse/snap_505"
+gdg = "GadgetDiskGalaxy/snapshot_0200.hdf5"
+
+_fields = (
+ ("gas", "density")
+ ("gas", "temperature"),
+ ('gas', 'velocity_magnitude'),
+ ("deposit", "all_density"),
+ ("deposit", "all_count"),
+ ("deposit", "all_cic")
+ ("deposit", "PartType0_density"),
+ ("deposit", "PartType4_density")
+)
+
+iso_kwargs = dict(bounding_box=[[-3, 3], [-3, 3], [-3, 3]])
+gdg_kwargs = dict(bounding_box=[[-1e5, 1e5], [-1e5, 1e5], [-1e5, 1e5]])
+
+
+ at requires_file(isothermal_h5)
+ at requires_file(isothermal_bin)
def test_GadgetDataset():
- kwargs = dict(bounding_box=[[-3,3], [-3,3], [-3,3]])
- assert isinstance(data_dir_load(isothermal, kwargs=kwargs),
+ assert isinstance(data_dir_load(isothermal_h5, kwargs=iso_kwargs),
GadgetHDF5Dataset)
+ assert isinstance(data_dir_load(isothermal_bin, kwargs=iso_kwargs),
+ GadgetDataset)
+
+
+ at requires_ds(isothermal_h5)
+def test_iso_collapse():
+ ds = data_dir_load(isothermal_h5, kwargs=iso_kwargs)
+ yield assert_equal, str(ds), "snap_505"
+ dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
+ dd = ds.all_data()
+ yield assert_equal, dd["particle_position"].shape, (2**17, 3)
+ tot = sum(dd[ptype, "particle_position"].shape[0]
+ for ptype in ds.particle_types if ptype != "all")
+ yield assert_equal, tot, (2**17)
+ for dobj_name in dso:
+ for field in _fields:
+ if 'PartType4' in field[1]:
+ continue
+ for axis in [0, 1, 2]:
+ for weight_field in [None, "density"]:
+ yield PixelizedProjectionValuesTest(
+ isothermal_h5, axis, field, weight_field,
+ dobj_name)
+ yield FieldValuesTest(isothermal_h5, field, dobj_name)
+ dobj = create_obj(ds, dobj_name)
+ s1 = dobj["ones"].sum()
+ s2 = sum(mask.sum() for block, mask in dobj.blocks)
+ yield assert_equal, s1, s2
+
+
+ at requires_ds(gdg, big_data=True)
+def test_snapshot_200():
+ ds = data_dir_load(gdg)
+ yield assert_equal, str(ds), "snapshot_200"
+ dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
+ dd = ds.all_data()
+ yield assert_equal, dd["particle_position"].shape[0], 11907080
+ yield assert_equal, dd["particle_position"].shape[1], 3
+ tot = sum(dd[ptype, "particle_position"].shape[0]
+ for ptype in ds.particle_types if ptype != "all")
+ yield assert_equal, tot, 11907080
+ for dobj_name in dso:
+ for field in _fields:
+ for axis in [0, 1, 2]:
+ for weight_field in [None, "density"]:
+ yield PixelizedProjectionValuesTest(
+ gdg, axis, field, weight_field,
+ dobj_name)
+ yield FieldValuesTest(gdg, field, dobj_name)
+ dobj = create_obj(ds, dobj_name)
+ s1 = dobj["ones"].sum()
+ s2 = sum(mask.sum() for block, mask in dobj.blocks)
+ yield assert_equal, s1, s2
https://bitbucket.org/yt_analysis/yt/commits/0e9019ac62f2/
Changeset: 0e9019ac62f2
Branch: yt
User: ngoldbaum
Date: 2015-09-09 16:21:17+00:00
Summary: Add sph_answer_test for testing answer testing SPH datasets
Affected #: 1 file
diff -r 3ecb2b5d913ac1532107c7675baf4a17ba083e32 -r 0e9019ac62f2489d17890e167555f4ece6bf4dca yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -817,6 +817,32 @@
ds_fn, axis, field, weight_field,
dobj_name)
+
+def sph_answer_test(ds_fn, ds_str_repr, ds_nparticles, fields, ds_kwargs=None):
+ if ds_kwargs is None:
+ ds_kwargs = {}
+ ds = data_dir_load(ds_fn, kwargs=ds_kwargs)
+ assert_equal(str(ds), ds_str_repr)
+ dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
+ dd = ds.all_data()
+ assert_equal(dd["particle_position"].shape, (ds_nparticles, 3))
+ tot = sum(dd[ptype, "particle_position"].shape[0]
+ for ptype in ds.particle_types if ptype != "all")
+ assert_equal(tot, ds_nparticles)
+ for dobj_name in dso:
+ for field in fields:
+ for axis in [0, 1, 2]:
+ for weight_field in [None, "density"]:
+ yield PixelizedProjectionValuesTest(
+ ds_fn, axis, field, weight_field,
+ dobj_name)
+ yield FieldValuesTest(ds_fn, field, dobj_name)
+ dobj = create_obj(ds, dobj_name)
+ s1 = dobj["ones"].sum()
+ s2 = sum(mask.sum() for block, mask in dobj.blocks)
+ assert_equal(s1, s2)
+
+
def create_obj(ds, obj_type):
# obj_type should be tuple of
# ( obj_name, ( args ) )
https://bitbucket.org/yt_analysis/yt/commits/a5caebed9439/
Changeset: a5caebed9439
Branch: yt
User: ngoldbaum
Date: 2015-09-09 16:21:33+00:00
Summary: Refactor OWLS and gadget SPH answer tests to use sph_answer_test
Affected #: 2 files
diff -r 0e9019ac62f2489d17890e167555f4ece6bf4dca -r a5caebed94396ad13764a462c96ae5018c7f3c9d yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -14,31 +14,29 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import requires_file, assert_equal
+from yt.testing import requires_file
from yt.utilities.answer_testing.framework import \
data_dir_load, \
requires_ds, \
- PixelizedProjectionValuesTest, \
- FieldValuesTest, \
- create_obj
+ sph_answer_test
from yt.frontends.gadget.api import GadgetHDF5Dataset, GadgetDataset
isothermal_h5 = "IsothermalCollapse/snap_505.hdf5"
isothermal_bin = "IsothermalCollapse/snap_505"
gdg = "GadgetDiskGalaxy/snapshot_0200.hdf5"
-_fields = (
- ("gas", "density")
+iso_fields = (
+ ("gas", "density"),
("gas", "temperature"),
('gas', 'velocity_magnitude'),
("deposit", "all_density"),
("deposit", "all_count"),
- ("deposit", "all_cic")
+ ("deposit", "all_cic"),
("deposit", "PartType0_density"),
- ("deposit", "PartType4_density")
)
+iso_kwargs = dict(bounding_box=[[-3, 3], [-3, 3], [-3, 3]])
-iso_kwargs = dict(bounding_box=[[-3, 3], [-3, 3], [-3, 3]])
+gdg_fields = iso_fields + (("deposit", "PartType4_density"), )
gdg_kwargs = dict(bounding_box=[[-1e5, 1e5], [-1e5, 1e5], [-1e5, 1e5]])
@@ -53,50 +51,11 @@
@requires_ds(isothermal_h5)
def test_iso_collapse():
- ds = data_dir_load(isothermal_h5, kwargs=iso_kwargs)
- yield assert_equal, str(ds), "snap_505"
- dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
- dd = ds.all_data()
- yield assert_equal, dd["particle_position"].shape, (2**17, 3)
- tot = sum(dd[ptype, "particle_position"].shape[0]
- for ptype in ds.particle_types if ptype != "all")
- yield assert_equal, tot, (2**17)
- for dobj_name in dso:
- for field in _fields:
- if 'PartType4' in field[1]:
- continue
- for axis in [0, 1, 2]:
- for weight_field in [None, "density"]:
- yield PixelizedProjectionValuesTest(
- isothermal_h5, axis, field, weight_field,
- dobj_name)
- yield FieldValuesTest(isothermal_h5, field, dobj_name)
- dobj = create_obj(ds, dobj_name)
- s1 = dobj["ones"].sum()
- s2 = sum(mask.sum() for block, mask in dobj.blocks)
- yield assert_equal, s1, s2
+ yield sph_answer_test(isothermal_h5, 'snap_505', 2**17,
+ iso_fields, ds_kwargs=iso_kwargs)
@requires_ds(gdg, big_data=True)
def test_snapshot_200():
- ds = data_dir_load(gdg)
- yield assert_equal, str(ds), "snapshot_200"
- dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
- dd = ds.all_data()
- yield assert_equal, dd["particle_position"].shape[0], 11907080
- yield assert_equal, dd["particle_position"].shape[1], 3
- tot = sum(dd[ptype, "particle_position"].shape[0]
- for ptype in ds.particle_types if ptype != "all")
- yield assert_equal, tot, 11907080
- for dobj_name in dso:
- for field in _fields:
- for axis in [0, 1, 2]:
- for weight_field in [None, "density"]:
- yield PixelizedProjectionValuesTest(
- gdg, axis, field, weight_field,
- dobj_name)
- yield FieldValuesTest(gdg, field, dobj_name)
- dobj = create_obj(ds, dobj_name)
- s1 = dobj["ones"].sum()
- s2 = sum(mask.sum() for block, mask in dobj.blocks)
- yield assert_equal, s1, s2
+ yield sph_answer_test(gdg, 'snap_505', 11907080, gdg_fields,
+ ds_kwargs=gdg_kwargs)
diff -r 0e9019ac62f2489d17890e167555f4ece6bf4dca -r a5caebed94396ad13764a462c96ae5018c7f3c9d yt/frontends/owls/tests/test_outputs.py
--- a/yt/frontends/owls/tests/test_outputs.py
+++ b/yt/frontends/owls/tests/test_outputs.py
@@ -15,14 +15,11 @@
#-----------------------------------------------------------------------------
from yt.testing import \
- assert_equal, \
requires_file
from yt.utilities.answer_testing.framework import \
requires_ds, \
data_dir_load, \
- PixelizedProjectionValuesTest, \
- FieldValuesTest, \
- create_obj
+ sph_answer_test
from yt.frontends.owls.api import OWLSDataset
os33 = "snapshot_033/snap_033.0.hdf5"
@@ -42,27 +39,7 @@
@requires_ds(os33, big_data=True)
def test_snapshot_033():
- ds = data_dir_load(os33)
- yield assert_equal, str(ds), "snap_033"
- dso = [ None, ("sphere", ("c", (0.1, 'unitary')))]
- dd = ds.all_data()
- yield assert_equal, dd["particle_position"].shape[0], 2*(128*128*128)
- yield assert_equal, dd["particle_position"].shape[1], 3
- tot = sum(dd[ptype,"particle_position"].shape[0]
- for ptype in ds.particle_types if ptype != "all")
- yield assert_equal, tot, (2*128*128*128)
- for dobj_name in dso:
- for field in _fields:
- for axis in [0, 1, 2]:
- for weight_field in [None, "density"]:
- yield PixelizedProjectionValuesTest(
- os33, axis, field, weight_field,
- dobj_name)
- yield FieldValuesTest(os33, field, dobj_name)
- dobj = create_obj(ds, dobj_name)
- s1 = dobj["ones"].sum()
- s2 = sum(mask.sum() for block, mask in dobj.blocks)
- yield assert_equal, s1, s2
+ yield sph_answer_test(os33, 'snap_033', 2*128**3, _fields)
@requires_file(os33)
https://bitbucket.org/yt_analysis/yt/commits/0c8b8971a569/
Changeset: 0c8b8971a569
Branch: yt
User: ngoldbaum
Date: 2015-09-09 16:21:40+00:00
Summary: Add tipsy answer tests
Affected #: 1 file
diff -r a5caebed94396ad13764a462c96ae5018c7f3c9d -r 0c8b8971a569964ff01db119293b9541e638e8cf yt/frontends/tipsy/tests/test_outputs.py
--- a/yt/frontends/tipsy/tests/test_outputs.py
+++ b/yt/frontends/tipsy/tests/test_outputs.py
@@ -14,15 +14,14 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import assert_equal, requires_file
from yt.utilities.answer_testing.framework import \
requires_ds, \
- small_patch_amr, \
- big_patch_amr, \
data_dir_load, \
- PixelizedProjectionValuesTest, \
+ sph_answer_test, \
+ create_obj, \
FieldValuesTest, \
- create_obj
+ PixelizedProjectionValuesTest
from yt.frontends.tipsy.api import TipsyDataset
_fields = (("deposit", "all_density"),
@@ -62,9 +61,9 @@
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
-gasoline = "agora_1e11.00400/agora_1e11.00400"
- at requires_ds(gasoline, big_data = True, file_check = True)
-def test_gasoline():
+gasoline_dmonly = "agora_1e11.00400/agora_1e11.00400"
+ at requires_ds(gasoline_dmonly, big_data = True, file_check = True)
+def test_gasoline_dmonly():
cosmology_parameters = dict(current_redshift = 0.0,
omega_lambda = 0.728,
omega_matter = 0.272,
@@ -72,7 +71,7 @@
kwargs = dict(cosmology_parameters = cosmology_parameters,
unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
- ds = data_dir_load(gasoline, TipsyDataset, (), kwargs)
+ ds = data_dir_load(gasoline_dmonly, TipsyDataset, (), kwargs)
yield assert_equal, str(ds), "agora_1e11.00400"
dso = [ None, ("sphere", ("c", (0.3, 'unitary')))]
dd = ds.all_data()
@@ -93,7 +92,21 @@
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
+tg_fields = (
+ ('gas', 'density'),
+ ('gas', 'temperature'),
+ ('gas', 'velocity_magnitude'),
+ ('gas', 'Fe_fraction'),
+ ('Stars', 'Metals'),
+)
+tipsy_gal = 'TipsyGalaxy/galaxy.00300'
+ at requires_ds(tipsy_gal)
+def test_tipsy_galaxy():
+ yield sph_answer_test(tipsy_gal, 'galaxy.00300', 315372, tg_fields)
+
+ at requires_file(gasoline_dmonly)
@requires_file(pkdgrav)
def test_TipsyDataset():
assert isinstance(data_dir_load(pkdgrav), TipsyDataset)
+ assert isinstance(data_dir_load(gasoline_dmonly), TipsyDataset)
https://bitbucket.org/yt_analysis/yt/commits/20c2028ee83b/
Changeset: 20c2028ee83b
Branch: yt
User: ngoldbaum
Date: 2015-09-09 19:17:24+00:00
Summary: Fixing a number of issues found while testing out the new tests
Affected #: 4 files
diff -r 0c8b8971a569964ff01db119293b9541e638e8cf -r 20c2028ee83b32f98025c9c28a979b5262f68591 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -18,7 +18,7 @@
from yt.utilities.answer_testing.framework import \
data_dir_load, \
requires_ds, \
- sph_answer_test
+ sph_answer
from yt.frontends.gadget.api import GadgetHDF5Dataset, GadgetDataset
isothermal_h5 = "IsothermalCollapse/snap_505.hdf5"
@@ -51,11 +51,12 @@
@requires_ds(isothermal_h5)
def test_iso_collapse():
- yield sph_answer_test(isothermal_h5, 'snap_505', 2**17,
- iso_fields, ds_kwargs=iso_kwargs)
-
+ for test in sph_answer(isothermal_h5, 'snap_505', 2**17,
+ iso_fields, ds_kwargs=iso_kwargs):
+ yield test
@requires_ds(gdg, big_data=True)
-def test_snapshot_200():
- yield sph_answer_test(gdg, 'snap_505', 11907080, gdg_fields,
- ds_kwargs=gdg_kwargs)
+def test_gadget_disk_galaxy():
+ for test in sph_answer(gdg, 'snap_505', 11907080, gdg_fields,
+ ds_kwargs=gdg_kwargs):
+ yield test
diff -r 0c8b8971a569964ff01db119293b9541e638e8cf -r 20c2028ee83b32f98025c9c28a979b5262f68591 yt/frontends/owls/tests/test_outputs.py
--- a/yt/frontends/owls/tests/test_outputs.py
+++ b/yt/frontends/owls/tests/test_outputs.py
@@ -19,27 +19,28 @@
from yt.utilities.answer_testing.framework import \
requires_ds, \
data_dir_load, \
- sph_answer_test
+ sph_answer
from yt.frontends.owls.api import OWLSDataset
os33 = "snapshot_033/snap_033.0.hdf5"
_fields = (
- ("gas", "density")
+ ("gas", "density"),
("gas", "temperature"),
('gas', 'He_p0_number_density'),
('gas', 'N_p1_number_density'),
('gas', 'velocity_magnitude'),
("deposit", "all_density"),
("deposit", "all_count"),
- ("deposit", "all_cic")
+ ("deposit", "all_cic"),
("deposit", "PartType0_density"),
("deposit", "PartType4_density"))
@requires_ds(os33, big_data=True)
def test_snapshot_033():
- yield sph_answer_test(os33, 'snap_033', 2*128**3, _fields)
+ for test in sph_answer(os33, 'snap_033', 2*128**3, _fields):
+ yield test
@requires_file(os33)
diff -r 0c8b8971a569964ff01db119293b9541e638e8cf -r 20c2028ee83b32f98025c9c28a979b5262f68591 yt/frontends/tipsy/tests/test_outputs.py
--- a/yt/frontends/tipsy/tests/test_outputs.py
+++ b/yt/frontends/tipsy/tests/test_outputs.py
@@ -18,7 +18,7 @@
from yt.utilities.answer_testing.framework import \
requires_ds, \
data_dir_load, \
- sph_answer_test, \
+ sph_answer, \
create_obj, \
FieldValuesTest, \
PixelizedProjectionValuesTest
@@ -103,7 +103,8 @@
tipsy_gal = 'TipsyGalaxy/galaxy.00300'
@requires_ds(tipsy_gal)
def test_tipsy_galaxy():
- yield sph_answer_test(tipsy_gal, 'galaxy.00300', 315372, tg_fields)
+ for test in sph_answer(tipsy_gal, 'galaxy.00300', 315372, tg_fields):
+ yield test
@requires_file(gasoline_dmonly)
@requires_file(pkdgrav)
diff -r 0c8b8971a569964ff01db119293b9541e638e8cf -r 20c2028ee83b32f98025c9c28a979b5262f68591 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -388,12 +388,13 @@
def run(self):
obj = create_obj(self.ds, self.obj_type)
+ field = obj._determine_fields(self.field)[0]
if self.particle_type:
- weight_field = "particle_ones"
+ weight_field = (field[0], "particle_ones")
else:
- weight_field = "ones"
+ weight_field = ("index", "ones")
avg = obj.quantities.weighted_average_quantity(
- self.field, weight=weight_field)
+ field, weight=weight_field)
mi, ma = obj.quantities.extrema(self.field)
return np.array([avg, mi, ma])
@@ -818,30 +819,38 @@
dobj_name)
-def sph_answer_test(ds_fn, ds_str_repr, ds_nparticles, fields, ds_kwargs=None):
+def sph_answer(ds_fn, ds_str_repr, ds_nparticles, fields, ds_kwargs=None):
+ if not can_run_ds(ds_fn):
+ return
if ds_kwargs is None:
ds_kwargs = {}
ds = data_dir_load(ds_fn, kwargs=ds_kwargs)
- assert_equal(str(ds), ds_str_repr)
+ yield assert_equal, str(ds), ds_str_repr
dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
dd = ds.all_data()
- assert_equal(dd["particle_position"].shape, (ds_nparticles, 3))
+ yield assert_equal, dd["particle_position"].shape, (ds_nparticles, 3)
tot = sum(dd[ptype, "particle_position"].shape[0]
for ptype in ds.particle_types if ptype != "all")
- assert_equal(tot, ds_nparticles)
+ yield assert_equal, tot, ds_nparticles
for dobj_name in dso:
- for field in fields:
- for axis in [0, 1, 2]:
- for weight_field in [None, "density"]:
- yield PixelizedProjectionValuesTest(
- ds_fn, axis, field, weight_field,
- dobj_name)
- yield FieldValuesTest(ds_fn, field, dobj_name)
dobj = create_obj(ds, dobj_name)
s1 = dobj["ones"].sum()
s2 = sum(mask.sum() for block, mask in dobj.blocks)
- assert_equal(s1, s2)
-
+ yield assert_equal, s1, s2
+ for field in fields:
+ if field[0] in ds.particle_types:
+ particle_type = True
+ else:
+ particle_type = False
+ for axis in [0, 1, 2]:
+ for weight_field in [None, ('gas', 'density')]:
+ if particle_type is False:
+ yield PixelizedProjectionValuesTest(
+ ds_fn, axis, field, weight_field,
+ dobj_name)
+ yield FieldValuesTest(ds_fn, field, dobj_name,
+ particle_type=particle_type)
+ return
def create_obj(ds, obj_type):
# obj_type should be tuple of
https://bitbucket.org/yt_analysis/yt/commits/f818f2971249/
Changeset: f818f2971249
Branch: yt
User: xarthisius
Date: 2015-09-15 20:21:43+00:00
Summary: Merged in ngoldbaum/yt (pull request #1741)
Adding answer tests for SPH frontends
Affected #: 4 files
diff -r 50b4d07251c61fabb1a47837041769cdb911bcb7 -r f818f29712491ce9f597decaea69297a06603393 yt/frontends/gadget/tests/test_outputs.py
--- a/yt/frontends/gadget/tests/test_outputs.py
+++ b/yt/frontends/gadget/tests/test_outputs.py
@@ -1,5 +1,5 @@
"""
-Gadget frontend tests using the IsothermalCollapse dataset
+Gadget frontend tests
@@ -14,15 +14,49 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import requires_file
from yt.utilities.answer_testing.framework import \
+ data_dir_load, \
requires_ds, \
- data_dir_load
-from yt.frontends.gadget.api import GadgetHDF5Dataset
+ sph_answer
+from yt.frontends.gadget.api import GadgetHDF5Dataset, GadgetDataset
-isothermal = "IsothermalCollapse/snap_505.hdf5"
- at requires_file(isothermal)
+isothermal_h5 = "IsothermalCollapse/snap_505.hdf5"
+isothermal_bin = "IsothermalCollapse/snap_505"
+gdg = "GadgetDiskGalaxy/snapshot_0200.hdf5"
+
+iso_fields = (
+ ("gas", "density"),
+ ("gas", "temperature"),
+ ('gas', 'velocity_magnitude'),
+ ("deposit", "all_density"),
+ ("deposit", "all_count"),
+ ("deposit", "all_cic"),
+ ("deposit", "PartType0_density"),
+)
+iso_kwargs = dict(bounding_box=[[-3, 3], [-3, 3], [-3, 3]])
+
+gdg_fields = iso_fields + (("deposit", "PartType4_density"), )
+gdg_kwargs = dict(bounding_box=[[-1e5, 1e5], [-1e5, 1e5], [-1e5, 1e5]])
+
+
+ at requires_file(isothermal_h5)
+ at requires_file(isothermal_bin)
def test_GadgetDataset():
- kwargs = dict(bounding_box=[[-3,3], [-3,3], [-3,3]])
- assert isinstance(data_dir_load(isothermal, kwargs=kwargs),
+ assert isinstance(data_dir_load(isothermal_h5, kwargs=iso_kwargs),
GadgetHDF5Dataset)
+ assert isinstance(data_dir_load(isothermal_bin, kwargs=iso_kwargs),
+ GadgetDataset)
+
+
+ at requires_ds(isothermal_h5)
+def test_iso_collapse():
+ for test in sph_answer(isothermal_h5, 'snap_505', 2**17,
+ iso_fields, ds_kwargs=iso_kwargs):
+ yield test
+
+ at requires_ds(gdg, big_data=True)
+def test_gadget_disk_galaxy():
+ for test in sph_answer(gdg, 'snap_505', 11907080, gdg_fields,
+ ds_kwargs=gdg_kwargs):
+ yield test
diff -r 50b4d07251c61fabb1a47837041769cdb911bcb7 -r f818f29712491ce9f597decaea69297a06603393 yt/frontends/owls/tests/test_outputs.py
--- a/yt/frontends/owls/tests/test_outputs.py
+++ b/yt/frontends/owls/tests/test_outputs.py
@@ -14,45 +14,33 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import \
+ requires_file
from yt.utilities.answer_testing.framework import \
requires_ds, \
- small_patch_amr, \
- big_patch_amr, \
data_dir_load, \
- PixelizedProjectionValuesTest, \
- FieldValuesTest, \
- create_obj
+ sph_answer
from yt.frontends.owls.api import OWLSDataset
-_fields = (("deposit", "all_density"), ("deposit", "all_count"),
- ("deposit", "PartType0_density"),
- ("deposit", "PartType4_density"))
+os33 = "snapshot_033/snap_033.0.hdf5"
-os33 = "snapshot_033/snap_033.0.hdf5"
+_fields = (
+ ("gas", "density"),
+ ("gas", "temperature"),
+ ('gas', 'He_p0_number_density'),
+ ('gas', 'N_p1_number_density'),
+ ('gas', 'velocity_magnitude'),
+ ("deposit", "all_density"),
+ ("deposit", "all_count"),
+ ("deposit", "all_cic"),
+ ("deposit", "PartType0_density"),
+ ("deposit", "PartType4_density"))
+
+
@requires_ds(os33, big_data=True)
def test_snapshot_033():
- ds = data_dir_load(os33)
- yield assert_equal, str(ds), "snap_033"
- dso = [ None, ("sphere", ("c", (0.1, 'unitary')))]
- dd = ds.all_data()
- yield assert_equal, dd["particle_position"].shape[0], 2*(128*128*128)
- yield assert_equal, dd["particle_position"].shape[1], 3
- tot = sum(dd[ptype,"particle_position"].shape[0]
- for ptype in ds.particle_types if ptype != "all")
- yield assert_equal, tot, (2*128*128*128)
- for dobj_name in dso:
- for field in _fields:
- for axis in [0, 1, 2]:
- for weight_field in [None, "density"]:
- yield PixelizedProjectionValuesTest(
- os33, axis, field, weight_field,
- dobj_name)
- yield FieldValuesTest(os33, field, dobj_name)
- dobj = create_obj(ds, dobj_name)
- s1 = dobj["ones"].sum()
- s2 = sum(mask.sum() for block, mask in dobj.blocks)
- yield assert_equal, s1, s2
+ for test in sph_answer(os33, 'snap_033', 2*128**3, _fields):
+ yield test
@requires_file(os33)
diff -r 50b4d07251c61fabb1a47837041769cdb911bcb7 -r f818f29712491ce9f597decaea69297a06603393 yt/frontends/tipsy/tests/test_outputs.py
--- a/yt/frontends/tipsy/tests/test_outputs.py
+++ b/yt/frontends/tipsy/tests/test_outputs.py
@@ -14,15 +14,14 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
-from yt.testing import *
+from yt.testing import assert_equal, requires_file
from yt.utilities.answer_testing.framework import \
requires_ds, \
- small_patch_amr, \
- big_patch_amr, \
data_dir_load, \
- PixelizedProjectionValuesTest, \
+ sph_answer, \
+ create_obj, \
FieldValuesTest, \
- create_obj
+ PixelizedProjectionValuesTest
from yt.frontends.tipsy.api import TipsyDataset
_fields = (("deposit", "all_density"),
@@ -62,9 +61,9 @@
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
-gasoline = "agora_1e11.00400/agora_1e11.00400"
- at requires_ds(gasoline, big_data = True, file_check = True)
-def test_gasoline():
+gasoline_dmonly = "agora_1e11.00400/agora_1e11.00400"
+ at requires_ds(gasoline_dmonly, big_data = True, file_check = True)
+def test_gasoline_dmonly():
cosmology_parameters = dict(current_redshift = 0.0,
omega_lambda = 0.728,
omega_matter = 0.272,
@@ -72,7 +71,7 @@
kwargs = dict(cosmology_parameters = cosmology_parameters,
unit_base = {'length': (1.0/60.0, "Mpccm/h")},
n_ref = 64)
- ds = data_dir_load(gasoline, TipsyDataset, (), kwargs)
+ ds = data_dir_load(gasoline_dmonly, TipsyDataset, (), kwargs)
yield assert_equal, str(ds), "agora_1e11.00400"
dso = [ None, ("sphere", ("c", (0.3, 'unitary')))]
dd = ds.all_data()
@@ -93,7 +92,22 @@
s2 = sum(mask.sum() for block, mask in dobj.blocks)
yield assert_equal, s1, s2
+tg_fields = (
+ ('gas', 'density'),
+ ('gas', 'temperature'),
+ ('gas', 'velocity_magnitude'),
+ ('gas', 'Fe_fraction'),
+ ('Stars', 'Metals'),
+)
+tipsy_gal = 'TipsyGalaxy/galaxy.00300'
+ at requires_ds(tipsy_gal)
+def test_tipsy_galaxy():
+ for test in sph_answer(tipsy_gal, 'galaxy.00300', 315372, tg_fields):
+ yield test
+
+ at requires_file(gasoline_dmonly)
@requires_file(pkdgrav)
def test_TipsyDataset():
assert isinstance(data_dir_load(pkdgrav), TipsyDataset)
+ assert isinstance(data_dir_load(gasoline_dmonly), TipsyDataset)
diff -r 50b4d07251c61fabb1a47837041769cdb911bcb7 -r f818f29712491ce9f597decaea69297a06603393 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -388,12 +388,13 @@
def run(self):
obj = create_obj(self.ds, self.obj_type)
+ field = obj._determine_fields(self.field)[0]
if self.particle_type:
- weight_field = "particle_ones"
+ weight_field = (field[0], "particle_ones")
else:
- weight_field = "ones"
+ weight_field = ("index", "ones")
avg = obj.quantities.weighted_average_quantity(
- self.field, weight=weight_field)
+ field, weight=weight_field)
mi, ma = obj.quantities.extrema(self.field)
return np.array([avg, mi, ma])
@@ -817,6 +818,40 @@
ds_fn, axis, field, weight_field,
dobj_name)
+
+def sph_answer(ds_fn, ds_str_repr, ds_nparticles, fields, ds_kwargs=None):
+ if not can_run_ds(ds_fn):
+ return
+ if ds_kwargs is None:
+ ds_kwargs = {}
+ ds = data_dir_load(ds_fn, kwargs=ds_kwargs)
+ yield assert_equal, str(ds), ds_str_repr
+ dso = [None, ("sphere", ("c", (0.1, 'unitary')))]
+ dd = ds.all_data()
+ yield assert_equal, dd["particle_position"].shape, (ds_nparticles, 3)
+ tot = sum(dd[ptype, "particle_position"].shape[0]
+ for ptype in ds.particle_types if ptype != "all")
+ yield assert_equal, tot, ds_nparticles
+ for dobj_name in dso:
+ dobj = create_obj(ds, dobj_name)
+ s1 = dobj["ones"].sum()
+ s2 = sum(mask.sum() for block, mask in dobj.blocks)
+ yield assert_equal, s1, s2
+ for field in fields:
+ if field[0] in ds.particle_types:
+ particle_type = True
+ else:
+ particle_type = False
+ for axis in [0, 1, 2]:
+ for weight_field in [None, ('gas', 'density')]:
+ if particle_type is False:
+ yield PixelizedProjectionValuesTest(
+ ds_fn, axis, field, weight_field,
+ dobj_name)
+ yield FieldValuesTest(ds_fn, field, dobj_name,
+ particle_type=particle_type)
+ return
+
def create_obj(ds, obj_type):
# obj_type should be tuple of
# ( obj_name, ( args ) )
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