Skip to content

Commit cf6eb15

Browse files
committed
Merge branch 'main' into fix-numbagg-check
* main: Set order='F' when raveling group_idx after broadcast (#286) Ignore benchmarks for codecov (#287)
2 parents a0d9325 + 273d319 commit cf6eb15

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

asv_bench/benchmarks/reduce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def setup(self, *args, **kwargs):
110110
class ChunkReduce2DAllAxes(ChunkReduce):
111111
def setup(self, *args, **kwargs):
112112
self.array = np.ones((N, N))
113-
self.labels = np.repeat(np.arange(N // 5), repeats=5)
113+
self.labels = np.repeat(np.arange(N // 5), repeats=5)[np.newaxis, :]
114114
self.axis = None
115115
setup_jit()
116116

codecov.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ codecov:
55
comment: false
66

77
ignore:
8-
- "benchmarks/*.py"
8+
- "asv_bench/benchmarks/*.py"
99
- "tests/*.py"
10-
- "setup.py"
1110

1211
coverage:
1312
precision: 2

flox/core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,12 @@ def chunk_reduce(
819819
# Of course we are slower to ravel `array` but we avoid argsorting
820820
# both `array` *and* `group_idx` in _prepare_for_flox
821821
group_idx = np.broadcast_to(group_idx, array.shape[-by.ndim :])
822-
# if engine == "flox":
823-
group_idx = group_idx.reshape(-1, order="F")
824-
order = "F"
822+
if engine == "flox":
823+
group_idx = group_idx.reshape(-1, order="F")
824+
order = "F"
825825
# always reshape to 1D along group dimensions
826826
newshape = array.shape[: array.ndim - by.ndim] + (math.prod(array.shape[-by.ndim :]),)
827-
array = array.reshape(newshape, order=order)
827+
array = array.reshape(newshape, order=order) # type: ignore[call-overload]
828828
group_idx = group_idx.reshape(-1)
829829

830830
assert group_idx.ndim == 1
@@ -1866,7 +1866,8 @@ def groupby_reduce(
18661866
Array to be reduced, possibly nD
18671867
*by : ndarray or DaskArray
18681868
Array of labels to group over. Must be aligned with ``array`` so that
1869-
``array.shape[-by.ndim :] == by.shape``
1869+
``array.shape[-by.ndim :] == by.shape`` or any disagreements in that
1870+
equality check are for dimensions of size 1 in `by`.
18701871
func : {"all", "any", "count", "sum", "nansum", "mean", "nanmean", \
18711872
"max", "nanmax", "min", "nanmin", "argmax", "nanargmax", "argmin", "nanargmin", \
18721873
"quantile", "nanquantile", "median", "nanmedian", "mode", "nanmode", \

tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_groupby_reduce(
203203
def gen_array_by(size, func):
204204
by = np.ones(size[-1])
205205
rng = np.random.default_rng(12345)
206-
array = rng.random(size)
206+
array = rng.random(tuple(6 if s == 1 else s for s in size))
207207
if "nan" in func and "nanarg" not in func:
208208
array[[1, 4, 5], ...] = np.nan
209209
elif "nanarg" in func and len(size) > 1:
@@ -222,8 +222,8 @@ def gen_array_by(size, func):
222222
pytest.param(4, marks=requires_dask),
223223
],
224224
)
225+
@pytest.mark.parametrize("size", ((1, 12), (12,), (12, 9)))
225226
@pytest.mark.parametrize("nby", [1, 2, 3])
226-
@pytest.mark.parametrize("size", ((12,), (12, 9)))
227227
@pytest.mark.parametrize("add_nan_by", [True, False])
228228
@pytest.mark.parametrize("func", ALL_FUNCS)
229229
def test_groupby_reduce_all(nby, size, chunks, func, add_nan_by, engine):

0 commit comments

Comments
 (0)