Skip to content

Commit 78155f0

Browse files
committed
fix #913 : fixed *_by functions returning the same value as if no axis was passed when specifying all axes
1 parent 30a8468 commit 78155f0

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/source/changes/version_0_33.rst.inc

+3
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ Fixes
5959
^^^^^
6060

6161
* fixed an edge case for group aggregates and labels in reverse order (closes :issue:`868`).
62+
63+
* fixed *_by functions returning the same value as if no axis was passed when specifying all axes
64+
(closes :issue:`913`)

larray/core/array.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,9 @@ def is_or_contains_group(o):
28322832
def _aggregate(self, op, args, kwargs=None, keepaxes=False, by_agg=False, commutative=False,
28332833
out=None, extra_kwargs={}):
28342834
operations = self._prepare_aggregate(op, args, kwargs, commutative, stack_depth=3)
2835-
if by_agg and operations != self.axes:
2835+
2836+
total_len_args = len(args) + len(kwargs) if kwargs is not None else 0
2837+
if by_agg and total_len_args:
28362838
operations = self._by_args_to_normal_agg_args(operations)
28372839

28382840
res = self

larray/tests/test_array.py

+4
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,10 @@ def test_agg_by(array):
23972397
assert array.sum_by().shape == ()
23982398
assert array.sum_by() == array.sum()
23992399

2400+
# all axes
2401+
assert array.sum_by(geo, age, lipro, sex).equals(array)
2402+
assert array.sum_by(age, geo, sex, lipro).equals(array)
2403+
24002404
# a) group aggregate on a fresh array
24012405

24022406
# a.1) one group

0 commit comments

Comments
 (0)