From 756c72438a6b9546cf2cf6b3ea023628ec81e8ff Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 2 Aug 2024 15:53:04 -0600 Subject: [PATCH] Add more first, last tests --- tests/test_core.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index e12e695d..e9c5ebec 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -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):