diff --git a/CHANGES.rst b/CHANGES.rst index 1c4483a4..5adb463e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +0.6.2 (unreleased) +------------------ + +- strip None factor for spectral_density in equivalency converter + to avoid deprecation warnings for astropy 7. [#229] + + 0.6.1 (2024-04-05) ------------------ diff --git a/asdf_astropy/converters/unit/equivalency.py b/asdf_astropy/converters/unit/equivalency.py index 67e273c3..2a889a15 100644 --- a/asdf_astropy/converters/unit/equivalency.py +++ b/asdf_astropy/converters/unit/equivalency.py @@ -21,6 +21,9 @@ def from_yaml_tree(self, node, tag, ctx): equivalency_method = with_H0 if name == "with_H0" else getattr(equivalencies, name) kwargs = dict(zip(equivalency_node["kwargs_names"], equivalency_node["kwargs_values"])) + # astropy 7.0 deprecated factor, if it's None, don't provide it to spectral_density + if "factor" in kwargs and name == "spectral_density" and kwargs["factor"] is None: + del kwargs["factor"] components.append(equivalency_method(**kwargs)) # The Equivalency class is a UserList that overrides __add__ to diff --git a/asdf_astropy/converters/unit/tests/test_equivalency.py b/asdf_astropy/converters/unit/tests/test_equivalency.py index 83d16034..4e3b0bcc 100644 --- a/asdf_astropy/converters/unit/tests/test_equivalency.py +++ b/asdf_astropy/converters/unit/tests/test_equivalency.py @@ -12,7 +12,6 @@ def create_equivalencies(): result = [ eq.plate_scale(0.3 * u.deg / u.mm), eq.pixel_scale(0.5 * u.deg / u.pix), - eq.spectral_density(350 * u.nm, factor=2), eq.spectral_density(350 * u.nm), eq.spectral(), eq.brightness_temperature(500 * u.GHz), @@ -39,6 +38,10 @@ def create_equivalencies(): if Version(astropy.__version__) >= Version("4.1"): result.append(eq.pixel_scale(100.0 * u.pix / u.cm)) + # the factor argument to spectral density is deprecated in astropy 7 + # skip this test to avoid test failures due to the deprecation warning + if Version(astropy.__version__) < Version("7.0.0.dev"): + result.append(eq.spectral_density(350 * u.nm, factor=2)) return result