Coverage for pygeodesy/constants.py: 98%

193 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2024-03-10 16:39 -0400

1# -*- coding: utf-8 -*- 

2 

3u'''Single-instance C{float} and C{int} constants across C{pygeodesy} 

4modules and related functions L{pygeodesy.float_}, L{pygeodesy.isclose}, 

5L{pygeodesy.isfinite}, L{pygeodesy.isinf}, L{pygeodesy.isint0}, 

6L{pygeodesy.isnan}, L{pygeodesy.isnear0}, L{pygeodesy.isnear1}, 

7L{pygeodesy.isnear90}, L{pygeodesy.isneg0}, L{pygeodesy.isninf}, 

8L{pygeodesy.isnon0} and L{pygeodesy.remainder}. 

9''' 

10# make sure int/int division yields float quotient, see .basics 

11from __future__ import division as _; del _ # PYCHOK semicolon 

12 

13from pygeodesy.basics import _0_0, _copysign, isbool, iscomplex, \ 

14 isint, _ALL_LAZY 

15from pygeodesy.errors import _xError, _xError2, _xkwds_get 

16from pygeodesy.interns import _INF_, _NAN_, _UNDER_ 

17# from pygeodesy.lazily import _ALL_LAZY # from .basics 

18# from pygeodesy.streprs import Fmt # from .unitsBase 

19from pygeodesy.unitsBase import Float, Int, Radius, Fmt 

20 

21from math import fabs, isinf, isnan, pi as _PI, sqrt 

22try: 

23 from math import inf as _inf, nan as _nan # PYCHOK Python 3+ 

24except ImportError: # Python 2- 

25 _inf, _nan = float(_INF_), float(_NAN_) 

26 

27__all__ = _ALL_LAZY.constants 

28__version__ = '24.03.09' 

29 

30 

31def _copysign_0_0(y): 

32 '''(INTERNAL) copysign(0.0, y), only C{float}. 

33 ''' 

34 return _N_0_0 if y < 0 else _0_0 

35 

36 

37def _copysign_1_0(y): 

38 '''(INTERNAL) copysign(1.0, y), only C{float}. 

39 ''' 

40 return _N_1_0 if y < 0 else _1_0 

41 

42 

43def _copysignINF(y): 

44 '''(INTERNAL) copysign(INF, y), only C{float}. 

45 ''' 

46 return NINF if y < 0 else INF 

47 

48 

49def _Float(**name_arg): 

50 '''(INTERNAL) New named, cached C{Float}. 

51 ''' 

52 n, arg = name_arg.popitem() 

53 return Float(_float(arg), name=n) 

54 

55 

56def _Radius(**name_arg): 

57 '''(INTERNAL) New named, cached C{Radius}. 

58 ''' 

59 n, arg = name_arg.popitem() 

60 return Radius(_float(arg), name=n) 

61 

62 

63def float_(*fs, **sets): # sets=False 

64 '''Get scalars as C{float} or I{intern}'ed C{float}. 

65 

66 @arg fs: One more values (C{scalar}), all positional. 

67 @kwarg sets: Use C{B{sets}=True} to C{intern} each 

68 B{C{fs}}, otherwise don't C{intern}. 

69 

70 @return: A single C{float} if only one B{C{fs}} is 

71 given, otherwise a tuple of C{float}s. 

72 

73 @raise TypeError: Some B{C{fs}} is not C{scalar}. 

74 ''' 

75 fl = [] 

76 _a = fl.append 

77 _f = _floats.setdefault if _xkwds_get(sets, sets=False) else \ 

78 _floats.get 

79 try: 

80 for i, f in enumerate(fs): 

81 f = float(f) 

82 _a(_f(f, f)) 

83 except Exception as x: 

84 E, t = _xError2(x) 

85 fs_i = Fmt.SQUARE(fs=i) 

86 raise E(fs_i, f, txt=t) 

