@@ -58,26 +58,33 @@ def test_scalar_geodetic2ecef(lla):
5858
5959 if isinstance (lla [0 ], list ):
6060 np = pytest .importorskip ("numpy" )
61+ scalar = False
62+ else :
63+ scalar = True
6164
6265 xyz = pm .geodetic2ecef (* lla )
6366 lla1 = pm .ecef2geodetic (* xyz )
6467
6568 try :
66- assert np .isclose (lla1 , lla , rtol = 1e-4 ). all ( )
69+ np .testing . assert_allclose (lla1 , lla , rtol = 1e-4 )
6770 except NameError :
6871 assert lla1 == approx (lla , rel = 1e-4 )
6972
73+ if scalar :
74+ assert all (isinstance (n , float ) for n in xyz )
75+ assert all (isinstance (n , float ) for n in lla1 )
76+
7077
7178def test_array_geodetic2ecef ():
7279 np = pytest .importorskip ("numpy" )
7380
7481 lla = (np .asarray (lla0 [0 ]), np .asarray (lla0 [1 ]), np .asarray (lla0 [2 ]))
7582 xyz = pm .geodetic2ecef (* lla )
76- assert np .isclose (pm .ecef2geodetic (* xyz ), lla ). all ( )
83+ np .testing . assert_allclose (pm .ecef2geodetic (* xyz ), lla )
7784
7885 lla = (np .atleast_1d (lla0 [0 ]), np .atleast_1d (lla0 [1 ]), np .atleast_1d (lla0 [2 ]))
7986 xyz = pm .geodetic2ecef (* lla )
80- assert np .isclose (pm .ecef2geodetic (* xyz ), lla ). all ( )
87+ np .testing . assert_allclose (pm .ecef2geodetic (* xyz ), lla )
8188
8289
8390@pytest .mark .parametrize ("xyz" , [xyz0 , ([xyz0 [0 ]], [xyz0 [1 ]], [xyz0 [2 ]])], ids = ("scalar" , "list" ))
@@ -88,26 +95,33 @@ def test_scalar_ecef2geodetic(xyz):
8895
8996 if isinstance (xyz [0 ], list ):
9097 np = pytest .importorskip ("numpy" )
98+ scalar = False
99+ else :
100+ scalar = True
91101
92102 lla = pm .ecef2geodetic (* xyz )
93103 xyz1 = pm .geodetic2ecef (* lla )
94104
95105 try :
96- assert np .isclose (xyz1 , xyz , rtol = 1e-4 ). all ( )
106+ np .testing . assert_allclose (xyz1 , xyz , rtol = 1e-4 )
97107 except NameError :
98108 assert xyz1 == approx (xyz , rel = 1e-4 )
99109
110+ if scalar :
111+ assert all (isinstance (n , float ) for n in xyz1 )
112+ assert all (isinstance (n , float ) for n in lla )
113+
100114
101115def test_array_ecef2geodetic ():
102116 np = pytest .importorskip ("numpy" )
103117
104118 xyz = (np .asarray (xyz0 [0 ]), np .asarray (xyz0 [1 ]), np .asarray (xyz0 [2 ]))
105119 lla = pm .ecef2geodetic (* xyz )
106- assert np .isclose (pm .geodetic2ecef (* lla ), xyz ). all ( )
120+ np .testing . assert_allclose (pm .geodetic2ecef (* lla ), xyz )
107121
108122 xyz = (np .atleast_1d (xyz0 [0 ]), np .atleast_1d (xyz0 [1 ]), np .atleast_1d (xyz0 [2 ]))
109123 lla = pm .ecef2geodetic (* xyz )
110- assert np .isclose (pm .geodetic2ecef (* lla ), xyz ). all ( )
124+ np .testing . assert_allclose (pm .geodetic2ecef (* lla ), xyz )
111125
112126
113127def test_inside_ecef2geodetic ():
@@ -201,19 +215,15 @@ def test_ecef2geodetic(xyz, lla):
201215 ],
202216)
203217def test_aer_geodetic (aer , lla , lla0 ):
204- lat1 , lon1 , alt1 = pm .aer2geodetic (* aer , * lla0 )
205- assert lat1 == approx (lla [0 ])
206- assert lon1 == approx (lla [1 ])
207- assert alt1 == approx (lla [2 ])
208- assert isinstance (lat1 , float )
209- assert isinstance (lon1 , float )
210- assert isinstance (alt1 , float )
218+ lla1 = pm .aer2geodetic (* aer , * lla0 )
219+ assert lla1 == approx (lla )
220+ assert all (isinstance (n , float ) for n in lla1 )
211221
212222 raer = (radians (aer [0 ]), radians (aer [1 ]), aer [2 ])
213223 rlla0 = (radians (lla0 [0 ]), radians (lla0 [1 ]), lla0 [2 ])
214- assert pm .aer2geodetic (* raer , * rlla0 , deg = False ) == approx (
215- ( radians (lla [0 ]), radians (lla [1 ]), lla [2 ])
216- )
224+ lla1 = pm .aer2geodetic (* raer , * rlla0 , deg = False )
225+ assert lla1 == approx (( radians (lla [0 ]), radians (lla [1 ]), lla [2 ]) )
226+ assert all ( isinstance ( n , float ) for n in lla1 )
217227
218228 with pytest .raises (ValueError ):
219229 pm .aer2geodetic (aer [0 ], aer [1 ], - 1 , * lla0 )
@@ -225,11 +235,11 @@ def test_aer_geodetic(aer, lla, lla0):
225235
226236
227237def test_scalar_nan ():
228- a , e , r = pm .geodetic2aer (nan , nan , nan , * lla0 )
229- assert isnan (a ) and isnan ( e ) and isnan ( r )
238+ aer = pm .geodetic2aer (nan , nan , nan , * lla0 )
239+ assert all ( isnan (n ) for n in aer )
230240
231- lat , lon , alt = pm .aer2geodetic (nan , nan , nan , * lla0 )
232- assert isnan (lat ) and isnan ( lon ) and isnan ( alt )
241+ llat = pm .aer2geodetic (nan , nan , nan , * lla0 )
242+ assert all ( isnan (n ) for n in llat )
233243
234244
235245def test_allnan ():
@@ -251,23 +261,21 @@ def test_somenan():
251261@pytest .mark .parametrize ("xyz, lla" , xyzlla )
252262def test_numpy_ecef2geodetic (xyz , lla ):
253263 np = pytest .importorskip ("numpy" )
254- lat , lon , alt = pm .ecef2geodetic (
264+ lla1 = pm .ecef2geodetic (
255265 * np .array (
256266 [
257267 [xyz ],
258268 ],
259269 dtype = np .float32 ,
260270 ).T
261271 )
262- assert lat [0 ] == approx (lla [0 ])
263- assert lon [0 ] == approx (lla [1 ])
264- assert alt [0 ] == approx (lla [2 ])
272+ assert lla1 == approx (lla )
265273
266274
267275@pytest .mark .parametrize ("lla, xyz" , llaxyz )
268276def test_numpy_geodetic2ecef (lla , xyz ):
269277 np = pytest .importorskip ("numpy" )
270- x , y , z = pm .geodetic2ecef (
278+ xyz1 = pm .geodetic2ecef (
271279 * np .array (
272280 [
273281 [lla ],
@@ -277,6 +285,4 @@ def test_numpy_geodetic2ecef(lla, xyz):
277285 )
278286
279287 atol_dist = 1 # meters
280- assert x [0 ] == approx (xyz [0 ], abs = atol_dist )
281- assert y [0 ] == approx (xyz [1 ], abs = atol_dist )
282- assert z [0 ] == approx (xyz [2 ], abs = atol_dist )
288+ assert xyz1 == approx (xyz , abs = atol_dist )
0 commit comments