[yt-svn] commit/yt: xarthisius: Merged in ngoldbaum/yt (pull request #1741)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 15 13:21:55 PDT 2015
1 new commit in yt:
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