87 return fl[0] if len(fl) == 1 else tuple(fl) 

88 

89 

90def _float(f): # in .datums, .ellipsoids, ... 

91 '''(INTERNAL) Cache initial C{float}s. 

92 ''' 

93 f = float(f) 

94 return _floats.setdefault(f, f) # PYCHOK del _floats 

95 

96 

97def float0_(*xs): 

98 '''Yield C{B{x}s} as a non-NEG0 C{float}. 

99 ''' 

100 for x in xs: 

101 yield float(x) if x else _0_0 

102 

103 

104def _float0(f): # in .resections, .vector3dBase, ... 

105 '''(INTERNAL) Return C{float(B{f})} or C{INT0}. 

106 ''' 

107 if f: 

108 f = float(f) 

109 f = _floats.get(f, f) 

110 elif f is not INT0: 

111 f = float(f) or _0_0 # force None, NN error 

112 return f 

113 

114 

115def _floatuple(*fs): 

116 '''(INTERNAL) Cache a tuple of C{float}s. 

117 ''' 

118 return tuple(map(_float, fs)) 

119 

120 

121try: 

122 from math import log2 as _log2 

123except ImportError: # Python 3.3- 

124 from math import log as _log 

125 

126 def _log2(x): # in .rhumb.aux_, .auxilats.auxLat 

127 return _log(x, 2) 

128 

129 

130def _naninf(p, *xs): 

131 '''(INTERNAL) Return C{NAN}, C{NINF} or C{INF}. 

132 ''' 

133 for x in xs: 

134 p *= x # fmath.fprod(xs) 

135 return _copysignINF(p) if isfinite(p) else p 

136 

137 

138def _over(p, q): 

139 '''(INTERNAL) Return C{B{p} / B{q}} avoiding C{ZeroDivisionError} exceptions. 

140 ''' 

141 try: 

142 return (p / q) 

143 except ZeroDivisionError: 

144 return (_copysignINF(p) if isfinite(p) else NAN) if p else p 

145 

146 

147def _1_over(x): 

148 '''(INTERNAL) Return reciprocal C{1 / B{x}} avoiding C{ZeroDivisionError} exceptions. 

149 ''' 

150 try: 

151 return _1_0 / float(x) 

152 except ZeroDivisionError: 

153 return NINF if isneg0(x) else INF 

154 

155 

156_floats = {} # PYCHOK floats cache, in .__main__ 

157# _float = float # PYCHOK expected 

158# del _floats # XXX zap floats cache never 

159 

160_0_0 = _float( _0_0) # PYCHOK expected 

161_0_0_1T = _0_0, # PYCHOK 1-tuple 

162_0_0_9T = _0_0_1T * 9 # PYCHOK 9-tuple 

163_0_0001 = _float( 0.0001) # PYCHOK expected 

164_0_001 = _float( 0.001) # PYCHOK expected 

165_0_01 = _float( 0.01) # PYCHOK expected 

166_0_1 = _float( 0.1) # PYCHOK expected 

167_0_125 = _float( 0.125) # PYCHOK expected 

168_0_25 = _float( 0.25) # PYCHOK expected 

169_0_5 = _float( 0.5) # PYCHOK expected 

170_1_0 = _float( 1) # PYCHOK expected 

171_1_0_1T = _1_0, # PYCHOK 1-tuple 

172_1_5 = _float( 1.5) # PYCHOK expected 

173_1_75 = _float( 1.75) # PYCHOK expected 

174_2_0 = _float( 2) # PYCHOK expected 

175_3_0 = _float( 3) # PYCHOK expected 

176_4_0 = _float( 4) # PYCHOK expected 

177_5_0 = _float( 5) # PYCHOK expected 

178_6_0 = _float( 6) # PYCHOK expected 

179_8_0 = _float( 8) # PYCHOK expected 

180_9_0 = _float( 9) # PYCHOK expected 

