Skip to content
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

bug: add missing Sun in VOUnits simple units #15832

Merged
merged 2 commits into from Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion astropy/units/format/vounit.py
Expand Up @@ -43,7 +43,7 @@ def _generate_unit_names():
"solRad", "sr", "T", "u", "V", "voxel", "W", "Wb", "yr",
] # fmt: skip
binary_bases = ["bit", "byte", "B"]
simple_units = ["Angstrom", "angstrom", "AU", "au", "Ba", "dB", "mas"]
simple_units = ["Angstrom", "angstrom", "AU", "au", "Ba", "dB", "mas", "Sun"]
si_prefixes = [
"y", "z", "a", "f", "p", "n", "u", "m", "c", "d",
"", "da", "h", "k", "M", "G", "T", "P", "E", "Z", "Y"
Expand Down
9 changes: 9 additions & 0 deletions astropy/units/tests/test_format.py
Expand Up @@ -681,6 +681,15 @@ def test_vounit_details():
assert u.Unit("ka", format="vounit") == u.Unit("1000 yr")
assert u.Unit("pix", format="vounit") == u.Unit("pixel", format="vounit")

# Regression test for astropy/astroquery#2480
assert u.Unit("Sun", format="vounit") is u.Sun

# Test that adding a prefix to a simple units raises a warning
with pytest.warns(
UnitsWarning, match="Unit 'kdB' not supported by the VOUnit standard.*"
):
u.Unit("kdB", format="vounit")

# The da- prefix is not allowed, and the d- prefix is discouraged
assert u.dam.to_string("vounit") == "10m"
assert u.Unit("dam dag").to_string("vounit") == "100g.m"
Expand Down
1 change: 1 addition & 0 deletions docs/changes/units/15832.bugfix.rst
@@ -0,0 +1 @@
Fix a missing ``Sun`` unit in the list of VOUnits simple_units.