Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie committed Aug 23, 2024
1 parent 8a0d8b7 commit f1fdadf
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions ndfilters/_tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,37 @@ def _mean(a: np.ndarray, args: tuple = ()) -> float:
argnames="mode",
argvalues=[
"mirror",
"nearest",
"wrap",
"truncate",
pytest.param("foo", marks=pytest.mark.xfail),
],
)
def test_generic_filter(
array: np.ndarray | u.Quantity,
function: Callable[[np.ndarray], float],
size: int | tuple[int, ...],
mode: Literal["mirror"],
mode: Literal["mirror", "nearest", "wrap", "truncate"],
):
result = ndfilters.generic_filter(
array=array,
function=function,
size=size,
mode=mode,
)
assert result.shape == array.shape
assert result.sum() != 0

result_expected = scipy.ndimage.generic_filter(
input=array,
function=function,
size=size,
mode=mode,
)
if mode != "truncate":
result_expected = scipy.ndimage.generic_filter(
input=array,
function=function,
size=size,
mode=mode,
)

assert result.shape == array.shape
if isinstance(array, u.Quantity):
assert np.all(result.value == result_expected)
assert result.unit == array.unit
else:
assert np.all(result == result_expected)
if isinstance(array, u.Quantity):
assert np.all(result.value == result_expected)
assert result.unit == array.unit
else:
assert np.all(result == result_expected)

0 comments on commit f1fdadf

Please sign in to comment.