Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aelanman committed Mar 22, 2024
1 parent e41afe4 commit 0ad61ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lunarsky/moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def from_selenodetic(cls, lon, lat, height=0.0, ellipsoid=None):
selenodetic = SELENOIDS[ellipsoid](lon, lat, height, copy=False)
xyz = selenodetic.to_cartesian().get_xyz(xyz_axis=-1) << height.unit
self = xyz.view(cls._location_dtype, cls).reshape(selenodetic.shape)
self._ellipsoid = ellipsoid
self.ellipsoid = ellipsoid
return self

def __str__(self):
Expand Down
11 changes: 8 additions & 3 deletions lunarsky/tests/test_moon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import copy
import numpy as np
import astropy.units as unit
from astropy.coordinates import Longitude, Latitude
from astropy.coordinates import Longitude, Latitude, SphericalRepresentation, SphericalDifferential
from astropy.tests.helper import quantity_allclose
from astropy.coordinates.tests.test_representation import representation_equal
from lunarsky import MoonLocation, MoonLocationAttribute, MCMF
from lunarsky.moon import SELENOIDS
from lunarsky.moon import SELENOIDS, MoonLocationInfo


class TestsWithObject:
Expand All @@ -21,7 +22,7 @@ def setup_method(self):
self.lat = Latitude([+0.0, 30.0, 60.0, +90.0, -90.0, -60.0, -30.0, 0.0], unit.deg)
self.h = unit.Quantity([0.1, 0.5, 1.0, -0.5, -1.0, +4.2, -11.0, -0.1], unit.m)
self.location = MoonLocation.from_selenodetic(self.lon, self.lat, self.h)
self.x, self.y, self.z = self.location.to_selenocentric()
self.x, self.y, self.z = self.location.selenocentric

def test_input(self):
cartesian = MoonLocation(self.x, self.y, self.z)
Expand Down Expand Up @@ -68,6 +69,10 @@ def test_invalid(self):
with pytest.raises(ValueError):
MoonLocation.from_selenodetic(self.lon, self.lat, self.h[:5])

# invalid ellipsoid
with pytest.raises(ValueError):
loc = MoonLocation.from_selenodetic(self.lon, self.lat, self.h, ellipsoid="INVALID")

def test_attributes(self):
assert np.allclose(self.location.height, self.h)
assert np.allclose(self.location.lon, self.lon)
Expand Down

0 comments on commit 0ad61ac

Please sign in to comment.