Skip to content

Fix bug with individual level label#435

Merged
wtbarnes merged 2 commits intowtbarnes:mainfrom
jwreep:single_label
Mar 6, 2026
Merged

Fix bug with individual level label#435
wtbarnes merged 2 commits intowtbarnes:mainfrom
jwreep:single_label

Conversation

@jwreep
Copy link
Copy Markdown
Collaborator

@jwreep jwreep commented Mar 5, 2026

Fixes #434

I figured it was probably better to simply use np.atleast_1d to solve this problem, rather than introducing if/else logic.

>>> import astropy.units as u
>>> import fiasco
>>> s_10 = fiasco.Ion('S X', 1*u.MK)
>>> s_10[0].label
array(['2s2 2p3 4S3/2'], dtype='<U13')
>>> s_10[:1].label
array(['2s2 2p3 4S3/2'], dtype='<U13')

Do we want to add a test as well?

@wtbarnes
Copy link
Copy Markdown
Owner

wtbarnes commented Mar 5, 2026

A much better solution than my original suggestion. Thanks! A test would be great. The code snippet in your comment would be a sufficient test.

@wtbarnes wtbarnes merged commit bb85e2b into wtbarnes:main Mar 6, 2026
18 of 19 checks passed
@wtbarnes
Copy link
Copy Markdown
Owner

wtbarnes commented Mar 6, 2026

Thanks Jeff!

@jwreep jwreep deleted the single_label branch March 6, 2026 05:35
wtbarnes pushed a commit that referenced this pull request Mar 9, 2026
* use np.atleast_1d to make single valued case arrays

* add test
@wtbarnes wtbarnes mentioned this pull request Mar 9, 2026
wtbarnes added a commit that referenced this pull request Mar 10, 2026
* use np.atleast_1d to make single valued case arrays

* add test

Co-authored-by: Jeffrey Reep <33359703+jwreep@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot access label property when indexing a single level

2 participants