Commits

Matthew Turk  committed 221b516

Adding more tests to the ray and ortho ray tests and moving to yield instead of
return

  • Participants
  • Parent commits 329544e
  • Branches yt

Comments (0)

Files changed (2)

File yt/data_objects/tests/test_ortho_rays.py

                    (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()

File yt/data_objects/tests/test_rays.py

 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