Skip to content

Commit

Permalink
MAINT: refactor to use more Quantities based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
bsipocz committed Jan 10, 2025
1 parent b039b1d commit 3075ab6
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions pyvo/dal/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,12 @@ def _validate_pos(self, pos):
self._validate_ra(m)

def _validate_ra(self, ra):
if isinstance(ra, str):
ra = Unit(ra)
if not isinstance(ra, Quantity):
ra = ra * u.deg
ra = Quantity(ra, u.deg)
if ra.to(u.deg).value < 0 or ra.to(u.deg).value > 360.0:
raise ValueError('Invalid ra: {}'.format(ra))

def _validate_dec(self, dec):
if isinstance(dec, str):
dec = Unit(dec)
if not isinstance(dec, Quantity):
dec = dec * u.deg
dec = Quantity(dec, u.deg)
if dec.to(u.deg).value < -90.0 or dec.to(u.deg).value > 90.0:
raise ValueError('Invalid dec: {}'.format(dec))

Expand Down Expand Up @@ -418,15 +412,12 @@ def get_dal_format(self, val):
raise ValueError('Invalid interval: min({}) > max({})'.format(
low, high))
if self._unit:
if isinstance(low, str):
low = Unit(low)
if not isinstance(low, Quantity):
low = low * self._unit
low = u.Quantity(low, self._unit)
low = low.to(self._unit, equivalencies=self._equivalencies).value
if isinstance(high, str):
high = Unit(high)

if not isinstance(high, Quantity):
high = high * self._unit
high = Quantity(high, self._unit)
high = high.to(self._unit, equivalencies=self._equivalencies).value

if low > high:
Expand Down

0 comments on commit 3075ab6

Please sign in to comment.