Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Nov 28, 2023
1 parent 7ad63fe commit b5056ba
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,15 @@ def test_groupby_reduce(
elif func == "count":
expected_result = np.array(expected, dtype=np.intp)

(result, groups) = groupby_reduce(
(result, *groups) = groupby_reduce(
array,
by,
func=func,
expected_groups=expected_groups,
fill_value=123,
engine=engine,
)
(groups_array,) = groups
# we use pd.Index(expected_groups).to_numpy() which is always int64
# for the values in this test
if expected_groups is None:
Expand All @@ -196,7 +197,7 @@ def test_groupby_reduce(
else:
g_dtype = np.int64

assert_equal(groups, np.array([0, 1, 2], g_dtype))
assert_equal(groups_array, np.array([0, 1, 2], g_dtype))
assert_equal(expected_result, result)


Expand Down Expand Up @@ -795,11 +796,14 @@ def test_groupby_bins(chunk_labels, kwargs, chunks, engine, method) -> None:
labels = dask.array.from_array(labels, chunks=chunks)

with raise_if_dask_computes():
actual, groups = groupby_reduce(
actual, *groups = groupby_reduce(
array, labels, func="count", fill_value=0, engine=engine, method=method, **kwargs
)
(groups_array,) = groups
expected = np.array([3, 1, 0], dtype=np.intp)
for left, right in zip(groups, pd.IntervalIndex.from_arrays([1, 2, 4], [2, 4, 5]).to_numpy()):
for left, right in zip(
groups_array, pd.IntervalIndex.from_arrays([1, 2, 4], [2, 4, 5]).to_numpy()
):
assert left == right
assert_equal(actual, expected)

Expand Down Expand Up @@ -1034,13 +1038,13 @@ def test_bool_reductions(func, engine):
def test_map_reduce_blockwise_mixed() -> None:
t = pd.date_range("2000-01-01", "2000-12-31", freq="D").to_series()
data = t.dt.dayofyear
actual, _ = groupby_reduce(
actual, *_ = groupby_reduce(
dask.array.from_array(data.values, chunks=365),
t.dt.month,
func="mean",
method="map-reduce",
)
expected, _ = groupby_reduce(data, t.dt.month, func="mean")
expected, *_ = groupby_reduce(data, t.dt.month, func="mean")
assert_equal(expected, actual)


Expand Down

0 comments on commit b5056ba

Please sign in to comment.