larray-project / larray

N-dimensional labelled arrays in Python
https://larray.readthedocs.io/
GNU General Public License v3.0
8 stars 6 forks source link

add a way to specify aggregated axes name #1002

Open gdementen opened 2 years ago

gdementen commented 2 years ago

see #1001.

Currently, we relatively often see code like this:

arr.sum(some_aggregation_on_a).rename('a', 'b')

and it would be nice to be able to express it like this instead:

arr.sum(b=some_aggragation_on_a)

OR (unsure which, or both):

arr.sum('b=some_aggragation_on_a')

The first syntax would be backward incompatible because currently **kwargs are a way to specify the source axis (instead of the destination axis like this issue is about) but I fear implementing the second (string) syntax without the first would be a very bad idea, at least if we keep the current semantic. Nobody would know what the following means:

arr.sum(a='b=a1,a2', b='a=b1,b2')

But I just saw issue #565 so maybe (luckily) this was undocumented (or is that issue about something else???).

FWIW, this issue is related to #23 and the future grid syntax.