[yt-svn] commit/yt: ngoldbaum: Merged in MatthewTurk/yt (pull request #2322)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Aug 4 12:19:22 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/1a9c9ab1575b/
Changeset: 1a9c9ab1575b
Branch: yt
User: ngoldbaum
Date: 2016-08-04 19:18:50+00:00
Summary: Merged in MatthewTurk/yt (pull request #2322)
Adding AxialPixelization tests
Affected #: 9 files
diff -r 295f67a469c76df7a8d25360bcfa836312ab61ea -r 1a9c9ab1575b1d2fc4ce517acc44074cf333a4c7 tests/tests.yaml
--- a/tests/tests.yaml
+++ b/tests/tests.yaml
@@ -73,6 +73,9 @@
- yt/analysis_modules/absorption_spectrum/tests/test_absorption_spectrum.py:test_absorption_spectrum_non_cosmo_sph
- yt/analysis_modules/absorption_spectrum/tests/test_absorption_spectrum.py:test_absorption_spectrum_cosmo_sph
+ local_axialpix_001:
+ - yt/geometry/coordinates/tests/test_axial_pixelization.py:test_axial_pixelization
+
other_tests:
unittests:
- '-v'
diff -r 295f67a469c76df7a8d25360bcfa836312ab61ea -r 1a9c9ab1575b1d2fc4ce517acc44074cf333a4c7 yt/geometry/coordinates/cartesian_coordinates.py
--- a/yt/geometry/coordinates/cartesian_coordinates.py
+++ b/yt/geometry/coordinates/cartesian_coordinates.py
@@ -113,7 +113,7 @@
# re-order the array and squeeze out the dummy dim
return np.squeeze(np.transpose(img, (yax, xax, ax)))
- elif dimension < 3:
+ elif self.axis_id.get(dimension, dimension) < 3:
return self._ortho_pixelize(data_source, field, bounds, size,
antialias, dimension, periodic)
else:
diff -r 295f67a469c76df7a8d25360bcfa836312ab61ea -r 1a9c9ab1575b1d2fc4ce517acc44074cf333a4c7 yt/geometry/coordinates/tests/test_axial_pixelization.py
--- /dev/null
+++ b/yt/geometry/coordinates/tests/test_axial_pixelization.py
@@ -0,0 +1,9 @@
+from yt.testing import \
+ fake_amr_ds, _geom_transforms
+from yt.utilities.answer_testing.framework import \
+ AxialPixelizationTest
+
+def test_axial_pixelization():
+ for geom in sorted(_geom_transforms):
+ ds = fake_amr_ds(geometry=geom)
+ yield AxialPixelizationTest(ds)
diff -r 295f67a469c76df7a8d25360bcfa836312ab61ea -r 1a9c9ab1575b1d2fc4ce517acc44074cf333a4c7 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -324,6 +324,8 @@
self.ds = data_dir_load(ds_fn)
def __call__(self):
+ if AnswerTestingTest.result_storage is None:
+ return
nv = self.run()
if self.reference_storage.reference_name is not None:
dd = self.reference_storage.get(self.storage_name)
@@ -860,6 +862,47 @@
def compare(self, new_result, old_result):
compare_image_lists(new_result, old_result, self.decimals)
+class AxialPixelizationTest(AnswerTestingTest):
+ # This test is typically used once per geometry or coordinates type.
+ # Feed it a dataset, and it checks that the results of basic pixelization
+ # don't change.
+ _type_name = "AxialPixelization"
+ _attrs = ('geometry',)
+ def __init__(self, ds_fn, decimals=None):
+ super(AxialPixelizationTest, self).__init__(ds_fn)
+ self.decimals = decimals
+ self.geometry = self.ds.coordinates.name
+
+ def run(self):
+ rv = {}
+ ds = self.ds
+ for i, axis in enumerate(ds.coordinates.axis_order):
+ (bounds, center, display_center) = \
+ pw.get_window_parameters(axis, ds.domain_center, None, ds)
+ slc = ds.slice(axis, center[i])
+ xax = ds.coordinates.axis_name[ds.coordinates.x_axis[axis]]
+ yax = ds.coordinates.axis_name[ds.coordinates.y_axis[axis]]
+ pix_x = ds.coordinates.pixelize(axis, slc, xax, bounds, (512, 512))
+ pix_y = ds.coordinates.pixelize(axis, slc, yax, bounds, (512, 512))
+ # Wipe out all NaNs
+ pix_x[np.isnan(pix_x)] = 0.0
+ pix_y[np.isnan(pix_y)] = 0.0
+ rv['%s_x' % axis] = pix_x
+ rv['%s_y' % axis] = pix_y
+ return rv
+
+ def compare(self, new_result, old_result):
+ assert_equal(len(new_result), len(old_result),
+ err_msg="Number of outputs not equal.",
+ verbose=True)
+ for k in new_result:
+ if self.decimals is None:
+ assert_almost_equal(new_result[k], old_result[k])
+ else:
+ assert_allclose_units(new_result[k], old_result[k],
+ 10**(-self.decimals))
+
+
def requires_sim(sim_fn, sim_type, big_data = False, file_check = False):
def ffalse(func):
return lambda: None
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