-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow ; in get/setitem #983
base: master
Are you sure you want to change the base?
Conversation
so that we can target multiple axes in a single string. eg. arr['a1;b1'] or arr['b1..b3;a2,a1']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I wonder if the tutorial section about selections shouldn't be updated ?
- I wonder if all the logic about keys should not be moved from the
group.py
module to a separate new module (since, as I understand it, the functions present ingroup.py
are also used inaxis.py
andarray.py
)?
@@ -2811,6 +2811,12 @@ def _key_to_axis_indices_dict(self, key): | |||
""" | |||
from .array import Array | |||
|
|||
if isinstance(key, str) and ';' in key: | |||
# FIXME: it would be more logical to use _to_keys(key) instead but this breaks | |||
# the "target an aggregate with its key" feature (test_getitem_on_group_agg). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't understand what you mean by "target an aggregate with its key" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that the two last lines both work:
>>> arr = ndtest(4)
>>> arr
a a0 a1 a2 a3
0 1 2 3
>>> a = arr.a
>>> g1 = a['a1,a3'] >> 'g1'
>>> g2 = a['a0,a2']
>>> agg = arr.sum((g1, g2))
>>> agg
a g1 a0,a2
4 2
>>> agg[g1]
4
>>> agg[g2]
2
This is an obscure feature of LArray which I thought users would want to use but was a pain to implement and "keep working over the years". It makes the code ugly in a few places and costs a bit of performance too... and AFAIK nobody uses it so we should scrap it I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. In that case, add an issue for that (or we will rapidly completely forget about it). Thx.
@@ -651,6 +651,14 @@ def test_getitem_guess_axis(array): | |||
res = arr['b[l1]'] | |||
assert_array_equal(res, arr.data[:, 0]) | |||
|
|||
# several axes in same string (guess axis) | |||
res = arr['l0;l2'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the tutorial with a similar example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
assert res == 1 | ||
|
||
# several axes in same string (with axis information) | ||
res = arr['a[l1];b[l2]'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Yes indeed. Thanks for keeping my lazyness in check 😄.
That would make sense but I don't know if that's easily feasible (cyclic imports etc.). Needs to check. |
Maybe adding an |
No description provided.