We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 94c44b2 commit 5c47411Copy full SHA for 5c47411
1 file changed
tests/tree/test_tree.py
@@ -573,5 +573,22 @@ def test_insert_point(self):
573
self.assertEqual(mesh1.nC, mesh2.nC)
574
575
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
593
if __name__ == "__main__":
594
unittest.main()
0 commit comments