Skip to content

Commit

Permalink
Add more first, last tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Aug 2, 2024
1 parent 8f7d093 commit 756c724
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,33 @@ def test_dask_reduce_axis_subset():
)


@pytest.mark.parametrize(
"func",
[
# "first", "last",
"nanfirst",
"nanlast",
],
)
@pytest.mark.parametrize(
"chunks",
[
None,
pytest.param(1, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
pytest.param(2, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
pytest.param(3, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
],
)
def test_first_last_useless(func, chunks):
array = np.array([[0, 0, 0], [0, 0, 0]], dtype=np.int8)
group_idx = np.array([1, 0, 0])
if chunks is not None:
array = dask.array.from_array(array, chunks=chunks)
actual, _ = groupby_reduce(array, group_idx, func=func, engine="numpy")
expected = np.array([[0, 0], [0, 0]], dtype=np.int8)
assert_equal(actual, expected)


@pytest.mark.parametrize("func", ["first", "last", "nanfirst", "nanlast"])
@pytest.mark.parametrize("axis", [(0, 1)])
def test_first_last_disallowed(axis, func):
Expand Down

0 comments on commit 756c724

Please sign in to comment.