181_10_0 = _float( 10) # PYCHOK expected 

182_16_0 = _float( 16) # PYCHOK expected 

183_32_0 = _float( 32) # PYCHOK expected 

184_60_0 = _float( 60) # PYCHOK expected 

185_90_0 = _float( 90) # PYCHOK expected 

186_100_0 = _float( 100) # PYCHOK expected 

187_180_0 = _float( 180) # PYCHOK expected 

188_270_0 = _float( 270) # PYCHOK expected 

189_360_0 = _float( 360) # PYCHOK expected 

190_400_0 = _float( 400) # PYCHOK expected 

191_720_0 = _float( 720) # PYCHOK expected 

192_1000_0 = _float(1000) # PYCHOK expected 

193_3600_0 = _float(3600) # PYCHOK expected 

194 

195_N_0_0 = float( '-0.0') # PYCHOK NOT _float! 

196_N_0_5 = _float( -_0_5) # PYCHOK expected 

197_N_1_0 = _float( -_1_0) # PYCHOK expected 

198_N_2_0 = _float( -_2_0) # PYCHOK expected 

199_N_90_0 = _float( -_90_0) # PYCHOK expected 

200_N_180_0 = _float(-_180_0) # PYCHOK expected 

201 

202_M_KM = _1000_0 # meter per Kilo meter, see .utily 

203_M_NM = _float(1852.0) # meter per Nautical Mile, exactly 

204_M_SM = _float(1609.344) # meter per Statute Mile 

205 

206try: 

207 from sys import float_info as _f_i 

208 # @see: <https://NumPy.org/doc/stable/reference/generated/numpy.finfo.html> 

209 DIG = Int( DIG =_f_i.dig) # PYCHOK system's float decimal digits 

210 EPS = _Float(EPS =_f_i.epsilon) # PYCHOK system's EPSilon 

211 MANT_DIG = Int( MANT_DIG=_f_i.mant_dig) # PYCHOK system's float mantissa bits 

212 MAX = _Float(MAX =_f_i.max) # PYCHOK system's MAX float 1.7976931348623157e+308 

213 MAX_EXP = Int( MAX_EXP =_f_i.max_exp) # PYTHON system's max base 2 exponent 

214 MIN = _Float(MIN =_f_i.min) # PYCHOK system's MIN float 2.2250738585072014e-308 

215 MIN_EXP = Int( MIN_EXP =_f_i.min_exp) # PYTHON system's min base 2 exponent 

216# RADIX = Int( RADIX =_f_i.radix) # PYTHON system's float base 

217 del _f_i 

218except ImportError: # PYCHOK no cover 

219 DIG = Int( DIG =15) # PYCHOK system's 64-bit float decimal digits 

220 EPS = _Float(EPS =2.220446049250313e-16) # PYCHOK EPSilon 2**-52, M{EPS +/- 1 != 1} 

221 MANT_DIG = Int( MANT_DIG=53) # PYCHOK float mantissa bits ≈ 53 (C{int}) 

222 MAX = _Float(MAX =pow(_2_0, 1023) * (_2_0 - EPS)) # PYCHOK ≈ 10**308 

223 MAX_EXP = Int( MAX_ESP =_log2(MAX)) # 308 base 10 

224 MIN = _Float(MIN =pow(_2_0, -1021)) # PYCHOK ≈ 10**-308 

225 MIN_EXP = Int(MIN_EXP =_log2(MIN)) # -307 base 10 

226# RADIX = Int(Radix =2) # base 

227 

228EPS0 = _Float( EPS0 = EPS**2) # PYCHOK near-/non-zero comparison 4.930381e-32, or EPS or EPS_2 

229EPS02 = _Float( EPS02 = EPS**4) # PYCHOK near-zero-squared comparison 2.430865e-63 

230EPS_2 = _Float( EPS_2 = EPS / _2_0) # PYCHOK ≈ 1.110223024625e-16 

