[yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Thu Oct 18 08:41:18 PDT 2012
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/12b9b286e3e1/
changeset: 12b9b286e3e1
branch: yt
user: brittonsmith
date: 2012-10-18 15:53:30
summary: Adding tests for rays and ortho rays.
affected #: 2 files
diff -r 75eab6836b445eb7fe75017d761b06ae63172310 -r 12b9b286e3e1eb752f70759a5b939dc36b0bb327 yt/data_objects/tests/test_ortho_rays.py
--- /dev/null
+++ b/yt/data_objects/tests/test_ortho_rays.py
@@ -0,0 +1,25 @@
+from yt.testing import *
+
+def test_ortho_ray():
+ pf = fake_random_pf(64, nprocs=8)
+ dx = (pf.domain_right_edge - pf.domain_left_edge) / \
+ pf.domain_dimensions
+
+ axes = ['x', 'y', 'z']
+ for ax, an in enumerate(axes):
+ ocoord = np.random.random(2)
+
+ my_oray = pf.h.ortho_ray(ax, ocoord)
+
+ my_axes = range(3)
+ del my_axes[ax]
+
+ # find the cells intersected by the ortho ray
+ my_all = pf.h.all_data()
+ my_cells = (np.abs(my_all[axes[my_axes[0]]] - ocoord[0]) <=
+ 0.5 * dx[my_axes[0]]) & \
+ (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())
diff -r 75eab6836b445eb7fe75017d761b06ae63172310 -r 12b9b286e3e1eb752f70759a5b939dc36b0bb327 yt/data_objects/tests/test_rays.py
--- /dev/null
+++ b/yt/data_objects/tests/test_rays.py
@@ -0,0 +1,31 @@
+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
+
+ p1 = np.random.random(3)
+ p2 = np.random.random(3)
+
+ my_ray = pf.h.ray(p1, p2)
+ assert_equal(my_ray['dts'].sum(), 1.0)
+ 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)
+
+ assert_equal(ray_cells.sum(), my_cells.sum())
+ assert_equal(my_ray['Density'][ray_cells].sum(),
+ my_all['Density'][my_cells].sum())
https://bitbucket.org/yt_analysis/yt/changeset/06462f53a16b/
changeset: 06462f53a16b
branch: yt
user: MatthewTurk
date: 2012-10-18 17:41:17
summary: Merged in brittonsmith/yt (pull request #305)
affected #: 2 files
diff -r 883eb7631b460d62733b6ffe9996a17dbf5c03cd -r 06462f53a16bbbb175a88920ed0c219aacbdc4d9 yt/data_objects/tests/test_ortho_rays.py
--- /dev/null
+++ b/yt/data_objects/tests/test_ortho_rays.py
@@ -0,0 +1,25 @@
+from yt.testing import *
+
+def test_ortho_ray():
+ pf = fake_random_pf(64, nprocs=8)
+ dx = (pf.domain_right_edge - pf.domain_left_edge) / \
+ pf.domain_dimensions
+
+ axes = ['x', 'y', 'z']
+ for ax, an in enumerate(axes):
+ ocoord = np.random.random(2)
+
+ my_oray = pf.h.ortho_ray(ax, ocoord)
+
+ my_axes = range(3)
+ del my_axes[ax]
+
+ # find the cells intersected by the ortho ray
+ my_all = pf.h.all_data()
+ my_cells = (np.abs(my_all[axes[my_axes[0]]] - ocoord[0]) <=
+ 0.5 * dx[my_axes[0]]) & \
+ (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())
diff -r 883eb7631b460d62733b6ffe9996a17dbf5c03cd -r 06462f53a16bbbb175a88920ed0c219aacbdc4d9 yt/data_objects/tests/test_rays.py
--- /dev/null
+++ b/yt/data_objects/tests/test_rays.py
@@ -0,0 +1,31 @@
+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
+
+ p1 = np.random.random(3)
+ p2 = np.random.random(3)
+
+ my_ray = pf.h.ray(p1, p2)
+ assert_equal(my_ray['dts'].sum(), 1.0)
+ 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)
+
+ assert_equal(ray_cells.sum(), my_cells.sum())
+ assert_equal(my_ray['Density'][ray_cells].sum(),
+ my_all['Density'][my_cells].sum())
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