Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Future-proof physical_type usage for astropy 4.3 #550

Merged
merged 4 commits into from
Apr 23, 2021

Conversation

rosteen
Copy link
Collaborator

@rosteen rosteen commented Apr 20, 2021

Fixes #549 .

@rosteen rosteen requested a review from pllim April 20, 2021 20:40
spectral_axis_unit_type = data.spectral_axis.unit.physical_type.title()
try:
spectral_axis_unit_type = data.spectral_axis.unit.physical_type.title()
except AttributeError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except is expensive. Better to check for astropy version on import and use if ... else ... based on that check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if list(data.spectral_axis.unit.physical_type)[0].title() would be better, in case you are accessing a unit with multiple entries, but if that is not a possibility, then you don't have to.

Copy link
Contributor

@ibusko ibusko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@pllim
Copy link
Contributor

pllim commented Apr 23, 2021

p.s. The protection rule for "outdated branch" might be overkill. Made me press a button that created a merge commit.

@rosteen
Copy link
Collaborator Author

rosteen commented Apr 23, 2021

Agreed, I was wondering where that came from when I had to do it for one of your PRs.

@pllim pllim merged commit dfce45c into spacetelescope:main Apr 23, 2021
@rosteen rosteen deleted the title-fix branch September 10, 2021 17:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix unit.physical_type errors with astropy 4.3
3 participants