Skip to content

Commit cc7b3ae

Browse files
committed
all tests pass with and without Numpy
1 parent 82576e6 commit cc7b3ae

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

tests/test_astropy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
import pytest
33
from pytest import approx
44
from math import radians
5+
from datetime import datetime
56
import pymap3d as pm
67
import pymap3d.sidereal as pmd
78
import pymap3d.haversine as pmh
89

910
lon = -148
10-
t0 = '2014-04-06T08:00:00'
11+
t0 = datetime(2014, 4, 6, 8)
1112
lla0 = (42, -82, 200)
1213
sra = 2.90658
1314
ha = 45.482789587392013
@@ -45,13 +46,15 @@ def test_anglesep_meeus():
4546

4647
@pytest.mark.parametrize('useastropy', [True, False])
4748
def test_eci_geodetic(useastropy):
49+
pytest.importorskip("numpy")
4850
t = '2013-01-15T12:00:05'
4951
lla = pm.eci2geodetic(*eci0, t, useastropy=useastropy)
5052
assert lla == approx(lla0, rel=0.2)
5153

5254

5355
@pytest.mark.parametrize('useastropy', [True, False])
5456
def test_eci_aer(useastropy):
57+
pytest.importorskip("numpy")
5558
t = '2013-01-15T12:00:05'
5659

5760
aer1 = pm.eci2aer(*eci0, 42, -100, 0, t, useastropy=useastropy)

tests/test_eci.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@pytest.mark.parametrize('useastropy', [True, False])
1111
def test_eciecef(useastropy):
12+
pytest.importorskip("numpy")
1213
ecef = pm.eci2ecef(*eci0, t1, useastropy=useastropy)
1314
assert ecef == approx([649012.04640917, -4697980.55129606, 4250818.82815207], rel=0.001)
1415

@@ -17,6 +18,7 @@ def test_eciecef(useastropy):
1718

1819
@pytest.mark.parametrize('useastropy', [True, False])
1920
def test_eci_times(useastropy):
21+
pytest.importorskip("numpy")
2022
with pytest.raises(ValueError):
2123
pm.eci2ecef(*eci0, [t0, t0], useastropy=useastropy)
2224

tests/test_geodetic.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import pytest
33
from pytest import approx
44
from math import radians, nan, sqrt, isnan
5+
try:
6+
import numpy
7+
except ImportError:
8+
numpy = None
59

610
import pymap3d as pm
711

@@ -32,6 +36,9 @@ def test_scalar_geodetic2ecef(lla):
3236
"""
3337
verify we can handle the wide variety of input data type users might use
3438
"""
39+
if numpy is None and isinstance(lla[0], list):
40+
pytest.skip("non-numpy scalar only")
41+
3542
x0, y0, z0 = pm.geodetic2ecef(*lla)
3643

3744
assert (x0, y0, z0) == approx(xyz0)
@@ -53,6 +60,9 @@ def test_scalar_ecef2geodetic(xyz):
5360
"""
5461
verify we can handle the wide variety of input data type users might use
5562
"""
63+
if numpy is None and isinstance(xyz[0], list):
64+
pytest.skip("non-numpy scalar only")
65+
5666
lat, lon, alt = pm.ecef2geodetic(*xyz)
5767

5868
assert [lat, lon, alt] == approx(lla0, rel=1e-4)
@@ -75,6 +85,9 @@ def test_scalar_aer_enu(xyz):
7585
"""
7686
verify we can handle the wide variety of input data type users might use
7787
"""
88+
if numpy is None and isinstance(xyz[0], list):
89+
pytest.skip("non-numpy scalar only")
90+
7891
enu = pm.ecef2enu(*xyz, 0, 90, -100)
7992

8093
assert pm.enu2ecef(*enu, 0, 90, -100) == approx([0, A, 50])

tests/test_sky.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pytest
22
from pytest import approx
3+
from datetime import datetime
34
import pymap3d as pm
45

56
lat, lon = (65, -148)
67
lla0 = (42, -82, 200)
78
azel = (180.1, 80)
8-
t0 = '2014-04-06T08:00:00'
9+
t0 = datetime(2014, 4, 6, 8)
910
radec = (166.5032081149338, 55.000011165405752)
1011

1112

0 commit comments

Comments
 (0)