231EPS1 = _Float( EPS1 =_1_0 - EPS) # PYCHOK ≈ 0.9999999999999998 

232EPS2 = _Float( EPS2 = EPS * _2_0) # PYCHOK ≈ 4.440892098501e-16 

233EPS4 = _Float( EPS4 = EPS * _4_0) # PYCHOK ≈ 8.881784197001e-16 

234# _1EPS = _Float(_1EPS =_1_0 + EPS) # PYCHOK ≈ 1.0000000000000002 

235_1_EPS = _Float(_1_EPS =_1_0 / EPS) # PYCHOK = 4503599627370496.0 

236# _2_EPS = _Float(_2_EPS =_2_0 / EPS) # PYCHOK = 9007199254740992.0 

237_EPS2e4 = _Float(_EPS2e4 = EPS2 * 1.e4) # PYCHOK ≈ 4.440892098501e-12 

238_EPS4e8 = _Float(_EPS4e8 = EPS4 * 1.e8) # PYCHOK ≈ 8.881784197001e-08 

239_EPSmin = _Float(_EPSmin = sqrt(MIN)) # PYCHOK = 1.49166814624e-154 

240_EPSqrt = _Float(_EPSqrt = sqrt(EPS)) # PYCHOK = 1.49011611938e5-08 

241_EPStol = _Float(_EPStol =_EPSqrt * _0_1) # PYCHOK = 1.49011611938e5-09 == sqrt(EPS * _0_01) 

242 

243_89_999_ = _Float(_89_999_= EPS1 * _90_0) # just below 90.0 

244# <https://Numbers.Computation.Free.FR/Constants/Miscellaneous/digits.html> 

245_1__90 = _Float(_1__90 =_1_0 / _90_0) # PYCHOK = 0.011_111_111_111_111_111_111_111_111_111_111_111_111_111_111_11111 

246_2__PI = _Float(_2__PI =_2_0 / _PI) # PYCHOK = 0.636_619_772_367_581_343_075_535_053_490_057_448_137_838_582_96182 

247 

248_1_16th = _Float(_1_16th =_1_0 / _16_0) # PYCHOK in .ellipsoids, .karney 

249_1_64th = _Float(_1_64th =_1_0 / 64) # PYCHOK in .elliptic, pow(2.0, -6) 

250_1_3rd = _Float(_1_3rd =_1_0 / _3_0) # PYCHOK in .fmath 

251_1_6th = _Float(_1_6th =_1_0 / _6_0) # PYCHOK in .fmath 

252_2_3rd = _Float(_2_3rd =_2_0 / _3_0) # PYCHOK in .fmath 

253 

254_K0_UTM = _Float(_K0_UTM = 0.9996) # PYCHOK in .etm, .ktm, .utm, UTM scale at central meridian 

255# sqrt(2) <https://WikiPedia.org/wiki/Square_root_of_2> 

256# 1.414213562373095_048_801_688_724_209_698_078_569_671_875_376_948_073_176_679_737_99 

257# _1SQRT2= _Float(_1SQRT2 =sqrt(_2_0) + 1) 

258_SQRT2_2 = _Float(_SQRT2_2=sqrt(_0_5)) # PYCHOK = 0.707106781186547_6 == sqrt(2) / 2 

259 

260INF = Float(INF =_inf) # PYCHOK INFinity, see function L{isinf}, L{isfinite}, NOT _Float! 

261INT0 = Int( INT0= 0) # PYCHOK unique int(0) instance, see .fsums, useZ=False 

262NAN = Float(NAN =_nan) # PYCHOK Not-A-Number, see function L{isnan}, NOT _Float! 

263NEG0 = Float(NEG0=_N_0_0) # PYCHOK NEGative 0.0, see function L{isneg0}, NOT _Float! 

264NINF = Float(NINF=-INF) # PYCHOK Negative INFinity, NOT _Float! 

