-
Notifications
You must be signed in to change notification settings - Fork 45
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
AstropyDeprecationWarning: The class "Fits" has been renamed to "FITS" in version 7.0 #499
Comments
Quick summaryThe correct code that would avoid the deprecation warnings would be - cunit = frame.unit[fidx].get_format_name(u.format.Fits).upper()
+ cunit = frame.unit[fidx].get_format_name("fits").upper() Trying to use formatter classes instead of the format names will not work as intended for all units, as can be demonstrated below: >>> from astropy import units as u
>>> u.voxel.get_format_name("fits")
'voxel'
>>> u.voxel.get_format_name(u.format.Fits)
'vox' If any of the affected units (at least Detailed explanationWriting down the name of every possible unit in every possible format >>> from astropy import units as u
>>> u.deg.get_format_name("fits")
'deg'
>>> u.deg.get_format_name("latex")
'{}^{\\circ}'
>>> u.deg.get_format_name("unicode")
'°' with incorrect code using the formatter classes directly >>> u.deg.get_format_name(u.format.Fits)
'deg'
>>> u.deg.get_format_name(u.format.Latex)
'deg'
>>> u.deg.get_format_name(u.format.Unicode)
'deg' Often enough the name as specified by the FITS standard is the same as the default name |
I also wonder if this problem would propagate to the fields in ASDF data schema, etc. 😬 |
Indeed I did, but I was thinking of simply shoe-horning an |
I had a look at the the whole block Lines 2034 to 2037 in 53025a9
Composite units (such as "mas / yr" or "km / s") are handled in the else -branch, but I can't tell if this is deliberate or is it just a workaround for the fact that they don't have a get_format_name() method. If the else -branch is indeed a clumsy workaround then the whole if-else block could be replaced with a single line:
- if hasattr(frame.unit[fidx], 'get_format_name'):
- cunit = frame.unit[fidx].get_format_name(u.format.Fits).upper()
- else:
- cunit = ''
+ cunit = frame.unit[fidx].to_string("fits").upper() Note also that differently from |
astropy/astropy#16455 (comment)
gwcs/gwcs/wcs.py
Line 2035 in 53025a9
@neutrinoceros expressed interest to submit a patch.
The text was updated successfully, but these errors were encountered: