From 38f10a3b0aecad2aa9a81401e9c511408429d1c7 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Mon, 11 Dec 2023 06:35:41 -0500 Subject: [PATCH] Allow using any angle-like parallax with Distance The `parallax` argument to `Distance` can now be any object that can be converted to an angular `Quantity`, most notably `table.Column`. --- astropy/coordinates/distances.py | 3 ++- docs/changes/coordinates/15712.bugfix.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 docs/changes/coordinates/15712.bugfix.rst diff --git a/astropy/coordinates/distances.py b/astropy/coordinates/distances.py index d53f5f504b4..b7957dcd8e9 100644 --- a/astropy/coordinates/distances.py +++ b/astropy/coordinates/distances.py @@ -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`. @@ -162,6 +162,7 @@ def __new__( unit = u.pc elif parallax is not None: + parallax = u.Quantity(parallax, copy=False, subok=True) if unit is None: unit = u.pc value = parallax.to_value(unit, equivalencies=u.parallax()) diff --git a/docs/changes/coordinates/15712.bugfix.rst b/docs/changes/coordinates/15712.bugfix.rst new file mode 100644 index 00000000000..fd62441a883 --- /dev/null +++ b/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.