Skip to content
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

Improve getitem ValueError message when trying to retrieve multliple labels #1101

Open
gdementen opened this issue Mar 25, 2024 · 0 comments

Comments

@gdementen
Copy link
Contributor

When trying to retrieve several labels and it fails, it is sometimes hard to know exactly which label(s) are missing from the array, especially when the axes are long and not all labels are displayed in the axes summary.

I think that when it fails, displaying axes where it matches partially and the missing keys could be a large quality of life improvement:

>>> arr = la.ndtest('a=a0..a4,a6..a9;b=b0..b2')
>>> arr['a0,a7,a2,a5,a3,a4,a8']
ValueError: 'a0,a7,a2,a5,a3,a4,a8' is not a valid label for any axis:
 a [9]: 'a0' 'a1' 'a2' ... 'a7' 'a8' 'a9'
 b [3]: 'b0' 'b1' 'b2'

FWIW, as a quick workaround, I had to resort to this to know which key was missing:

>>> arr.a.union('a0,a7,a2,a5,a3,a4,a8').difference(arr.a)
Axis(['a5'], 'a')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant