Skip to content

Commit

Permalink
Improved test coverage for regridding.find_indices().
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie committed Dec 4, 2023
1 parent 2302e89 commit 78d1c30
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions regridding/_find_indices/_tests/test_find_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
(np.linspace(-1, 1, num=32),),
(np.linspace(-1, 1, num=64),),
),
(
(np.linspace(-1, 1, num=32),),
(np.linspace(-2, 2, num=64),),
),
],
)
@pytest.mark.parametrize(
Expand All @@ -36,5 +40,12 @@ def test_find_indices_1d(
(coordinates_output_x,) = coordinates_output
(result_x,) = result

assert np.all(coordinates_input_x[result_x + 0] <= coordinates_output_x)
assert np.all(coordinates_input_x[result_x + 1] >= coordinates_output_x)
where = coordinates_output_x <= coordinates_input_x.max()
where &= coordinates_output_x > coordinates_input_x.min()

assert np.all(
coordinates_input_x[result_x[where] + 0] <= coordinates_output_x[where]
)
assert np.all(
coordinates_input_x[result_x[where] + 1] >= coordinates_output_x[where]
)

0 comments on commit 78d1c30

Please sign in to comment.