Skip to content

Commit bcae992

Browse files
committed
Add more first, last tests
1 parent 8f7d093 commit bcae992

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_core.py

+27
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,33 @@ def test_dask_reduce_axis_subset():
613613
)
614614

615615

616+
@pytest.mark.parametrize("group_idx", [[0, 1, 0], [0, 0, 1], [1, 0, 0], [1, 1, 0]])
617+
@pytest.mark.parametrize(
618+
"func",
619+
[
620+
# "first", "last",
621+
"nanfirst",
622+
"nanlast",
623+
],
624+
)
625+
@pytest.mark.parametrize(
626+
"chunks",
627+
[
628+
None,
629+
pytest.param(1, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
630+
pytest.param(2, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
631+
pytest.param(3, marks=pytest.mark.skipif(not has_dask, reason="no dask")),
632+
],
633+
)
634+
def test_first_last_useless(func, chunks, group_idx):
635+
array = np.array([[0, 0, 0], [0, 0, 0]], dtype=np.int8)
636+
if chunks is not None:
637+
array = dask.array.from_array(array, chunks=chunks)
638+
actual, _ = groupby_reduce(array, np.array(group_idx), func=func, engine="numpy")
639+
expected = np.array([[0, 0], [0, 0]], dtype=np.int8)
640+
assert_equal(actual, expected)
641+
642+
616643
@pytest.mark.parametrize("func", ["first", "last", "nanfirst", "nanlast"])
617644
@pytest.mark.parametrize("axis", [(0, 1)])
618645
def test_first_last_disallowed(axis, func):

0 commit comments

Comments
 (0)