From 35baf17c39d8bf282e681bfb7c8be1d364b63dce Mon Sep 17 00:00:00 2001 From: rickD Date: Fri, 10 Apr 2020 13:06:50 -0700 Subject: [PATCH] #110 add nearest_cell test --- tests/test_grid.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_grid.py b/tests/test_grid.py index d35d480..34d200c 100644 --- a/tests/test_grid.py +++ b/tests/test_grid.py @@ -51,6 +51,16 @@ def test_constructors(): def test_dtype(): assert(grid.dir.dtype == np.uint8) +def test_nearest_cell(): + ''' + corner: snaps to nearest top/left + center: snaps to index of cell that contains the geometry + ''' + col, row = grid.nearest_cell(x, y, snap='corner') + assert (col, row) == (229, 101) + col, row = grid.nearest_cell(x, y, snap='center') + assert (col, row) == (228, 100) + def test_catchment(): # Reference routing grid.catchment(x, y, data='dir', dirmap=dirmap, out_name='catch',