Coverage for pygeodesy/lazily.py: 96%
202 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-25 13:15 -0400
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-25 13:15 -0400
2# -*- coding: utf-8 -*-
4u'''Lazily import C{pygeodesy} modules and attributes, based on
5U{lazy_import<https://modutil.ReadTheDocs.io/en/latest/#lazy_import>}
6from I{Brett Cannon}'s U{modutil<https://PyPI.org/project/modutil>}.
8C{Lazy import} is I{supported only for }U{Python 3.7+
9<https://Snarky.Ca/lazy-importing-in-python-3-7>} and is I{enabled by
10default} in U{PyGeodesy 18.11.10<https://PyPI.org/project/PyGeodesy>}
11I{and newer}.
13To I{enable} C{lazy import}, set C{env} variable C{PYGEODESY_LAZY_IMPORT}
14to C{1}, C{2}, C{3} or higher prior to C{import pygeodesy}. To I{disable}
15C{lazy import}, set C{env} variable C{PYGEODESY_LAZY_IMPORT} to C{0} or
16an empty string. Use C{2} or higher to print a message for each lazily
17imported module and attribute, similar to C{env} variable C{PYTHONVERBOSE}
18showing imports. Using C{3} or higher also shows the importing file name
19and line number.
21@note: C{Lazy import} applies only to top-level modules of C{pygeodesy}.
22 The C{lazy import} of a top-level module invariably loads all
23 sub-modules imported by that top-level module.
25@note: C{Lazy import} raises a L{LazyAttributeError} or L{LazyImportError}
26 depending on the cause of the error and such errors can occur late,
27 after all initial imports.
28'''
30from pygeodesy import internals as _internals, interns as _interns, \
31 _isfrozen # DON'T _lazy_import2
32# from pygeodesy.errors import _error_init, _xkwds_item2 # _ALL_MODS
33from pygeodesy.internals import _caller3, _envPYGEODESY, _headof, printf, _tailof, \
34 typename, _versions # _getenv, _PYGEODESY_ENV, \
35# _MODS_Base, _MODS.sys_version_info2
36from pygeodesy.interns import _attribute_, _by_, _COLONSPACE_, _COMMASPACE_, _DALL_, \
37 _DMAIN_, _doesn_t_exist_, _DOT_, _EQUALSPACED_, _from_, \
38 _immutable_, _line_, _module_, NN, _no_, _not_, _or_, \
39 _pygeodesy_, _pygeodesy_abspath_, _SPACE_, _SUB_PACKAGES, \
40 _UNDER_, _version_, _sys, _intern # function, _1_, _HASH_
41try:
42 from importlib import import_module
43except ImportError as x: # Python 2.6-
44 raise ImportError(_COLONSPACE_(x, _versions()))
45# import sys as _sys # from .interns
47_a0 = () # PYCHOK empty tuple
48_asSPACED_ = ' as '
49_FOR_DOCS = _envPYGEODESY('FOR_DOCS') # for epydoc ...
50_init__all__ = _FOR_DOCS or _envPYGEODESY('_init__all__', _DALL_) == _DALL_ # PYCHOK exported
51_lazily_ = 'lazily'
52_PYTHON_X_DEV = getattr(_sys.flags, 'dev_mode', False) # PYCHOK Python 3.2+
53_unlazy = _unLazy0 = _isfrozen or _internals._MODS.sys_version_info2 < (3, 7) # PYCHOK mod.__getattr__ 3.7+
54_WARNINGS_X_DEV = _envPYGEODESY('WARNINGS') and (_PYTHON_X_DEV or bool(_sys.warnoptions)) # PYCHOK .props
56# @module_property[_RO?] <https://GitHub.com/jtushman/proxy_tools/> <https://discuss.Python.org/t/47379>
57isLazy = None # see @var isLazy in .__init__
60class LazyAttributeError(AttributeError):
61 '''Raised if a C{lazily imported} attribute is missing or invalid.
62 '''
63 def __init__(self, *args, **kwds):
64 _ALL_MODS.errors._error_init(AttributeError, self, args, **kwds)
67class LazyImportError(ImportError):
68 '''Raised if C{lazy import} is not supported, disabled or failed.
69 '''
70 def __init__(self, *args, **kwds):
71 _ALL_MODS.errors._error_init(ImportError, self, args, **kwds)
74class _Dict(dict):
75 '''(INTERNAL) Imports C{dict}.
76 '''
77 _name = NN
79 def __getattr__(self, attr):
80 try:
81 return self[attr]
82 except KeyError:
83 return dict.__getattr__(self, attr)
85# def __setattr__(self, attr, value):
86# if attr in self:
87# self[attr] = value
88# else:
89# dict.__setattr__(self, attr, value)
91 def add(self, name, mod_, *subs):
92 '''Add a C{[name] = mod_} item.
94 @raise AssertionError: The B{C{name}} already exists
95 with a different B{C{mod_}}.
96 '''
97 try:
98 sub = self[name] # duplicate OK
99 if sub != mod_ and sub not in subs:
100 t = _DOT_(self._name, name)
101 t = _COLONSPACE_(t, repr(sub))
102 t = _COMMASPACE_(t, _not_(repr(mod_)))
103 raise AssertionError(t)
104 except KeyError:
105 self[name] = mod_
107 def _NAME(self, which):
108 self._name = _intern(typename(which).upper())
111class _NamedEnum_RO(dict):
112 '''(INTERNAL) C{Read_Only} enum-like C{dict} sub-class.
113 '''
114# _name = NN # also first kwd, __init__(_name=...)
116 def _DOT_(self, attr): # PYCHOK no cover
117 return _DOT_(self._name, attr) # PYCHOK _name
119 def __getattr__(self, attr):
120 try:
121 return self[attr]
122 except KeyError:
123 t = self._DOT_(attr)
124 raise LazyAttributeError(t, txt=_doesn_t_exist_)
126 def __setattr__(self, attr, value): # PYCHOK no cover
127 t = _EQUALSPACED_(self._DOT_(attr), repr(value))
128 raise LazyAttributeError(_immutable_, txt=t)
130 def enums(self):
131 # Yield all C{(mod_, tuple)} pairs
132 for m, t in dict.items(self):
133 n = m.replace(_UNDER_, _DOT_)
134 if n != m:
135 if m.startswith(_UNDER_):
136 continue # skip _name= ...
137 u = m.rstrip(_UNDER_)
138 if u != m:
139 u = len(u)
140 n = n[:u] + m[u:]
141 yield n, t
143 def fill_D(self, _D, which):
144 # Fill C{_Dict _D}.
145 _D._NAME(which)
146 _a = _D.add
147 for m, t in self.enums():
148 _a(m, _DOT_(m, NN, NN)) # import module
149 for a in t:
150 a, _, as_ = a.partition(_asSPACED_)
151 if as_: # import attr as attr_
152 _a(as_, _DOT_(m, a, NN), *_SUB_PACKAGES)
153 else:
154 _a(a, m)
155 return _D
158def _a(*names):
159 '''(INTERNAL) Intern all C{names}.
160 '''
161 return tuple(map(_intern, names)) if names else _a0
164def _ALL_ATTRS(*attrs):
165 '''(INTERNAL) Unravel all exported module attributes.
166 '''
167 t = ()
168 for attr in attrs:
169 t += tuple(map(_getattras, attr))
170 return t
173_ALL_INIT = _a(_pygeodesy_abspath_, _version_)
175# __all__ value for most modules, accessible as _ALL_LAZY.<module>
176_ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
177 albers=_a('AlbersEqualArea', 'AlbersEqualArea2', 'AlbersEqualArea4',
178 'AlbersEqualAreaCylindrical', 'AlbersEqualAreaNorth', 'AlbersEqualAreaSouth',
179 'AlbersError', 'Albers7Tuple'),
180 auxilats=_a(), # module only
181 azimuthal=_a('AzimuthalError', 'Azimuthal7Tuple',
182 'Equidistant', 'EquidistantExact', 'EquidistantGeodSolve', 'EquidistantKarney',
183 'Gnomonic', 'GnomonicExact', 'GnomonicGeodSolve', 'GnomonicKarney',
184 'LambertEqualArea', 'Orthographic', 'Stereographic',
185 'equidistant', 'gnomonic'),
186 basics=_a('clips', 'copysign0', 'copytype', 'halfs2',
187 'int1s', 'isbool', 'isCartesian', 'isclass', 'iscomplex', 'isDEPRECATED', 'isfloat',
188 'isidentifier', 'isinstanceof', 'isint', 'isiterable', 'isiterablen', 'isiterabletype',
189 'iskeyword', 'isLatLon', 'islistuple', 'isNvector', 'isodd',
190 'isscalar', 'issequence', 'isstr', 'issubclassof', 'itemsorted',
191 'len2', 'map1', 'map2', 'max2', 'min2', 'neg', 'neg_',
192 'signBit', 'signOf', 'splice', 'str2ub', 'ub2str', 'unsigned0'),
193 booleans=_a('BooleanFHP', 'BooleanGH', 'LatLonFHP', 'LatLonGH',
194 'isBoolean'),
195 cartesianBase=_a('RadiusThetaPhi3Tuple', 'rtp2xyz', 'rtp2xyz_', 'xyz2rtp', 'xyz2rtp_'),
196 clipy=_a('ClipCS4Tuple', 'ClipFHP4Tuple', 'ClipGH4Tuple', 'ClipLB6Tuple', 'ClipSH3Tuple',
197 'clipCS4', 'clipFHP4', 'clipGH4', 'clipLB6', 'clipSH', 'clipSH3'),
198 css=_a('CassiniSoldner', 'Css', 'CSSError', 'toCss',
199 'EasNorAziRk4Tuple', 'EasNorAziRkEqu6Tuple', 'LatLonAziRk4Tuple'),
200 constants=_a('DIG', 'EPS', 'EPS0', 'EPS02', 'EPS1', 'EPS2', 'EPS4', 'EPS_2',
201 'INF', 'INT0', 'MANT_DIG', 'MAX', 'MAX_EXP', 'MIN', 'MIN_EXP', 'NAN', 'NEG0', 'NINF',
202 'PI', 'PI2', 'PI_2', 'PI3', 'PI_3', 'PI3_2', 'PI4', 'PI_4',
203 'R_FM', 'R_GM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_QM', 'R_SM', 'R_VM',
204 'float_', 'float0_', 'isclose', 'isfinite', 'isinf', 'isint0',
205 'isnan', 'isnear0', 'isnear1', 'isnear90', 'isneg0', 'isninf', 'isnon0',
206 'remainder'),
207 datums=_a('Datum', 'Datums', 'Transform', 'Transforms'),
208# deprecated=_a(), # module only
209 dms=_a('F_D', 'F_DM', 'F_DMS', 'F_DEG', 'F_MIN', 'F_SEC', 'F_D60', 'F__E', 'F__F', 'F__G', 'F_RAD',
210 'F_D_', 'F_DM_', 'F_DMS_', 'F_DEG_', 'F_MIN_', 'F_SEC_', 'F_D60_', 'F__E_', 'F__F_', 'F__G_', 'F_RAD_',
211 'F_D__', 'F_DM__', 'F_DMS__', 'F_DEG__', 'F_MIN__', 'F_SEC__', 'F_D60__', 'F__E__', 'F__F__', 'F__G__', 'F_RAD__',
212 'S_DEG', 'S_MIN', 'S_SEC', 'S_DMS', 'S_RAD', 'S_SEP',
213 'bearingDMS', 'clipDegrees', 'clipRadians', 'compassDMS', 'compassPoint',
214 'degDMS', 'latDMS', 'latlonDMS', 'latlonDMS_', 'lonDMS', 'normDMS',
215 'parseDDDMMSS', 'parseDMS', 'parseDMS2', 'parse3llh', 'parseRad', 'precision', 'toDMS'),
216 ecef=_a('EcefError', 'EcefFarrell21', 'EcefFarrell22', 'EcefKarney', 'EcefMatrix',
217 'EcefSudano', 'Ecef9Tuple', 'EcefVeness', 'EcefYou'),
218 elevations=_a('Elevation2Tuple', 'GeoidHeight2Tuple',
219 'elevation2', 'geoidHeight2'),
220 ellipsoidalBase=_a(), # module only
221 ellipsoidalBaseDI=_a(), # module only
222 ellipsoidalExact=_a(), # module only
223 ellipsoidalGeodSolve=_a(), # module only
224 ellipsoidalKarney=_a(), # module only
225 ellipsoidalNvector=_a(), # module only
226 ellipsoidalVincenty=_a('VincentyError',), # nothing else
227 ellipsoids=_a('a_f2Tuple', 'Circle4Tuple', 'Curvature2Tuple',
228 'Ellipsoid', 'Ellipsoid2', 'Ellipsoids',
229 'a_b2e', 'a_b2e2', 'a_b2e22', 'a_b2e32', 'a_b2f', 'a_b2f_', 'a_b2f2', 'a_b2n',
230 'a_f2b', 'a_f_2b', 'b_f2a', 'b_f_2a',
231 'e2f', 'e22f',
232 'f2e2', 'f2e22', 'f2e32', 'f_2f', 'f2f_', 'f2f2', 'f2n', 'n2e2', 'n2f', 'n2f_'),
233 elliptic=_a('Elliptic', 'EllipticError', 'Elliptic3Tuple'),
234 epsg=_a('Epsg', 'EPSGError'),
235 errors=_a('AuxError', 'ClipError', 'CrossError', 'GeodesicError', 'IntersectionError',
236 'NumPyError', 'LenError', 'LimitError', 'MGRSError',
237 'ParseError', 'PointsError', 'RangeError', 'RhumbError',
238 'SciPyError', 'SciPyWarning', 'TRFError', 'TriangleError', 'UnitError', 'VectorError',
239 'crosserrors', 'exception_chaining', 'isError', 'limiterrors', 'rangerrors'),
240 etm=_a('Etm', 'ETMError', 'ExactTransverseMercator',
241 'parseETM5', 'toEtm8'),
242 fmath=_a('Fdot', 'Fhorner', 'Fhypot', 'Fpolynomial', 'Fpowers', 'Fcbrt', 'Froot', 'Fsqrt',
243 'bqrt', 'cbrt', 'cbrt2', 'euclid', 'euclid_',
244 'facos1', 'fasin1', 'fatan', 'fatan1', 'fatan2', 'favg',
245 'fdot', 'fdot_', 'fdot3', 'fma', 'fmean', 'fmean_', 'fhorner', 'fidw', 'f2mul_',
246 'fpolynomial', 'fpowers', 'fprod', 'frandoms', 'frange', 'freduce', 'fremainder',
247 'hypot', 'hypot_', 'hypot1', 'hypot2', 'hypot2_',
248 'norm2', 'norm_', 'sqrt0', 'sqrt3', 'sqrt_a', 'zcrt', 'zqrt'),
249 formy=_a('Radical2Tuple',
250 'angle2chord', 'antipode', 'antipode_', 'bearing', 'bearing_',
251 'chord2angle', 'compassAngle', 'cosineLaw', 'cosineLaw_',
252 'equirectangular', 'equirectangular4', 'euclidean', 'euclidean_',
253 'excessAbc_', 'excessCagnoli_', 'excessGirard_', 'excessLHuilier_',
254 'excessKarney', 'excessKarney_', 'excessQuad', 'excessQuad_',
255 'flatLocal', 'flatLocal_', 'flatPolar', 'flatPolar_',
256 'hartzell', 'haversine', 'haversine_', 'heightOf', 'heightOrthometric', 'horizon', 'hubeny', 'hubeny_',
257 'intersection2', 'intersections2', 'isantipode', 'isantipode_', 'isnormal', 'isnormal_',
258 'normal', 'normal_', 'opposing', 'opposing_', 'radical2',
259 'thomas', 'thomas_', 'vincentys', 'vincentys_'),
260 frechet=_a('Frechet', 'FrechetDegrees', 'FrechetError', 'FrechetRadians', 'FrechetCosineLaw',
261 'FrechetDistanceTo', 'FrechetEquirectangular', 'FrechetEuclidean', 'FrechetExact',
262 'FrechetFlatLocal', 'FrechetFlatPolar', 'FrechetHaversine', 'FrechetHubeny', 'FrechetKarney',
263 'FrechetThomas', 'FrechetVincentys', 'Frechet6Tuple',
264 'frechet_'),
265 fstats=_a('Fcook', 'Flinear', 'Fwelford'),
266 fsums=_a('Fsum', 'DivMod2Tuple', 'Fsum2Tuple', 'ResidualError',
267 'f2product', 'fsum', 'fsum_', 'fsumf_', 'fsum1', 'fsum1_', 'fsum1f_', 'nonfiniterrors'),
268 gars=_a('Garef', 'GARSError'),
269 geodesici=_a('Intersectool', 'Intersectool5Tuple', 'Intersect7Tuple',
270 'Intersector', 'Intersector5Tuple', 'Middle5Tuple', 'XDict'),
271 geodesicw=_a('Geodesic', 'GeodesicLine', 'Geodesic_WGS84'),
272 geodesicx=_a('gx', 'gxarea', 'gxbases', 'gxline', # modules
273 'GeodesicAreaExact', 'GeodesicExact', 'GeodesicLineExact', 'PolygonArea'),
274 geodsolve=_a('GeodesicSolve', 'GeodesicLineSolve', 'GeodSolve12Tuple'),
275 geohash=_a('Geohash', 'Geohashed', 'GeohashError', 'Neighbors8Dict', 'Resolutions2Tuple', 'Sizes3Tuple'),
276 geoids=_a('GeoidError', 'GeoidEGM96', 'GeoidG2012B', 'GeoidKarney', 'GeoidPGM', 'egmGeoidHeights',
277 'PGMError', 'GeoidHeight5Tuple'),
278 hausdorff=_a('Hausdorff', 'HausdorffDegrees', 'HausdorffError', 'HausdorffRadians', 'HausdorffCosineLaw',
279 'HausdorffDistanceTo', 'HausdorffEquirectangular', 'HausdorffEuclidean', 'HausdorffExact',
280 'HausdorffFlatLocal', 'HausdorffFlatPolar', 'HausdorffHaversine', 'HausdorffHubeny',
281 'HausdorffKarney', 'HausdorffThomas', 'HausdorffVincentys', 'Hausdorff6Tuple',
282 'hausdorff_', 'randomrangenerator'),
283 heights=_a('HeightCubic', 'HeightError', 'HeightIDWcosineLaw', 'HeightIDWdistanceTo',
284 'HeightIDWequirectangular', 'HeightIDWeuclidean', 'HeightIDWexact', 'HeightIDWflatLocal',
285 'HeightIDWflatPolar', 'HeightIDWhaversine', 'HeightIDWhubeny', 'HeightIDWkarney', 'HeightIDWthomas',
286 'HeightIDWvincentys', 'HeightLinear', 'HeightLSQBiSpline', 'HeightSmoothBiSpline'),
287 internals=_internals.__all__,
288 interns=_interns.__all__,
289 iters=_a('LatLon2PsxyIter', 'PointsIter', 'points2',
290 'isNumpy2', 'isPoints2', 'isTuple2', 'iterNumpy2', 'iterNumpy2over'),
291 karney=_a('Area3Tuple', 'Caps', 'Direct9Tuple', 'GDict', 'Inverse10Tuple', 'Rhumb8Tuple'),
292 ktm=_a('KTMError', 'KTransverseMercator'),
293 latlonBase=_a('latlon2n_xyz', 'philam2n_xyz'),
294 lazily=_a('LazyAttributeError', 'LazyImportError', 'isLazy'),
295 lcc=_a('Conic', 'Conics', 'Lcc', 'LCCError', 'toLcc'),
296 ltp=_a('Attitude', 'AttitudeError', 'ChLV', 'ChLVa', 'ChLVe', 'Frustum',
297 'LocalCartesian', 'LocalError', 'Ltp', 'tyr3d'),
298 ltpTuples=_a('Aer', 'Aer4Tuple', 'Attitude4Tuple',
299 'ChLVEN2Tuple', 'ChLV9Tuple', 'ChLVYX2Tuple', 'ChLVyx2Tuple',
300 'Enu', 'Enu4Tuple', 'Footprint5Tuple', 'Local9Tuple', 'Los',
301 'Ned', 'Ned4Tuple', 'Uvw', 'Uvw3Tuple', 'XyzLocal', 'Xyz4Tuple'),
302 mgrs=_a('Mgrs', 'parseMGRS', 'toMgrs', 'Mgrs4Tuple', 'Mgrs6Tuple'),
303 named=_a('ADict',
304 'callername', 'classname', 'classnaming', 'modulename',
305 'nameof', 'notImplemented', 'notOverloaded'),
306 namedTuples=_a('Bearing2Tuple', 'Bounds2Tuple', 'Bounds4Tuple',
307 'Destination2Tuple', 'Destination3Tuple',
308 'Distance2Tuple', 'Distance3Tuple', 'Distance4Tuple',
309 'EasNor2Tuple', 'EasNor3Tuple', 'Forward4Tuple', 'Intersection3Tuple',
310 'LatLon2Tuple', 'LatLon3Tuple', 'LatLon4Tuple',
311 'LatLonDatum3Tuple', 'LatLonDatum5Tuple',
312 'LatLonPrec3Tuple', 'LatLonPrec5Tuple',
313 'NearestOn2Tuple', 'NearestOn3Tuple', 'NearestOn6Tuple', 'NearestOn8Tuple',
314 'PhiLam2Tuple', 'PhiLam3Tuple', 'PhiLam4Tuple', 'Point3Tuple', 'Points2Tuple',
315 'Reverse4Tuple', 'Triangle7Tuple', 'Triangle8Tuple', 'Trilaterate5Tuple',
316 'UtmUps2Tuple', 'UtmUps5Tuple', 'UtmUps8Tuple', 'UtmUpsLatLon5Tuple',
317 'Vector2Tuple', 'Vector3Tuple', 'Vector4Tuple'),
318 nvectorBase=_a('NorthPole', 'SouthPole', 'n_xyz2latlon', 'n_xyz2philam'),
319 osgr=_a('Osgr', 'OSGRError', 'parseOSGR', 'toOsgr'),
320 points=_a('LatLon_', 'LatLon2psxy', 'Numpy2LatLon', 'Shape2Tuple', 'Tuple2LatLon',
321 'areaOf', 'boundsOf', 'centroidOf', 'fractional',
322 'isclockwise', 'isconvex', 'isconvex_', 'isenclosedBy', 'ispolar',
323 'luneOf', 'nearestOn5', 'perimeterOf', 'quadOf'),
324 props=_a('Property', 'Property_RO', 'property_doc_',
325 'property_RO', 'property_ROnce', 'property_ROver',
326 'deprecated_class', 'deprecated_function', 'deprecated_method',
327 'deprecated_Property_RO', 'deprecated_property_RO', 'DeprecationWarnings'),
328 resections=_a('Collins5Tuple', 'ResectionError', 'Survey3Tuple', 'Tienstra7Tuple',
329 'TriAngle5Tuple', 'TriSide2Tuple', 'TriSide4Tuple',
330 'cassini', 'collins5', 'pierlot', 'pierlotx', 'tienstra7',
331 'snellius3', 'wildberger3',
332 'triAngle', 'triAngle5', 'triArea', 'triSide', 'triSide2', 'triSide4'),
333 rhumb=_a(), # module only
334 rhumb_aux_=_a('RhumbAux', 'RhumbLineAux'),
335 rhumb_ekx=_a('Rhumb', 'RhumbLine'),
336 rhumb_solve=_a('RhumbSolve', 'RhumbLineSolve', 'RhumbSolve7Tuple'),
337 sphericalBase=_a(), # module only
338 sphericalNvector=_a(), # module only
339 sphericalTrigonometry=_a(), # module only
340 simplify=_a('simplify1', 'simplifyRDP', 'simplifyRW', 'simplifyVW'),
341 solveBase=_a(), # module only
342 streprs=_a('anstr', 'attrs', 'enstr2', 'fstr', 'fstrzs', 'hstr', 'instr',
343 'lrstrip', 'pairs', 'reprs', 'strs', 'unstr'),
344 trf=_a('RefFrame', 'RefFrames', 'TransformXform', 'TRFXform', 'TRFXform7Tuple',
345 'date2epoch', 'epoch2date', 'trfTransform0', 'trfTransforms', 'trfXform'),
346 triaxials=_a('BetaOmega2Tuple', 'BetaOmega3Tuple', 'Jacobi2Tuple',
347 'JacobiConformal', 'JacobiConformalSpherical',
348 'Triaxial', 'Triaxial_', 'TriaxialError', 'Triaxials', 'hartzell4'),
349 units=_a('Azimuth', 'Band', 'Bearing', 'Bearing_', 'Bool',
350 'Degrees', 'Degrees_', 'Degrees2', 'Distance', 'Distance_', 'Easting', 'Epoch',
351 'Feet', 'FIx', 'Float_', 'Height', 'Height_', 'HeightX', 'Int_',
352 'Lam', 'Lamd', 'Lat', 'Lat_', 'Lon', 'Lon_',
353 'Meter', 'Meter_', 'Meter2', 'Meter3', 'Northing', 'Number_',
354 'Phi', 'Phid', 'Precision_', 'Radians', 'Radians_', 'Radians2',
355 'Radius_', 'Scalar', 'Scalar_', 'Zone'),
356 unitsBase=_a('Float', 'Int', 'Radius', 'Str'),
357 ups=_a('Ups', 'UPSError', 'parseUPS5', 'toUps8', 'upsZoneBand5'),
358 utily=_a('acos1', 'acre2ha', 'acre2m2', 'asin1', 'atan1', 'atan1d', 'atan2', 'atan2b', 'atan2d',
359 'chain2m', 'circle4', 'cot', 'cot_', 'cotd', 'cotd_',
360 'degrees', 'degrees90', 'degrees180', 'degrees360', 'degrees2grades', 'degrees2m',
361 'fathom2m', 'ft2m', 'furlong2m', # 'degrees2grades as degrees2gons',
362 'grades', 'grades400', 'grades2degrees', 'grades2radians',
363# 'grades as gons', 'grades400 as gons400', 'grades2degrees as gons2degrees', 'grades2radians as gons2radians',
364 'ha2acre', 'ha2m2', 'hav', 'km2m',
365 'm2acre', 'm2chain', 'm2degrees', 'm2fathom', 'm2ft', 'm2furlong',
366 'm2ha', 'm2km', 'm2NM', 'm2radians', 'm2SM', 'm2toise', 'm2yard',
367 'NM2m', 'radians', 'radiansPI', 'radiansPI2', 'radiansPI_2', 'radians2m',
368 'sincos2', 'SinCos2', 'sincos2_', 'sincos2d', 'sincos2d_', 'sincostan3', 'sincostan3d', 'SM2m',
369 'tan', 'tan_', 'tand', 'tand_', 'tan_2', 'tanPI_2_2', 'toise2m', 'truncate',
370 'unroll180', 'unrollPI',
371 'wrap90', 'wrap180', 'wrap360', 'wrapPI_2', 'wrapPI', 'wrapPI2', 'wrap_normal',
372 'yard2m'),
373 utm=_a('Utm', 'UTMError', 'parseUTM5', 'toUtm8', 'utmZoneBand5'),
374 utmups=_a('UtmUps', 'UTMUPSError', 'parseUTMUPS5', 'toUtmUps8',
375 'utmupsValidate', 'utmupsValidateOK', 'utmupsZoneBand5'),
376 utmupsBase=_a(), # module only
377 vector2d=_a('Circin6Tuple', 'Circum3Tuple', 'Circum4Tuple', 'Meeus2Tuple', 'Radii11Tuple', 'Soddy4Tuple', 'Triaxum5Tuple',
378 'circin6', 'circum3', 'circum4', 'circum4_', 'meeus2', 'radii11', 'soddy4', 'triaxum5', 'trilaterate2d2'),
379 vector3d=_a('Vector3d', 'intersection3d3', 'iscolinearWith', 'nearestOn', 'nearestOn6', 'parse3d',
380 'trilaterate3d2'),
381 vector3dBase=_a(), # module only
382 webmercator=_a('Wm', 'WebMercatorError', 'parseWM', 'toWm', 'EasNorRadius3Tuple'),
383 wgrs=_a('Georef', 'WGRSError'),)
385_ALL_DEPRECATED = _NamedEnum_RO(_name='_ALL_DEPRECATED',
386 deprecated=_a('bases', 'datum', 'nvector', # DEPRECATED modules and ...
387 'rhumbaux', 'rhumbBase', 'rhumbsolve', 'rhumbx'), # ... names
388 deprecated_bases=_a('LatLonHeightBase', 'points2'),
389 deprecated_classes=_a('ClipCS3Tuple', 'EasNorExact4Tuple', 'EcefCartesian', 'Fn_rt',
390 'FrechetCosineAndoyerLambert', 'FrechetCosineForsytheAndoyerLambert',
391 'HausdorffCosineAndoyerLambert', 'HausdorffCosineForsytheAndoyerLambert',
392 'HeightIDW', 'HeightIDW2', 'HeightIDW3', 'HeightIDWcosineAndoyerLambert',
393 'HeightIDWcosineForsytheAndoyerLambert', 'Helmert7Tuple',
394 'Lam_', 'LatLonExact4Tuple', 'NearestOn4Tuple', 'Ned3Tuple',
395 'Phi_', 'RefFrameError', 'Rhumb7Tuple', 'RhumbOrder2Tuple',
396 'Transform7Tuple', 'TriAngle4Tuple', 'UtmUps4Tuple', 'XDist'),
397 deprecated_consterns=_a('EPS1_2', 'MANTIS', 'OK'),
398 deprecated_datum=_a('Curvature2Tuple', 'Datum', 'Ellipsoid', 'Transform', # assert
399 'Datums', 'Ellipsoids', 'Transforms',
400 'R_FM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_SM', 'R_VM'),
401 deprecated_functions=_a('anStr', 'areaof', 'atand', 'bounds', # most of the DEPRECATED functions, except ellipsoidal ...
402 'clipCS3', 'clipDMS', 'clipStr', 'collins', 'copysign', # ... and spherical flavors
403 'cosineAndoyerLambert', 'cosineAndoyerLambert_',
404 'cosineForsytheAndoyerLambert', 'cosineForsytheAndoyerLambert_',
405 'decodeEPSG2', 'encodeEPSG', 'enStr2', 'equirectangular_', 'equirectangular3',
406 'excessAbc', 'excessGirard', 'excessLHuilier',
407 'false2f', 'falsed2f', 'float0', 'fStr', 'fStrzs', 'Fsum2product',
408 'hypot3', 'inStr', 'isenclosedby', 'istuplist',
409 'joined', 'joined_', 'nearestOn3', 'nearestOn4',
410 'parseUTM', 'perimeterof', 'polygon',
411 'scalar', 'simplify2', 'simplifyRDPm', 'simplifyVWm',
412 'tienstra', 'toUtm', 'triAngle4',
413 'unsign0', 'unStr', 'utmZoneBand2'),
414 deprecated_nvector=_a('LatLonNvectorBase', 'Nvector', 'sumOf', 'NorthPole', 'SouthPole'),)
417class _ALL_MODS(_internals._MODS_Base):
418 '''(INTERNAL) Memoized import of any L{pygeodesy} module.
419 '''
420 def __getattr__(self, name):
421 '''Get a C{pygeodesy} module or attribute by B{C{name}}.
423 @arg name: Un/qualified module or qualified attribute name (C{str}).
425 @raise ImportError: Importing module B{C{name}} failed.
427 @raise AttributeError: No attribute named B{C{name}}.
428 '''
429 try:
430 v = _lazy_dict[name] # package.__dict__
431 except KeyError:
432 v = _lazy_module(name) # package.__getattr__
433 if _tailof(typename(v)) != name:
434 try:
435 v = getattr(v, _tailof(name))
436 except AttributeError:
437 pass # XXX LazyAttributeError?
438 return v
440 def getattr(self, name, *attr_dflt): # , parent=_pygeodesy_
441 '''Get an attribute of/or a C{pygeodesy} module.
443 @arg name: Un/qualified module name (C{str}).
444 @arg attr_dflt: Optional attribute name (C{str}) and
445 optional default value (any C{type}).
447 @return: The C{pygeodesy} module's attribute value.
449 @raise ImportError: Importing module B{C{name}} failed.
451 @raise AttributeError: No attribute named B{C{attr}}.
452 '''
453 v = self.getmodule(name)
454 if attr_dflt:
455 v = getattr(v, *attr_dflt)
456 return v
458 def getmodule(self, name, parent=_pygeodesy_):
459 '''Get a C{pygeodesy} module or the C{__main__}.
461 @arg name: Un/qualified module name (C{str}).
463 @return: The C{pygeodesy} module.
465 @raise ImportError: Importing module B{C{name}} failed.
466 '''
467 if _headof(name) != parent and name != _DMAIN_:
468 name = _DOT_(parent, name)
469 try:
470 return _sys.modules[name]
471 except KeyError:
472 return _getmodule(name, parent)
474 def imported(self, name):
475 '''Return module or package C{name} if already imported.
476 '''
477 return _sys.modules.get(name, None)
479 def into(self, **mod_DNAME):
480 '''Lazily import module C{mod} into module C{_DNAME_}
481 and set C{_DNAME_._mod} to module C{mod}, I{once}.
482 '''
483 class _Into(object):
485 def __getattr__(unused, name):
486 mod, dun = self.errors._xkwds_item2(mod_DNAME)
487 _mod = _UNDER_(NN, mod)
488 d = self.getmodule(dun) # '__main__' OK
489 i = _getmodattr(d, _mod, dun)
490 assert isinstance(i, _Into)
491 m = self.getmodule(mod)
492 setattr(d, _mod, m) # overwrite C{d._mod}
493 return getattr(m, name)
495 return _Into()
497# @_Property_RO
498# def _isBoolean(self):
499# '''(INTERNAL) Get function C(.booleans.isBoolean}, I{once}.
500# '''
501# return self.booleans.isBoolean
503 def items(self): # no module named 'items'
504 '''Yield the modules imported so far.
505 '''
506 for n, m in _sys.modules.items():
507 if _headof(n) == _pygeodesy_:
508 yield n, m
510_internals._MODS = _ALL_MODS = _ALL_MODS() # PYCHOK singleton
512__all__ = _ALL_LAZY.lazily
513__version__ = '25.04.21'
516def _ALL_OTHER(*objs):
517 '''(INTERNAL) Get class and function B{C{objs}} for __all__.
518 '''
519 def _interned(o): # intern'd base name
520 n = _tailof(typename(o))
521 i = NN(_UNDER_, n, _UNDER_) # intern'd
522 return getattr(_interns, i, n)
524 return tuple(map(_interned, objs)) # map2
527if _FOR_DOCS: # PYCHOK no cover
528 _ALL_DOCS = _ALL_OTHER
529 # (INTERNAL) Only export B{C{objs.__name__}} when making the
530 # docs to force C{epydoc} to include certain classes, methods,
531 # functions and other names in the documentation. Using the
532 # C{epydoc --private ...} command line option tends to include
533 # too much internal documentation.
534else:
535 def _ALL_DOCS(*unused):
536 return ()
539def _all_deprecates():
540 '''(INTERNAL) Build C{dict} of all deprecated imports and attributes.
541 '''
542 D = _ALL_DEPRECATES
543 if not D:
544 _ALL_DEPRECATED.fill_D(D, _all_deprecates) # see _all_imports()
545 return D
547_ALL_DEPRECATES = _Dict() # PYCHOK _ALL_DEPRECATED.imports()
550def _all_enums():
551 '''(INTERNAL) Yield all C{(mod_, tuple)} pairs for C{__init__._all}.
552 '''
553 # assert _init__all__
554 for mod_t in _ALL_LAZY.enums():
555 yield mod_t
556 if _FOR_DOCS:
557 for mod_t in _ALL_DEPRECATED.enums():
558 yield mod_t
561def _all_imports():
562 '''(INTERNAL) Build C{dict} of all lazy imports.
563 '''
564 # imports naming conventions stored below - [<key>] = <from>:
565 # import <module> - [<module>] = <module>
566 # from <module> import <attr> - [<attr>] = <module>
567 # from pygeodesy import <attr> - [<attr>] = <attr>
568 # from <module> import <attr> as <name> - [<name>] = <module>.<attr>.
569 D = _ALL_IMPORTS
570 if not D:
571 _ALL_LAZY.fill_D(D, _all_imports) # see _all_deprecates()
572 return D
574_ALL_IMPORTS = _Dict() # PYCHOK _ALL_LAZY.imports()
577def _all_missing2(_all_):
578 '''(INTERNAL) Get diffs between pygeodesy.__all__ and lazily._all_imports.
579 '''
580 def _diff(one, two):
581 return tuple(sorted(a for a in one if a not in two))
583 _alzy = _Dict((a, a) for a in _ALL_INIT)
584 _alzy.update(_all_imports()) # without _all_backups!
585 return ((_DOT_(_lazily_, _all_imports.__name__), _diff(_all_, _alzy)),
586 (_DOT_(_pygeodesy_, _DALL_), _diff(_alzy.keys(), _all_)))
589def _getattras(attr_as): # test/testDeprecated
590 '''(INTERNAL) Get the C{"as name"} or C{"name"} of a lazy entry.
591 '''
592 a_, _, as_ = attr_as.partition(_asSPACED_)
593 return as_ or a_.rstrip(_DOT_)
596def _getmodattr(m, name, mod=_pygeodesy_):
597 '''(INTERNAL) Get attr C{m.name}.
598 '''
599 try:
600 return getattr(m, name)
601 except AttributeError:
602 name = _DOT_(mod, name)
603 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
604 raise LazyAttributeError(_no_(_attribute_), txt=name)
607def _getmodule(name, *parent):
608 '''(INTERNAL) Wrapper for C{import_module}.
609 '''
610 try:
611 return import_module(name, parent)
612 except ImportError:
613 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
614 raise LazyImportError(_no_(_module_), txt=name)
617# def _lazy_attributes(DUNDER_name):
618# '''(INTERNAL) Return a function to C{B{__name__}.__getattr__(attr)}
619# on lazily imported modules and sub-modules.
620# '''
621# if _unlazy:
622# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
623#
624# def _getattr(attr, *dflt):
625# try: # a module name
626# return _ALL_MODS.getmodule(attr)
627# except (AttributeError, ImportError):
628# return _ALL_MODS.getattr(DUNDER_name, attr, *dflt)
629#
630# return _getattr
633_lazy_dict = {} # PYCHOK overwritten by _lazy_import2
636def _lazy_import2(pack): # MCCABE 14
637 '''Check for and set up C{lazy import}.
639 @arg pack: The name of the package (C{str}) performing the imports,
640 to help resolving relative imports, usually C{__package__}.
642 @return: 2-Tuple C{(package, getattr)} of the importing package for
643 easy reference within itself and the callable to be set to
644 C{package.__getattr__}.
646 @raise LazyAttributeError: The package, module or attribute name is
647 invalid or does not exist.
649 @raise LazyImportError: Lazy import not supported or not enabled or
650 an import failed.
652 @note: This is I{Brett Cannon}'s function U{modutil.lazy_import
653 <https://GitHub.com/brettcannon/modutil/blob/master/modutil.py>}
654 modified to handle the C{__all__} and C{__dir__} attributes and
655 call C{importlib.import_module(<module>.<name>, ...)} without
656 causing a C{ModuleNotFoundError}.
658 @see: The original U{modutil<https://PyPI.org/project/modutil>},
659 U{PEP 562<https://www.Python.org/dev/peps/pep-0562>} and the
660 U{new way<https://Snarky.CA/lazy-importing-in-python-3-7/>}.
661 '''
662 if pack != _pygeodesy_ or _unlazy: # Python 3.7+ # PYCHOK no cover
663 t = _DOT_(pack, typename(_lazy_import2))
664 raise LazyImportError(_no_(t), txt=_versions())
666 package, parent = _lazy_init2(pack) # _pygeodesy_
668 _DPACKAGE_ = '__package__'
669 _lazily_imported_ = _SPACE_(_interns._HASH_, _lazily_, 'imported', parent)
671 sub_packages = set((parent, NN) + tuple(
672 _DOT_(parent, s) for s in _SUB_PACKAGES))
673 imports = _all_imports()
674 deprecates = _all_deprecates()
676 def __getattr__(name): # __getattr__ only for Python 3.7+
677 # only called once for each undefined pygeodesy attribute
678 mod = imports.get(name, NN) or deprecates.get(name, NN)
679 if mod:
680 # importlib.import_module() implicitly sets sub-modules
681 # on this module as appropriate for direct imports (see
682 # note in the _lazy_import2.__doc__ above).
683 if mod.endswith(_DOT_): # import mod[.attr] as name
684 mod, _, attr = mod[:-1].rpartition(_DOT_)
685 else: # from mod import name
686 attr = name
687 v = _getmodule(_DOT_(pack, mod), parent)
688 t = getattr(v, _DPACKAGE_, None)
689 if t not in sub_packages: # invalid module package
690 raise LazyImportError(_DOT_(mod, _DPACKAGE_), t)
691 if attr: # get mod.attr
692 v = _getmodattr(v, attr, mod)
694 elif name in (_DALL_,): # XXX _Ddir_, _Dmembers_?
695 v = _ALL_INIT + tuple(imports.keys())
696 else: # PYCHOK no cover
697 t = _no_(_module_, _or_, _attribute_)
698 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
699 raise LazyAttributeError(t, txt=_DOT_(parent, name))
701 setattr(package, name, v) # package.__dict__[name] = val
702 if isLazy > 1:
703 t = _DOT_(_lazily_imported_, name)
704 if mod and _tailof(mod) != name:
705 t = _SPACE_(t, _from_, _DOT_(NN, mod))
706 if isLazy > 2:
707 try: # see C{_caller3}
708 _, f, s = _caller3(2)
709 t = _SPACE_(t, _by_, f, _line_, s)
710 except ValueError:
711 pass
712 printf(t) # XXX print
714 return v # __getattr__
716 global _lazy_dict, _lazy_module
717 _lazy_dict = package.__dict__
718 _lazy_module = __getattr__
720 return package, __getattr__ # _lazy_import2
723# def _lazy_import_all(Dname):
724# '''(INTERNAL) Return a function mimicking C{from B{__name__} import *},
725# of all items, see .deprecated.__init__
726# '''
727# if _unlazy:
728# raise AssertionError(_COMMASPACE_(Dname, _not_(_DEPRECATED_)))
729#
730# _getattr = _lazy_attributes(Dname) # __name__.__getattr__
731# _import_start = _lazy_import_star(Dname, ALL_=_ALL_IMPORTS)
732#
733# def _import_all(attr, *dflt):
734# return _import_star(Dname) if attr == _DALL_ else \
735# _getattr(attr, *dflt)
736#
737# return _import_all
740def _lazy_import_as(DUNDER_name):
741 '''(INTERNAL) Return a function to C{import B{__name__}.mod as mod}
742 I{of modules only}, see .deprecated, .rhumb or get an attribute
743 lazily exported by C{__name__}.
744 '''
745 if _unlazy:
746 return None
748 def _import_as(mod):
749 try:
750 return _ALL_MODS.getmodule(_DOT_(DUNDER_name, mod))
751 except ImportError:
752 return _lazy_module(mod)
754 return _import_as
757# def _lazy_import_star(DUNDER_name, ALL_=_ALL_DEPRECATES):
758# '''(INTERNAL) Return a function to mimick C{from B{__name__} import *},
759# of all DEPRECATED items, see .deprecated, .testDeprecated
760# '''
761# if _unlazy:
762# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
763#
764# def _import_star(_into_):
765# '''Do C{from B{__name__} import *} inside module C{B{__into__}}.
766# '''
767# d = dict()
768# nm = _tailof(DUNDER_name)
769# _g = _ALL_MODS.getattr # pygeodesy.__getattr__
770# for a, m in ALL_.items():
771# if _headof(m) == nm:
772# try:
773# d[a] = _g(m, a)
774# except (AttributeError, ImportError):
775# pass
776# _sys.modules[_into_].__dict__.update(d)
777# return d.keys() # imported names
778#
779# return _import_star
782def _lazy_init2(pack):
783 '''(INTERNAL) Initialize lazy import and set globals C{isLazy} and C{_unLazy0}.
785 @arg pack: The name of the package (C{str}) performing the imports,
786 to resolve relative imports, usually C{__package__}.
788 @return: 2-Tuple C{(package, parent)} with the importing C{package}
789 for easy reference within itself and its name aka the
790 C(package)'s C{parent}, same as B{C{pack}}.
792 @raise LazyImportError: Lazy import not supported or not enabled,
793 an import failed or the package name is
794 invalid or does not exist.
796 @note: Global C{isLazy} is set accordingly.
797 '''
798 global isLazy, _unLazy0
800 E = _internals._PYGEODESY_ENV('LAZY_IMPORT')
801 z = _internals._getenv(E, _interns._1_) # 1 default on 3.7+
802 z = z.strip() # like PYTHONVERBOSE et.al.
803 isLazy = int(z) if z.isdigit() else (1 if z else 0)
805 _unLazy0 = _unlazy or not isLazy # pre-3.7 or w/o lazy import
807 if isLazy < 1: # invalid, not enabled
808 raise LazyImportError(E, repr(z), txt_not_='enabled')
809 if _sys.flags.verbose: # PYCHOK no cover
810 isLazy += 1
812 try: # to initialize in Python 3+
813 package = import_module(pack)
814 parent = package.__spec__.parent # __spec__ only in Python 3.7+
815 if parent != pack: # assert
816 t = _COMMASPACE_(parent, _not_(pack)) # PYCHOK no cover
817 raise AttributeError(_EQUALSPACED_('parent', t))
819 except (AttributeError, ImportError) as x:
820 isLazy = False # failed
821 z = typename(_lazy_init2)
822 raise LazyImportError(z, pack, cause=x)
824 return package, parent
827def _lazy_module(name): # overwritten by _lazy_import2
828 '''(INTERNAL) Get or import a C{pygeodesy} module.
829 '''
830 try: # most likely ... module has been imported
831 m = _ALL_MODS.getmodule(name)
832 except (AttributeError, ImportError) as x:
833 raise LazyImportError(name, cause=x)
834 _lazy_dict[name] = m # cache
835 return m
838# def _lazy_subs(__name__, force=_FOR_DOCS, over=False):
839# '''(INTERNAL) Return the names of a __name__ package's sub-packages
840# and update the package's C{__dict__} accordingly.
841# '''
842# sm = dict()
843# if force and __name__ != _DMAIN_:
844# nm = _tailof(__name__)
845# _a = _ALL_MODS.getattr
846# _m = _ALL_MODS.getmodule
847# d = _a(__name__, _DDICT_, {})
848# for n in _a(__name__, _DALL_, ()):
849# try: # n is a class name, get its mod name
850# m = _a(__name__, n).__module__
851# n, s = m.split(_DOT_)[-2:]
852# if n == nm and s not in sm:
853# m = _m(m) # == import m as s
854# sm[s] = m if over else d.get(s, m)
855# except (AttributeError, ImportError, ValueError) as x:
856# pass
857# d.update(sm)
858#
859# return _ALL_OTHER(*sm.values())
862if __name__ == _DMAIN_:
864 def _main():
865 from timeit import timeit
867 def t1():
868 from pygeodesy.trf import RefFrame
869 return RefFrame
871 def t2():
872 return _ALL_MODS.trf.RefFrame
874 assert t1() is t2() # prime each
876 t1 = timeit(t1, number=1000000)
877 t2 = timeit(t2, number=1000000)
878 A = typename(_ALL_MODS)
879 v = _versions()
880 printf('%.6f import vs %.6f %s: %.2fX, %s', t1, t2, A, (t1 / t2), v)
882 _main()
884# % python3.13 -W ignore -m pygeodesy.lazily
885# 0.054235 import vs 0.052469 _ALL_MODS: 1.03X, pygeodesy 25.4.24 Python 3.13.3 64bit arm64 macOS 15.4
887# % python2 -m pygeodesy.lazily
888# 0.653715 import vs 0.321318 _ALL_MODS: 2.03X, pygeodesy 25.4.24 Python 2.7.18 64bit arm64_x86_64 macOS 10.16
890# % python3.13 -W ignore -m pygeodesy.lazily
891# 0.106602 import vs 0.078136 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.13.0 64bit arm64 macOS 14.6.1
893# % python3.12 -W ignore -m pygeodesy.lazily
894# 0.138844 import vs 0.080458 _ALL_MODS: 1.73X, pygeodesy 24.10.24 Python 3.12.7 64bit arm64 macOS 14.6.1
896# % python3.11 -W ignore -m pygeodesy.lazily
897# 0.387520 import vs 0.254229 _ALL_MODS: 1.52X, pygeodesy 24.10.24 Python 3.11.5 64bit arm64 macOS 14.6.1
899# % python3.10 -W ignore -m pygeodesy.lazily
900# 0.371269 import vs 0.272897 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.10.8 64bit arm64 macOS 14.6.1
902# % python3.8 -W ignore -m pygeodesy.lazily
903# 0.555572 import vs 0.370304 _ALL_MODS: 1.50X, pygeodesy 24.10.24 Python 3.8.10 64bit arm64_x86_64 macOS 10.16
905# % python2 -m pygeodesy.lazily
906# 1.160292 import vs 0.490279 _ALL_MODS: 2.37X, pygeodesy 24.10.24 Python 2.7.18 64bit arm64_x86_64 macOS 10.16
908# **) MIT License
909#
910# Copyright (C) 2018-2025 -- mrJean1 at Gmail -- All Rights Reserved.
911#
912# Permission is hereby granted, free of charge, to any person obtaining a
913# copy of this software and associated documentation files (the "Software"),
914# to deal in the Software without restriction, including without limitation
915# the rights to use, copy, modify, merge, publish, distribute, sublicense,
916# and/or sell copies of the Software, and to permit persons to whom the
917# Software is furnished to do so, subject to the following conditions:
918#
919# The above copyright notice and this permission notice shall be included
920# in all copies or substantial portions of the Software.
921#
922# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
923# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
924# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
925# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
926# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
927# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
928# OTHER DEALINGS IN THE SOFTWARE.