265 

266PI = _Float(PI =_PI) # 3.1415_9265_3589_7932_3846_2643_3832_795 

267PI2 = _Float(PI2 =_PI * _2_0) # PYCHOK Two PI, M{PI * 2} aka I{Tau} 

268PI_2 = _Float(PI_2 =_PI / _2_0) # PYCHOK Half PI, M{PI / 2} 

269PI3 = _Float(PI3 =_PI * _3_0) # PYCHOK Three PI, M{PI * 3} 

270PI3_2 = _Float(PI3_2=_PI * _1_5) # PYCHOK PI and a half, M{PI * 3 / 2} 

271PI_3 = _Float(PI_3 =_PI / _3_0) # PYCHOK One third PI, M{PI / 3} 

272PI4 = _Float(PI4 =_PI * _4_0) # PYCHOK Four PI, M{PI * 4} 

273PI_4 = _Float(PI_4 =_PI / _4_0) # PYCHOK Quarter PI, M{PI / 4} 

274 

275R_MA = _Radius(R_MA=6378137.0) # PYCHOK equatorial earth radius (C{meter}), WGS84, EPSG:3785 

276R_MB = _Radius(R_MB=6356752.3) # PYCHOK polar earth radius (C{meter}), WGS84, EPSG:3785 

277R_M = _Radius(R_M =6371008.771415) # PYCHOK mean, spherical earth radius (C{meter}) 

278R_KM = _Radius(R_KM=R_M / _M_KM) # PYCHOK mean, spherical earth radius (C{KM}, Kilo meter) 

279R_NM = _Radius(R_NM=R_M / _M_NM) # PYCHOK mean, spherical earth radius (C{NM}, nautical miles) 

280R_SM = _Radius(R_SM=R_M / _M_SM) # PYCHOK mean, spherical earth radius (C{SM}, statute miles) 

281# See <https://www.EdWilliams.org/avform.htm>, <https://www.DTIC.mil/dtic/tr/fulltext/u2/a216843.pdf> 

282# and <https://GitHub.com/NASA/MultiDop/blob/master/src/share/man/man3/geog_lib.3> based on the 

283# International Standard Nautical Mile of 1,852 meter (1' latitude) 

284R_FM = _Radius(R_FM=6371000.0) # PYCHOK former FAI Sphere earth radius (C{meter}) 

285R_GM = _Radius(R_GM=6371230.0) # PYCHOK avg. radius, distance to geoid surface (C{meter}) 

286# <http://Wiki.GIS.com/wiki/index.php/Ellipsoidal_quadratic_mean_radius> 

287R_QM = _Radius(R_QM=6372797.560856) # PYCHOK earth' quadratic mean radius (C{meter}) 

288# Rtri= _Radius(Rtri=6372797.5559594) # PYCHOK Rtriaxial quadratic mean radius (C{meter}), WGS84 

289# Rbi = _Radius(Rbi =6367453.6345163) # PYCHOK Rbiaxial quadratic mean radius (C{meter}), WGS84 

290R_VM = _Radius(R_VM=6366707.0194937) # PYCHOK aViation/naVigation earth radius (C{meter}) 

291# R_AU= Meter( R_AU=149597870700.0) # PYCHOK <https://WikiPedia.org/wiki/Astronomical_unit> 

292 

293_INF_NAN_NINF = INF, NAN, NINF 

294_pos_self = _1_0.__pos__() is _1_0 # PYCHOK in .fsums, .vector3dBase 

295 

296 

297def _0_0s(n): 

298 '''(INTERNAL) Return an C{B{n}-tuple} of C{_0_0} zeros. 

299 ''' 

300 return _0_0_9T[:n] if 0 <= n <= len(_0_0_9T) else (_0_0_1T * n) 

301 

302 

303try: 

304 from math import isclose as _isclose 

305except ImportError: # Python 3.4- 

306 

