[yt-svn] commit/yt: xarthisius: Merged in MatthewTurk/yt (pull request #1147)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Sep 7 08:29:04 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/c8042b5d05d0/
Changeset:   c8042b5d05d0
Branch:      yt
User:        xarthisius
Date:        2014-09-07 17:28:55
Summary:     Merged in MatthewTurk/yt (pull request #1147)

Periodicity checks for objects
Affected #:  2 files

diff -r 0abeb6afd3bc2b563c023b4a72be222447d843af -r c8042b5d05d064f8e5c38f03dd58a680a52036f3 yt/data_objects/tests/test_spheres.py
--- a/yt/data_objects/tests/test_spheres.py
+++ b/yt/data_objects/tests/test_spheres.py
@@ -6,10 +6,11 @@
     from yt.config import ytcfg
     ytcfg["yt","__withintesting"] = "True"
 
+_fields_to_compare = ("spherical_r", "cylindrical_r",
+                      "spherical_theta", "cylindrical_theta",
+                      "spherical_phi", "cylindrical_z")
+
 def test_domain_sphere():
-    ds = fake_random_ds(16, fields = ("density"))
-    sp = ds.sphere(ds.domain_center, ds.domain_width[0])
-
     # Now we test that we can get different radial velocities based on field
     # parameters.
 
@@ -51,3 +52,12 @@
     yield assert_equal, np.any(rp0["radial_velocity"][rp0.used] ==
                                rp1["radial_velocity"][rp1.used]), \
                                False
+
+    ref_sp = ds.sphere("c", 0.25)
+    for f in _fields_to_compare:
+        ref_sp[f].sort()
+    for center in periodicity_cases(ds):
+        sp = ds.sphere(center, 0.25)
+        for f in _fields_to_compare:
+            sp[f].sort()
+            yield assert_equal, sp[f], ref_sp[f]

diff -r 0abeb6afd3bc2b563c023b4a72be222447d843af -r c8042b5d05d064f8e5c38f03dd58a680a52036f3 yt/testing.py
--- a/yt/testing.py
+++ b/yt/testing.py
@@ -624,6 +624,18 @@
         return _func
     return compare_results(func)
 
+def periodicity_cases(ds):
+    # This is a generator that yields things near the corners.  It's good for
+    # getting different places to check periodicity.
+    yield (ds.domain_left_edge + ds.domain_right_edge)/2.0
+    dx = ds.domain_width / ds.domain_dimensions
+    # We start one dx in, and only go to one in as well.
+    for i in (1, ds.domain_dimensions[0] - 2):
+        for j in (1, ds.domain_dimensions[1] - 2):
+            for k in (1, ds.domain_dimensions[2] - 2):
+                center = dx * np.array([i,j,k]) + ds.domain_left_edge
+                yield center
+
 def run_nose(verbose=False, run_answer_tests=False, answer_big_data=False):
     import nose, os, sys, yt
     from yt.funcs import mylog

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