[yt-svn] commit/yt: MatthewTurk: Adding more tests to the ray and ortho ray tests and moving to yield instead of

Bitbucket commits-noreply at bitbucket.org
Tue Oct 23 17:42:31 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/221b5163bffa/
changeset:   221b5163bffa
branch:      yt
user:        MatthewTurk
date:        2012-10-24 02:42:02
summary:     Adding more tests to the ray and ortho ray tests and moving to yield instead of
return
affected #:  2 files

diff -r 329544ece9b19b441f2491e7dad059c848e9e318 -r 221b5163bffa2e478a2b65d80090adf1be45bb2e yt/data_objects/tests/test_ortho_rays.py
--- a/yt/data_objects/tests/test_ortho_rays.py
+++ b/yt/data_objects/tests/test_ortho_rays.py
@@ -21,5 +21,5 @@
                    (np.abs(my_all[axes[my_axes[1]]] - ocoord[1]) <= 
                     0.5 * dx[my_axes[1]])
 
-        assert_equal(my_oray['Density'].sum(),
-                     my_all['Density'][my_cells].sum())
+        yield assert_equal, my_oray['Density'].sum(), \
+                            my_all['Density'][my_cells].sum()


diff -r 329544ece9b19b441f2491e7dad059c848e9e318 -r 221b5163bffa2e478a2b65d80090adf1be45bb2e yt/data_objects/tests/test_rays.py
--- a/yt/data_objects/tests/test_rays.py
+++ b/yt/data_objects/tests/test_rays.py
@@ -1,31 +1,33 @@
 from yt.testing import *
 
 def test_ray():
-    pf = fake_random_pf(64, nprocs=8)
-    dx = (pf.domain_right_edge - pf.domain_left_edge) / \
-      pf.domain_dimensions
+    for nproc in [1, 2, 4, 8]:
+        pf = fake_random_pf(64, nprocs=nproc)
+        dx = (pf.domain_right_edge - pf.domain_left_edge) / \
+          pf.domain_dimensions
 
-    p1 = np.random.random(3)
-    p2 = np.random.random(3)
+        p1 = np.random.random(3)
+        p2 = np.random.random(3)
 
-    my_ray = pf.h.ray(p1, p2)
-    assert_rel_equal(my_ray['dts'].sum(), 1.0, 14)
-    ray_cells = my_ray['dts'] > 0
+        my_ray = pf.h.ray(p1, p2)
+        assert_rel_equal(my_ray['dts'].sum(), 1.0, 14)
+        ray_cells = my_ray['dts'] > 0
 
-    # find cells intersected by the ray
-    my_all = pf.h.all_data()
-    
-    dt = np.abs(dx / (p2 - p1))
-    tin  = np.concatenate([[(my_all['x'] - p1[0]) / (p2 - p1)[0] - 0.5 * dt[0]],
-                           [(my_all['y'] - p1[1]) / (p2 - p1)[1] - 0.5 * dt[1]],
-                           [(my_all['z'] - p1[2]) / (p2 - p1)[2] - 0.5 * dt[2]]])
-    tout = np.concatenate([[(my_all['x'] - p1[0]) / (p2 - p1)[0] + 0.5 * dt[0]],
-                           [(my_all['y'] - p1[1]) / (p2 - p1)[1] + 0.5 * dt[1]],
-                           [(my_all['z'] - p1[2]) / (p2 - p1)[2] + 0.5 * dt[2]]])
-    tin = tin.max(axis=0)
-    tout = tout.min(axis=0)
-    my_cells = (tin < tout) & (tin < 1) & (tout > 0)
+        # find cells intersected by the ray
+        my_all = pf.h.all_data()
+        
+        dt = np.abs(dx / (p2 - p1))
+        tin  = np.concatenate([[(my_all['x'] - p1[0]) / (p2 - p1)[0] - 0.5 * dt[0]],
+                               [(my_all['y'] - p1[1]) / (p2 - p1)[1] - 0.5 * dt[1]],
+                               [(my_all['z'] - p1[2]) / (p2 - p1)[2] - 0.5 * dt[2]]])
+        tout = np.concatenate([[(my_all['x'] - p1[0]) / (p2 - p1)[0] + 0.5 * dt[0]],
+                               [(my_all['y'] - p1[1]) / (p2 - p1)[1] + 0.5 * dt[1]],
+                               [(my_all['z'] - p1[2]) / (p2 - p1)[2] + 0.5 * dt[2]]])
+        tin = tin.max(axis=0)
+        tout = tout.min(axis=0)
+        my_cells = (tin < tout) & (tin < 1) & (tout > 0)
 
-    assert_rel_equal(ray_cells.sum(), my_cells.sum(), 14)
-    assert_rel_equal(my_ray['Density'][ray_cells].sum(),
-                     my_all['Density'][my_cells].sum(), 14)
+        yield assert_rel_equal, ray_cells.sum(), my_cells.sum(), 14
+        yield assert_rel_equal, my_ray['Density'][ray_cells].sum(), \
+                                my_all['Density'][my_cells].sum(), 14
+        yield assert_rel_equal, my_ray['dts'].sum(), 1.0, 14

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