You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mixing slices and individual labels to select along the same axis #429
I would say neither. It is because it has many syntax implications on other stuff and I never had both the time AND a clear enough mind to think this through. It is related to #23 and the whole constellation of related issues and how to make our API future-proof.
>>>a=Axis('a=a0..a4')
>>># when using the string syntax, it seems natural that:>>>a['a0:a2,a4']
a[['a0', 'a1', 'a2', 'a4']]
>>># and>>>a['a0:a2;a4']
(a['a0':'a2'], a['a4'])
>>># BUT I want to have a way to do it easily using the non string syntax AND keep both syntaxes consistent>>>a['a0':'a2', 'a4']
a[['a0', 'a1', 'a2', 'a4']]
OR?
(a['a0':'a2'], a['a4'])
and I have been leaning on the second one because we can easily add something to go from multiple groups to a single group, but not the opposite. But given the inconsistency with the string syntax, this yielded a deadlock.
The question is thus: is there an alternative to make creating several groups containing slices on the same axis easily?
Assuming we keep the , with scalars to mean "concatenate" to match the string syntax:
>>>a['a0':'a2', 'a4']
a[['a0', 'a1', 'a2', 'a4']]
We have a few options:
>>># in the worst case, we can use the following syntax. We will get it "for free" because :>>># * we need anyway to implement G[] to easily create groups without axis, >>># * we need to keep `axis[several, group]` returning `(axis[several], axis[group])`>>>a[G['a0':'a2'], G['a4']]
(a['a0':'a2'], a['a4'])
>>># but we could implement this too:>>>a.groups['a0':'a2', 'a4']
(a['a0':'a2'], a['a4'])
>>># unsure what we should return in that case though (maybe raise an exception?):>>>a[G['a0':'a2'], 'a4']
BUT that would generate anonymous groups leading to ugly automatic labels when performing an aggregation.
Furthermore, that doesn't solve the problem when the user actually wants to create a unique group with labels given by mixing a slice and a list of individual labels.
This my understanding of Axis.groups[ ] and I may have miss something.
Axis.groups[] does not exist yet AFAIK, it was just an idea to support the use case where users want to create several groups on the same axis "quickly" if we make Axis[slice, slice] return a single group.
Activity
gdementen commentedon Sep 18, 2017
this is basically a duplicate of #360. There is a reason but I have no time to explain that now.
alixdamman commentedon Sep 19, 2017
That reason is technical or philosophical? (this issue comes from the demand of one our current user)
gdementen commentedon Sep 19, 2017
I would say neither. It is because it has many syntax implications on other stuff and I never had both the time AND a clear enough mind to think this through. It is related to #23 and the whole constellation of related issues and how to make our API future-proof.
and I have been leaning on the second one because we can easily add something to go from multiple groups to a single group, but not the opposite. But given the inconsistency with the string syntax, this yielded a deadlock.
The question is thus: is there an alternative to make creating several groups containing slices on the same axis easily?
FWIW, for non slices, this is a non-issue:
gdementen commentedon Sep 19, 2017
One alternative would be to use a "slice builder" (e.g S) and move subgroups in lists, but this feels too hard/unatural to my tastes:
gdementen commentedon Sep 20, 2017
Assuming we keep the
,with scalars to mean "concatenate" to match the string syntax:We have a few options:
FWIW: here is one of my use cases in MOSES:
gdementen commentedon Sep 20, 2017
so basically, we can start implementing this.
alixdamman commentedon Sep 20, 2017
release 0.27?
gdementen commentedon Sep 20, 2017
If you feel like so. My comment was just meant as "it is no longer blocked by my hesitation for indirect consequences of this".
gdementen commentedon Nov 28, 2017
I met this need in planet
gdementen commentedon Feb 18, 2021
With the current LArray version, the easiest workaround is to use "union": arr[a["a0:a2"].union(a["a4"])]
alixdamman commentedon Feb 24, 2021
As I understand,
Axis.groups[ ]returns a tuple of groups:BUT that would generate anonymous groups leading to ugly automatic labels when performing an aggregation.
Furthermore, that doesn't solve the problem when the user actually wants to create a unique group with labels given by mixing a slice and a list of individual labels.
This my understanding of
Axis.groups[ ]and I may have miss something.gdementen commentedon Feb 24, 2021
Axis.groups[] does not exist yet AFAIK, it was just an idea to support the use case where users want to create several groups on the same axis "quickly" if we make Axis[slice, slice] return a single group.