Skip to content

Commit 5c47411

Browse files
committed
add tests
1 parent 94c44b2 commit 5c47411

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/tree/test_tree.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,5 +573,22 @@ def test_insert_point(self):
573573
self.assertEqual(mesh1.nC, mesh2.nC)
574574

575575

576+
@pytest.mark.parametrize("dim", [2, 3])
577+
def test_cell_locator(dim):
578+
mesh = discretize.TreeMesh((16, 16, 16)[:dim])
579+
mesh.insert_cells([0.5, 0.5, 0.5][:dim], levels=-1)
580+
581+
query_point = [0.21, 0.42, 0.22][:dim]
582+
identified_cell = mesh.point2index(query_point)
583+
found = False
584+
for i, cell in enumerate(mesh):
585+
bounds = cell.bounds.reshape((-1, 2))
586+
587+
if np.all((bounds[:, 0] <= query_point) & (bounds[:, 1] >= query_point)):
588+
found = True
589+
assert i == identified_cell
590+
assert found
591+
592+
576593
if __name__ == "__main__":
577594
unittest.main()

0 commit comments

Comments
 (0)