Skip to content

Commit

Permalink
Merge pull request #229 from braingram/deprecated_factor
Browse files Browse the repository at this point in the history
Strip `factor=None` in equivalency converter for spectral density
  • Loading branch information
braingram authored Jun 13, 2024
2 parents 1b28610 + 8f54ebf commit dab5b4d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
3 changes: 3 additions & 0 deletions asdf_astropy/converters/unit/equivalency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion asdf_astropy/converters/unit/tests/test_equivalency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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


Expand Down

0 comments on commit dab5b4d

Please sign in to comment.