Skip to content

Commit

Permalink
Allow using any angle-like parallax with Distance
Browse files Browse the repository at this point in the history
The `parallax` argument to `Distance` can now be any object that can be
converted to an angular `Quantity`, most notably `table.Column`.
  • Loading branch information
taldcroft authored and eerovaher committed Dec 12, 2023
1 parent a65a0e6 commit 38f10a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion astropy/coordinates/distances.py
Expand Up @@ -50,7 +50,7 @@ class Distance(u.SpecificTypeQuantity):
distmod : float or `~astropy.units.Quantity`
The distance modulus for this distance. Note that if ``unit`` is not
provided, a guess will be made at the unit between AU, pc, kpc, and Mpc.
parallax : `~astropy.units.Quantity` or `~astropy.coordinates.Angle`
parallax : angle-like
The parallax in angular units.
dtype : `~numpy.dtype`, optional
See `~astropy.units.Quantity`.
Expand Down Expand Up @@ -162,6 +162,7 @@ def __new__(
unit = u.pc

elif parallax is not None:
parallax = u.Quantity(parallax, copy=False, subok=True)

Check warning on line 165 in astropy/coordinates/distances.py

View check run for this annotation

Codecov / codecov/patch

astropy/coordinates/distances.py#L165

Added line #L165 was not covered by tests
if unit is None:
unit = u.pc
value = parallax.to_value(unit, equivalencies=u.parallax())
Expand Down
2 changes: 2 additions & 0 deletions docs/changes/coordinates/15712.bugfix.rst
@@ -0,0 +1,2 @@
``Distance`` now accepts as ``parallax`` any angle-like value.
This includes types like ``Column`` which have a unit but are not ``Quantity`` subclasses.

0 comments on commit 38f10a3

Please sign in to comment.