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
{{ message }}
Repository navigation
Make PhysicalType instances support string methods with deprecation warnings #11617
Prior to #11204, the physical_type attribute of units was a string with the name of the unit. #11204 transformed the physical_type attribute into instances of the new PhysicalType class. #11204 did preserve much of the behavior of the string API (such as having == work between PhysicalType instances and strings), but there were a few ways that it did not. A few of these ways are being discussed in #11204 starting with this comment. A lot of this could probably be done with this suggestion from @mhvk.
Suggestions on specific string behaviors to include and test for would be appreciated!
I might be able to address this on tomorrow or Friday if I don't have too many side effects from my vaccination later today, but anyone else should feel free to address this in the meantime.
The trouble is worth it though. Units and physical types are extremely hard to get right and the astropy approach of taking it one step at a time is great. And every change will break someone's workflow.
We use the physical type to determine whether a value is an integrated flux or a flux density, #11204 seems to be a step in the right direction to do this properly through dimensional analysis. So thank you!
Activity
namurphy commentedon Apr 21, 2021
I might be able to address this on tomorrow or Friday if I don't have too many side effects from my vaccination later today, but anyone else should feel free to address this in the meantime.
pllim commentedon Apr 28, 2021
Will this be fixed by #11625 ?
namurphy commentedon Apr 28, 2021
Thank you for the reminder! I completely forgot I raised this issue. Yep, #11625 will fix this.
hugobuddel commentedon Jul 30, 2021
==works, butindoes not. This used to result in True in astropy 4.2:But results in False in astropy 4.3.post1:
This works though (and this is how I solved it in our codebase):
And using the full string works with
in:I'm not sure this warrants a separate issue. Support for
==is probably good enough for most cases.hugobuddel commentedon Jul 30, 2021
Oh sorry, it seems to be fixed already but not yet in a release?
hugobuddel commentedon Jul 30, 2021
Ah, now I understand,
innow works like this:So it doesn't make any real sense to support my intended usage in this new scheme. Oh well, that's fine with me. So don't change anything! 😃
namurphy commentedon Jul 30, 2021
Glad that you figured it out!
I seem to have caused a lot more trouble with #11204 than I had intended! 😅
hugobuddel commentedon Jul 31, 2021
The trouble is worth it though. Units and physical types are extremely hard to get right and the astropy approach of taking it one step at a time is great. And every change will break someone's workflow.
We use the physical type to determine whether a value is an integrated flux or a flux density, #11204 seems to be a step in the right direction to do this properly through dimensional analysis. So thank you!