Skip to content

Commit b5652b8

Browse files
committed
restore optional numpy
1 parent a8a90ae commit b5652b8

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

src/pymap3d/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Fortran: [Maptran3D](https://github.com/geospace-code/maptran3d)
3232
"""
3333

34-
from .aer import ecef2aer, aer2ecef, geodetic2aer, aer2geodetic, eci2aer, aer2eci
34+
from .aer import ecef2aer, aer2ecef, geodetic2aer, aer2geodetic
3535
from .ellipsoid import Ellipsoid
3636
from .enu import enu2geodetic, geodetic2enu, aer2enu, enu2aer
3737
from .ned import ned2ecef, ned2geodetic, geodetic2ned, ecef2nedv, ned2aer, aer2ned, ecef2ned
@@ -66,9 +66,10 @@
6666
from .lox import meridian_arc, meridian_dist, loxodrome_inverse, loxodrome_direct, departure, meanm
6767
from .los import lookAtSpheroid
6868
from .timeconv import str2dt
69-
from .eci import eci2ecef, ecef2eci
7069

7170
try:
7271
from .azelradec import radec2azel, azel2radec
72+
from .eci import eci2ecef, ecef2eci
73+
from .aer import eci2aer, aer2eci
7374
except ImportError:
7475
from .vallado import radec2azel, azel2radec

src/pymap3d/aer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
from .enu import geodetic2enu, aer2enu, enu2aer
77
from .ellipsoid import Ellipsoid
88

9-
from .eci import eci2ecef, ecef2eci
10-
9+
try:
10+
from .eci import eci2ecef, ecef2eci
11+
except ImportError:
12+
eci2ecef = ecef2eci = None
1113

1214
__all__ = ["aer2ecef", "ecef2aer", "geodetic2aer", "aer2geodetic", "eci2aer", "aer2eci"]
1315

@@ -208,6 +210,8 @@ def eci2aer(
208210
srange : "ndarray"
209211
slant range [meters]
210212
"""
213+
if eci2ecef is None:
214+
raise ImportError("pip install numpy")
211215

212216
xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)
213217

@@ -265,6 +269,9 @@ def aer2eci(
265269
z : "ndarray"
266270
ECEF z coordinate (meters)
267271
"""
272+
if ecef2eci is None:
273+
raise ImportError("pip install numpy")
274+
268275
x, y, z = aer2ecef(az, el, srange, lat0, lon0, h0, ell, deg=deg)
269276

270277
return ecef2eci(x, y, z, t, use_astropy=use_astropy)

src/pymap3d/ecef.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010

1111
from .ellipsoid import Ellipsoid
1212
from .utils import sanitize
13-
from .eci import eci2ecef, ecef2eci
13+
14+
try:
15+
from .eci import eci2ecef, ecef2eci
16+
except ImportError:
17+
eci2ecef = ecef2eci = None
1418

1519
# py < 3.6 compatible
1620
tau = 2 * pi
@@ -366,6 +370,8 @@ def eci2geodetic(
366370
367371
eci2geodetic() a.k.a. eci2lla()
368372
"""
373+
if eci2ecef is None:
374+
raise ImportError("pip install numpy")
369375

370376
xecef, yecef, zecef = eci2ecef(x, y, z, t, use_astropy=use_astropy)
371377

@@ -415,6 +421,9 @@ def geodetic2eci(
415421
416422
geodetic2eci() a.k.a lla2eci()
417423
"""
424+
if ecef2eci is None:
425+
raise ImportError("pip install numpy")
426+
418427
x, y, z = geodetic2ecef(lat, lon, alt, ell, deg)
419428

420429
return ecef2eci(x, y, z, t, use_astropy=use_astropy)

tests/test_eci.py

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

77
@pytest.mark.parametrize("use_astropy", [True, False])
88
def test_eci2ecef(use_astropy):
9+
pytest.importorskip("numpy")
910
if use_astropy:
1011
pytest.importorskip("astropy")
1112
# this example from Matlab eci2ecef docs
@@ -19,6 +20,7 @@ def test_eci2ecef(use_astropy):
1920

2021
@pytest.mark.parametrize("use_astropy", [True, False])
2122
def test_ecef2eci(use_astropy):
23+
pytest.importorskip("numpy")
2224
if use_astropy:
2325
pytest.importorskip("astropy")
2426
# this example from Matlab ecef2eci docs
@@ -32,6 +34,7 @@ def test_ecef2eci(use_astropy):
3234

3335
@pytest.mark.parametrize("use_astropy", [True, False])
3436
def test_eci2geodetic(use_astropy):
37+
pytest.importorskip("numpy")
3538
if use_astropy:
3639
pytest.importorskip("astropy")
3740

@@ -45,6 +48,7 @@ def test_eci2geodetic(use_astropy):
4548

4649
@pytest.mark.parametrize("use_astropy", [True, False])
4750
def test_geodetic2eci(use_astropy):
51+
pytest.importorskip("numpy")
4852
if use_astropy:
4953
pytest.importorskip("astropy")
5054

@@ -59,6 +63,7 @@ def test_geodetic2eci(use_astropy):
5963
@pytest.mark.parametrize("use_astropy", [True, False])
6064
def test_eci2aer(use_astropy):
6165
# test coords from Matlab eci2aer
66+
pytest.importorskip("numpy")
6267
if use_astropy:
6368
pytest.importorskip("astropy")
6469
t = datetime(1969, 7, 20, 21, 17, 40)
@@ -74,6 +79,7 @@ def test_eci2aer(use_astropy):
7479
@pytest.mark.parametrize("use_astropy", [True, False])
7580
def test_aer2eci(use_astropy):
7681
# test coords from Matlab aer2eci
82+
pytest.importorskip("numpy")
7783
if use_astropy:
7884
pytest.importorskip("astropy")
7985

0 commit comments

Comments
 (0)