307 def _isclose(a, b, rel_tol=1e-9, abs_tol=0): 

308 '''Mimick Python 3.5+ C{math.isclose}. 

309 ''' 

310 t, d = abs_tol, fabs(a - b) 

311 if d > t: 

312 r = max(fabs(a), fabs(b)) * rel_tol 

313 t = max(r, t) 

314 return d <= t 

315 

316 

317def isclose(a, b, rel_tol=1e-12, abs_tol=EPS0): 

318 '''Like C{math.isclose}, but with defaults such 

319 that C{isclose(0, EPS0)} is C{True} by default. 

320 ''' 

321 return _isclose(a, b, rel_tol=rel_tol, abs_tol=abs_tol) 

322 

323 

324try: 

325 from math import isfinite as _isfinite # in .ellipsoids, ... 

326except ImportError: # Python 3.1- 

327 

328 def _isfinite(x): 

329 '''Mimick Python 3.2+ C{math.isfinite}. 

330 ''' 

331 return not (isinf(x) or isnan(x)) 

332 

333 

334def isfinite(obj): 

335 '''Check a finite C{scalar} or C{complex} value. 

336 

337 @arg obj: Value (C{scalar} or C{complex}). 

338 

339 @return: C{False} if B{C{obj}} is C{INF}, C{NINF} 

340 or C{NAN}, C{True} otherwise. 

341 

342 @raise TypeError: Non-scalar and non-complex B{C{obj}}. 

343 ''' 

344 try: 

345 return (obj not in _INF_NAN_NINF) and _isfinite(obj) 

346 except Exception as x: 

347 if iscomplex(obj): # _isfinite(complex) thows TypeError 

348 return isfinite(obj.real) and isfinite(obj.imag) 

349 raise _xError(x, Fmt.PAREN(isfinite.__name__, obj)) 

350 

351 

352def isint0(obj, both=False): 

353 '''Check for L{INT0} or C{int(0)} value. 

354 

355 @arg obj: The object (any C{type}). 

356 @kwarg both: If C{true}, also check C{float(0)} (C{bool}). 

357 

358 @return: C{True} if B{C{obj}} is L{INT0}, C{int(0)} or 

359 C{float(0)}, C{False} otherwise. 

360 ''' 

361 return (obj is INT0 or obj is int(0) or bool(both and 

362 (not obj) and isint(obj, both=True))) and not isbool(obj) 

363 

364 

365def isnear0(x, eps0=EPS0): 

366 '''Is B{C{x}} near I{zero} within a tolerance? 

367 

368 @arg x: Value (C{scalar}). 

369 @kwarg eps0: Near-I{zero} tolerance (C{EPS0}). 

370 

371 @return: C{True} if C{abs(B{x}) < B{eps0}}, 

372 C{False} otherwise. 

373 

374 @see: Function L{isnon0}. 

375 ''' 

376 return bool(eps0 > x > -eps0) 

377 

378 

379def isnear1(x, eps1=EPS0): 

380 '''Is B{C{x}} near I{one} within a tolerance? 

381 

382 @arg x: Value (C{scalar}). 

383 @kwarg eps1: Near-I{one} tolerance (C{EPS0}). 

384 

385 @return: C{isnear0(B{x} - 1, eps0=B{eps1})}. 

386 

387 @see: Function L{isnear0}. 

388 ''' 

389 return bool(eps1 > (x - _1_0) > -eps1) 

390 

391 

392def isnear90(x, eps90=EPS0): 

393 '''Is B{C{x}} near I{90} within a tolerance? 

394 

395 @arg x: Value (C{scalar}). 

396 @kwarg eps90: Near-I{90} tolerance (C{EPS0}). 

397 

398 @return: C{isnear0(B{x} - 90, eps0=eps90)}. 

399 

400 @see: Function L{isnear0}. 

401 ''' 

402 return bool(eps90 > (x - _90_0) > -eps90) 

