Skip to content

Commit d78f825

Browse files
committed
eci2ecef,ecef2eci: vectorize. Employ initial partial type annotation
remove unneeded asarray
1 parent f4e595d commit d78f825

32 files changed

Lines changed: 975 additions & 923 deletions

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ version = {attr = "pymap3d.__version__"}
2525
tests = ["pytest", "mypy"]
2626
coverage = ["pytest-cov"]
2727
format = ["black[jupyter]", "isort"]
28-
core = ["python-dateutil", "numpy >= 1.10.0"]
29-
full = ["astropy", "xarray"]
28+
core = ["python-dateutil", "numpy >= 1.21.0"]
29+
full = ["astropy"]
3030
proj = ["pyproj"]
3131

3232
[tool.black]

src/pymap3d/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
1717
deg : bool = True means degrees. False = radians.
1818
19-
Most functions accept NumPy arrays of any shape, as well as compatible data types
20-
including AstroPy, Pandas and Xarray that have Numpy-like data properties.
21-
For clarity, we omit all these types in the docs, and just specify the scalar type.
19+
Most functions accept scalar float or NumPy NDArray.
2220
2321
Other languages
2422
---------------

src/pymap3d/_dummy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from datetime import datetime
22

3+
34
def eci2ecef(x, y, z, time: datetime, force_non_astropy: bool = False) -> tuple:
45
raise ImportError("Numpy required for eci2ecef")
56

7+
68
def ecef2eci(x, y, z, time: datetime, force_non_astropy: bool = False) -> tuple:
79
raise ImportError("Numpy required for ecef2eci")

src/pymap3d/_typing.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Typing helpers for pymap3d.
2+
3+
NumPy is strictly optional at runtime.
4+
"""
5+
6+
from __future__ import annotations
7+
8+
from datetime import datetime
9+
from typing import TYPE_CHECKING, Any, Union
10+
11+
# typing.Union is for Python 3.9. Python 3.10+ can use the | operator for unions.
12+
13+
if TYPE_CHECKING:
14+
# Only loaded by type checkers (mypy, pyright, etc.)
15+
import numpy as np
16+
import numpy.typing as npt
17+
18+
ArrayLike = npt.ArrayLike
19+
NDArray = npt.NDArray
20+
21+
DatetimeLike = Union[str, datetime, np.datetime64]
22+
FloatLike = Union[float, np.floating]
23+
24+
FloatArray = npt.NDArray[np.floating]
25+
DatetimeArray = Union[npt.NDArray[np.datetime64], np.datetime64, datetime]
26+
else:
27+
ArrayLike = Any
28+
NDArray = Any
29+
30+
DatetimeLike = Union[str, datetime]
31+
FloatLike = float
32+
33+
FloatArray = float
34+
DatetimeArray = datetime
35+
36+
37+
__all__ = ["ArrayLike", "NDArray", "FloatArray", "FloatLike", "DatetimeArray", "DatetimeLike"]

0 commit comments

Comments
 (0)