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']
>>> g
a['yada']
>>> arr[g]
ValueError: a['yada'] is not a valid label for any axis
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.
related to #200. Please see the comments there.
Currently, keys are only checked when used in an array, so when creating a group, it happily accepts keys which do not exist.
FWIW, it was done this way initially for two reasons:
related to #200. Please see the comments there.