|
4 | 4 |
|
5 | 5 | from __future__ import annotations |
6 | 6 | import typing |
| 7 | +from math import pi |
7 | 8 |
|
8 | 9 | from .ellipsoid import Ellipsoid |
9 | 10 |
|
10 | 11 | try: |
11 | | - from numpy import hypot, cos, sin, arctan2 as atan2, radians, pi, asarray, sign |
| 12 | + from numpy import hypot, cos, sin, arctan2 as atan2, radians, asarray, sign |
12 | 13 | except ImportError: |
13 | | - from math import atan2, hypot, cos, sin, radians, pi # type: ignore |
14 | | - |
15 | | - asarray = None # type: ignore |
| 14 | + from math import atan2, hypot, cos, sin, radians # type: ignore |
16 | 15 |
|
17 | 16 | def sign(x: float) -> float: # type: ignore |
18 | 17 | """signum function""" |
@@ -63,17 +62,22 @@ def sph2cart(az: ndarray, el: ndarray, r: ndarray) -> tuple[ndarray, ndarray, nd |
63 | 62 | def sanitize( |
64 | 63 | lat: float | ndarray, ell: typing.Optional[Ellipsoid], deg: bool |
65 | 64 | ) -> tuple[float | ndarray, Ellipsoid]: |
| 65 | + |
66 | 66 | if ell is None: |
67 | 67 | ell = Ellipsoid() |
68 | | - if asarray is not None: |
| 68 | + |
| 69 | + try: |
69 | 70 | lat = asarray(lat) |
| 71 | + except NameError: |
| 72 | + pass |
| 73 | + |
70 | 74 | if deg: |
71 | 75 | lat = radians(lat) |
72 | 76 |
|
73 | | - if asarray is not None: |
| 77 | + try: |
74 | 78 | if (abs(lat) > pi / 2).any(): # type: ignore |
75 | 79 | raise ValueError("-pi/2 <= latitude <= pi/2") |
76 | | - else: |
| 80 | + except AttributeError: |
77 | 81 | if abs(lat) > pi / 2: # type: ignore |
78 | 82 | raise ValueError("-pi/2 <= latitude <= pi/2") |
79 | 83 |
|
|
0 commit comments