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
Currently, keys are only checked when used in an array, so when creating a group, it happily accepts keys which do not exist.
>>>arr=ndtest((2, 3))
>>># this should fail
... g=arr.a['yada']
>>>ga['yada']
>>>arr[g]
ValueError: a['yada'] isnotavalidlabelforanyaxis
FWIW, it was done this way initially for two reasons:
performance (to avoid translating the key if it is not used), but in the end, it is better to be correct than fast and, in the usual case where the resulting group is actually used, it would be even faster this way (assuming we translate it directly to positional).
to be correct in case the axis labels are modified in-place. But I now think we should either forbid this anyway, or allow this with a big fat warning that you might be shooting yourself in the foot.
I tried implementing this and fixed a few buggy tests thanks to this. I assume it would uncover less buggy code for users because they probably use the groups they define but... you never know.
I commented the checking code so far because a couple of tests are still failing with this and I am undecided how to fix them and besides a bugfix release does not seem like the right time to implement such a change.
Two class of test failures:
tests which are expected to fail/raise but now raise "too soon" and thus the error message is not correct/the expected one. I hope it will be just a matter of catching the exception and re-raising it.
a few tests revolving around the question of where we accept "query strings" and where we accept only raw values. For example:
age=Axis('age=0..10')
arr=ndtest(age)
g=age[['2', '4', '7']] # the group creation worked before but fails with the check (but it failed when using the group)arr[g] # failed beforeg=age['2,4,7'] # works before and afterLGroup('1', axis=age) # group creation worked before but fails with the checkLGroup('1:3', axis=age) # works before and after
I think I remember there were some cases where "query strings" are parsed within a list but I cannot find any anymore. I don't think we should, so that would only leave us with the single integer string being refused oddity. It's not really an ambiguity but that's weird anyway.
Activity
gdementen commentedon Apr 3, 2026
I tried implementing this and fixed a few buggy tests thanks to this. I assume it would uncover less buggy code for users because they probably use the groups they define but... you never know.
I commented the checking code so far because a couple of tests are still failing with this and I am undecided how to fix them and besides a bugfix release does not seem like the right time to implement such a change.
Two class of test failures:
DOC: commented code to check that LGroup keys are valid on their axis…
DOC: commented code to check that LGroup keys are valid on their axis…