Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1188 Update the numba_celltree package #1189

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion imod/select/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def points_in_bounds(da, **points):
da_x = da.coords[key]
_, xmin, xmax = imod.util.spatial.coord_reference(da_x)
# Inplace bitwise operator
in_bounds &= (x >= xmin) & (x < xmax)
in_bounds &= (x >= xmin) & (x <= xmax)

return in_bounds

Expand Down
31 changes: 19 additions & 12 deletions imod/tests/test_select/test_select_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def test_in_bounds(test_da_nonequidistant, test_uda):
actual = imod.select.points_in_bounds(case, x=x, y=y)
assert (expected == actual).all()

# Upper exclusive
# Upper inclusive
x = 4.0
y = 3.0
expected = np.array([False])
expected = np.array([True])
actual = imod.select.points_in_bounds(case, x=x, y=y)
assert (expected == actual).all()

Expand All @@ -107,11 +107,12 @@ def test_get_indices__nonequidistant(test_da_nonequidistant):
actual = imod.select.points_indices(test_da_nonequidistant, x=x, y=y)
assert expected == xy_indices(actual)

# Upper exclusive
# Upper inclusive
x = 4.0
y = 2.5
with pytest.raises(ValueError):
actual = imod.select.points_indices(test_da_nonequidistant, x=x, y=y)
expected = (np.array([0]), np.array([4]))
actual = imod.select.points_indices(test_da_nonequidistant, x=x, y=y)
assert expected == xy_indices(actual)

# Arrays
x = [3.0, 0.0]
Expand All @@ -123,11 +124,15 @@ def test_get_indices__nonequidistant(test_da_nonequidistant):
assert (rr_e == rr_a).all()
assert (cc_e == cc_a).all()

# Arrays; upper exclusive
# Arrays; upper inclusive
x = [4.0, 0.0]
y = [2.5, 0.0]
with pytest.raises(ValueError):
rr_e, cc_e = (np.array([0, 2]), np.array([4, 0]))
rr_a, cc_a = xy_indices(
imod.select.points_indices(test_da_nonequidistant, x=x, y=y)
)
assert (rr_e == rr_a).all()
assert (cc_e == cc_a).all()


def test_get_indices__equidistant(test_da):
Expand All @@ -141,22 +146,24 @@ def test_get_indices__equidistant(test_da):
def test_get_indices__unstructured(test_uda):
x = 3.0
y = 2.5
expected = np.array([3])
expected = np.array([2])
indices = imod.select.points_indices(test_uda, x=x, y=y)
actual = indices["mesh2d_nFaces"].values
assert expected == actual

# Upper exclusive
# Upper inclusive
x = 4.0
y = 2.5
with pytest.raises(ValueError):
actual = imod.select.points_indices(test_uda, x=x, y=y)
expected = np.array([3])
indices = imod.select.points_indices(test_uda, x=x, y=y)
actual = indices["mesh2d_nFaces"].values
assert expected == actual


def test_get_values__unstructured(test_uda):
x = 3.0
y = 2.5
expected = np.array([3])
expected = np.array([2])
indices = imod.select.points_values(test_uda, x=x, y=y)
actual = indices["mesh2d_nFaces"].values
assert expected == actual
Expand Down
Loading