[yt-svn] commit/yt: drudd: Re-added test_grid_points using private method of GridIndex

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jul 14 13:32:55 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/256e66b375dc/
Changeset:   256e66b375dc
Branch:      yt-3.0
User:        drudd
Date:        2014-07-14 20:39:38
Summary:     Re-added test_grid_points using private method of GridIndex
Affected #:  1 file

diff -r 561d2e56371ca0053ee093df7968f59ae978481a -r 256e66b375dcc6bb27036c1dfbf02c59e6f76285 yt/utilities/lib/tests/test_grid_tree.py
--- a/yt/utilities/lib/tests/test_grid_tree.py
+++ b/yt/utilities/lib/tests/test_grid_tree.py
@@ -67,3 +67,52 @@
             grid_children = np.array([child.id - child._id_offset
                                       for child in grid.Children])
             yield assert_equal, grid_children, children[i]
+
+def test_find_points():
+    """Main test suite for MatchPoints"""
+    num_points = 100
+    randx = np.random.uniform(low=test_pf.domain_left_edge[0],
+                              high=test_pf.domain_right_edge[0],
+                              size=num_points)
+    randy = np.random.uniform(low=test_pf.domain_left_edge[1],
+                              high=test_pf.domain_right_edge[1],
+                              size=num_points)
+    randz = np.random.uniform(low=test_pf.domain_left_edge[2],
+                              high=test_pf.domain_right_edge[2],
+                              size=num_points)
+
+    point_grids, point_grid_inds = test_pf.index._find_points(randx, randy, randz)
+
+    grid_inds = np.zeros((num_points), dtype='int64')
+
+    for ind, ixx, iyy, izz in zip(range(num_points), randx, randy, randz):
+
+        pos = np.array([ixx, iyy, izz])
+        pt_level = -1
+
+        for grid in test_pf.index.grids:
+
+            if np.all(pos >= grid.LeftEdge) and \
+               np.all(pos <= grid.RightEdge) and \
+               grid.Level > pt_level:
+                pt_level = grid.Level
+                grid_inds[ind] = grid.id - grid._id_offset
+
+    yield assert_equal, point_grid_inds, grid_inds
+
+    # Test wheter find_points works for lists
+    point_grids, point_grid_inds = test_pf.index._find_points(randx.tolist(),
+                                                         randy.tolist(),
+                                                         randz.tolist())
+    yield assert_equal, point_grid_inds, grid_inds
+
+    # Test if find_points works for scalar
+    ind = random.randint(0, num_points - 1)
+    point_grids, point_grid_inds = test_pf.index._find_points(randx[ind],
+                                                         randy[ind],
+                                                         randz[ind])
+    yield assert_equal, point_grid_inds, grid_inds[ind]
+
+    # Test if find_points fails properly for non equal indices' array sizes
+    yield assert_raises, AssertionError, test_pf.index._find_points, \
+        [0], 1.0, [2, 3]

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