403 

404 

405def isneg0(x): 

406 '''Check for L{NEG0}, negative C{0.0}. 

407 

408 @arg x: Value (C{scalar}). 

409 

410 @return: C{True} if B{C{x}} is C{NEG0} or C{-0.0}, 

411 C{False} otherwise. 

412 ''' 

413 return (not x) and _copysign(1, x) < 0 

414# and str(x).startswith(_MINUS_) 

415 

416 

417def isninf(x): 

418 '''Check for L{NINF}, negative C{INF}. 

419 

420 @arg x: Value (C{scalar}). 

421 

422 @return: C{True} if B{C{x}} is C{NINF} or C{-inf}, 

423 C{False} otherwise. 

424 ''' 

425 return x is NINF or (x < 0 and not isfinite(x)) 

426 

427 

428def isnon0(x, eps0=EPS0): 

429 '''Is B{C{x}} non-zero with a tolerance? 

430 

431 @arg x: Value (C{scalar}). 

432 @kwarg eps0: Non-zero tolerance (C{EPS0}). 

433 

434 @return: C{True} if C{abs(B{x}) > B{eps0}}, 

435 C{False} otherwise. 

436 

437 @see: Function L{isnear0}. 

438 ''' 

439 return not bool(eps0 > x > -eps0) # not isnear0 

440 

441 

442def _off90(lat): 

443 '''(INTERNAL) Off 90.0 for .gars and .wgrs. 

444 ''' 

445 return max(min(lat, _89_999_), -_89_999_) 

446 

447 

448try: 

449 from math import remainder 

450except ImportError: # Python 3.6- 

451 from math import fmod as _fmod 

452 

453 def remainder(x, y): 

454 '''Mimick Python 3.7+ C{math.remainder}. 

455 ''' 

456 if isnan(y): 

457 x = NAN 

458 elif x and not isnan(x): 

459 y = fabs(y) 

460 x = _fmod(x, y) 

461 h = _0_5 * y 

462 if x >= h: 

463 x -= y 

464 elif x < -h: 

465 x += y 

466 return x # keep signed 0.0 

467 

468 

469def _umod_360(deg): 

470 '''(INTERNAL) Non-negative C{deg} modulo 360, basic C{.utily.wrap360}. 

471 ''' 

472 return (deg % _360_0) or _0_0 

473 

474 

475def _umod_PI2(rad): 

476 '''(INTERNAL) Non-negative C{rad} modulo PI2, basic C{.utily.wrapPI2}. 

477 ''' 

478 return (rad % PI2) or _0_0 

479 

480 

481if __name__ == '__main__': 

482 

483 from pygeodesy import itemsorted, printf 

484 

485 t = n = v = [] 

486 for n, v in itemsorted(locals()): 

487 if isinstance(v, (Float, Int, Radius)): 

488 printf('%9s: %r', n, v.toRepr(std=False)) 

489 if v.name != n: 

490 raise AssertionError('%r != %r' % (n, v)) 

491 if v.name is not n: 

492 raise AssertionError('%r is not %r' % (n, v)) 

493 if not n.startswith(_UNDER_): 

494 t.append(n) 

495 t.append(float_.__name__) 

496 printf('__all__ = %r', tuple(t)) 

497 

498# **) MIT License 

499# 

500# Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved. 

501# 

502# Permission is hereby granted, free of charge, to any person obtaining a 

503# copy of this software and associated documentation files (the "Software"), 

504# to deal in the Software without restriction, including without limitation 

505# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

506# and/or sell copies of the Software, and to permit persons to whom the 

507# Software is furnished to do so, subject to the following conditions: 

508# 

509# The above copyright notice and this permission notice shall be included 

510# in all copies or substantial portions of the Software. 

511# 

512# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

513# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

514# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

515# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

516# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

517# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

518# OTHER DEALINGS IN THE SOFTWARE.