pygeodesy 24.9.29__py2.py3-none-any.whl → 24.10.24__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyGeodesy-24.9.29.dist-info → PyGeodesy-24.10.24.dist-info}/METADATA +15 -15
- {PyGeodesy-24.9.29.dist-info → PyGeodesy-24.10.24.dist-info}/RECORD +56 -56
- pygeodesy/__init__.py +20 -19
- pygeodesy/__main__.py +5 -5
- pygeodesy/albers.py +12 -17
- pygeodesy/basics.py +38 -41
- pygeodesy/booleans.py +54 -46
- pygeodesy/cartesianBase.py +2 -2
- pygeodesy/constants.py +20 -16
- pygeodesy/datums.py +3 -3
- pygeodesy/dms.py +250 -270
- pygeodesy/ellipsoidalBase.py +2 -2
- pygeodesy/ellipsoidalBaseDI.py +10 -10
- pygeodesy/ellipsoidalNvector.py +4 -4
- pygeodesy/ellipsoidalVincenty.py +2 -2
- pygeodesy/ellipsoids.py +7 -48
- pygeodesy/elliptic.py +14 -14
- pygeodesy/errors.py +15 -10
- pygeodesy/etm.py +18 -2
- pygeodesy/fmath.py +188 -176
- pygeodesy/formy.py +4 -4
- pygeodesy/fstats.py +54 -56
- pygeodesy/fsums.py +304 -266
- pygeodesy/geodesici.py +43 -40
- pygeodesy/geodesicw.py +3 -3
- pygeodesy/geodesicx/gxarea.py +3 -2
- pygeodesy/geodsolve.py +73 -24
- pygeodesy/geohash.py +2 -2
- pygeodesy/geoids.py +28 -27
- pygeodesy/internals.py +156 -85
- pygeodesy/interns.py +23 -20
- pygeodesy/karney.py +61 -12
- pygeodesy/latlonBase.py +13 -15
- pygeodesy/lazily.py +206 -214
- pygeodesy/mgrs.py +13 -13
- pygeodesy/named.py +11 -10
- pygeodesy/nvectorBase.py +1 -1
- pygeodesy/points.py +2 -2
- pygeodesy/props.py +34 -13
- pygeodesy/rhumb/bases.py +5 -5
- pygeodesy/rhumb/solve.py +7 -8
- pygeodesy/solveBase.py +7 -25
- pygeodesy/sphericalBase.py +20 -23
- pygeodesy/sphericalNvector.py +24 -23
- pygeodesy/sphericalTrigonometry.py +9 -8
- pygeodesy/streprs.py +11 -8
- pygeodesy/trf.py +6 -4
- pygeodesy/triaxials.py +46 -9
- pygeodesy/units.py +4 -3
- pygeodesy/ups.py +6 -6
- pygeodesy/utily.py +2 -2
- pygeodesy/utm.py +2 -2
- pygeodesy/vector3d.py +5 -5
- pygeodesy/vector3dBase.py +4 -5
- {PyGeodesy-24.9.29.dist-info → PyGeodesy-24.10.24.dist-info}/WHEEL +0 -0
- {PyGeodesy-24.9.29.dist-info → PyGeodesy-24.10.24.dist-info}/top_level.txt +0 -0
pygeodesy/lazily.py
CHANGED
|
@@ -30,58 +30,44 @@ and line number.
|
|
|
30
30
|
from pygeodesy import internals as _internals, interns as _interns, \
|
|
31
31
|
_isfrozen # DON'T _lazy_import2
|
|
32
32
|
# from pygeodesy.errors import _error_init, _xkwds_item2 # _ALL_MODS
|
|
33
|
-
from pygeodesy.internals import _caller3,
|
|
34
|
-
|
|
33
|
+
from pygeodesy.internals import _caller3, _DUNDER_nameof, _getPYGEODESY, _headof, \
|
|
34
|
+
_is_DUNDER_main, printf, _tailof, _versions
|
|
35
35
|
from pygeodesy.interns import NN, _attribute_, _by_, _COLONSPACE_, _COMMASPACE_, \
|
|
36
|
-
_doesn_t_exist_, _DOT_,
|
|
37
|
-
_HASH_, _immutable_, _line_, _module_, _no_,
|
|
38
|
-
_or_, _pygeodesy_abspath_, _pygeodesy_,
|
|
39
|
-
_SUB_PACKAGES, _UNDER_, _version_,
|
|
40
|
-
_intern # function
|
|
41
|
-
# from pygeodesy.streprs import unstr # _ALL_MODS
|
|
42
|
-
|
|
36
|
+
_doesn_t_exist_, _DOT_, _DUNDER_all_, _EQUALSPACED_, \
|
|
37
|
+
_from_, _HASH_, _immutable_, _line_, _module_, _no_, \
|
|
38
|
+
_not_, _or_, _pygeodesy_abspath_, _pygeodesy_, _sys, \
|
|
39
|
+
_SUB_PACKAGES, _UNDER_, _version_, _intern # function
|
|
43
40
|
try:
|
|
44
41
|
from importlib import import_module
|
|
45
42
|
except ImportError as x: # Python 2.6-
|
|
46
|
-
raise ImportError(_COLONSPACE_(
|
|
47
|
-
from os import getenv as _getenv
|
|
43
|
+
raise ImportError(_COLONSPACE_(x, _versions()))
|
|
48
44
|
# import sys as _sys # from .interns
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_PYGEODESY_LAZY_IMPORT_ = 'PYGEODESY_LAZY_IMPORT'
|
|
62
|
-
_PYGEODESY_RHUMBSOLVE_ = 'PYGEODESY_RHUMBSOLVE' # PYCHOK .rhumb.solve, test.bases
|
|
63
|
-
_PYTHON_X_DEV = getattr(_sys, '_xoptions', {}).get('dev', # Python 3.2+
|
|
64
|
-
_getenv('PYTHONDEVMODE', NN)) # PYCHOK exported
|
|
65
|
-
_sys_version_info2 = _sys.version_info[:2] # in .basics, .fmath, ...
|
|
66
|
-
_unlazy = _unLazy0 = _isfrozen or _sys_version_info2 < (3, 7) # PYCHOK mod.__getattr__ 3.7+
|
|
67
|
-
_WARNINGS_X_DEV = _getenv('PYGEODESY_WARNINGS', NN) and (
|
|
68
|
-
_PYTHON_X_DEV or bool(_sys.warnoptions)) # PYCHOK .props
|
|
69
|
-
# @module_property[_RO?] <https://GitHub.com/jtushman/proxy_tools/>
|
|
70
|
-
isLazy = None # see @var isLazy in .__init__
|
|
46
|
+
_a0 = () # PYCHOK empty tuple
|
|
47
|
+
_asSPACED_ = ' as '
|
|
48
|
+
_FOR_DOCS = _getPYGEODESY('_FOR_DOCS') # for epydoc ...
|
|
49
|
+
_init__all__ = _FOR_DOCS or _getPYGEODESY('_init__all__', _DUNDER_all_) == _DUNDER_all_ # PYCHOK exported
|
|
50
|
+
_lazily_ = 'lazily'
|
|
51
|
+
_PYTHON_X_DEV = getattr(_sys.flags, 'dev_mode', False) # PYCHOK Python 3.2+
|
|
52
|
+
_unlazy = _unLazy0 = _isfrozen or _internals._MODS.sys_version_info2 < (3, 7) # PYCHOK mod.__getattr__ 3.7+
|
|
53
|
+
_WARNINGS_X_DEV = _getPYGEODESY('WARNINGS') and (_PYTHON_X_DEV or bool(_sys.warnoptions)) # PYCHOK .props
|
|
54
|
+
|
|
55
|
+
# @module_property[_RO?] <https://GitHub.com/jtushman/proxy_tools/> <https://discuss.Python.org/t/47379>
|
|
56
|
+
isLazy = None # see @var isLazy in .__init__
|
|
71
57
|
|
|
72
58
|
|
|
73
59
|
class LazyAttributeError(AttributeError):
|
|
74
60
|
'''Raised if a C{lazily imported} attribute is missing or invalid.
|
|
75
61
|
'''
|
|
76
|
-
def __init__(self, *
|
|
77
|
-
_ALL_MODS.errors._error_init(AttributeError, self,
|
|
62
|
+
def __init__(self, *args, **kwds):
|
|
63
|
+
_ALL_MODS.errors._error_init(AttributeError, self, args, **kwds)
|
|
78
64
|
|
|
79
65
|
|
|
80
66
|
class LazyImportError(ImportError):
|
|
81
67
|
'''Raised if C{lazy import} is not supported, disabled or failed some other way.
|
|
82
68
|
'''
|
|
83
|
-
def __init__(self, *
|
|
84
|
-
_ALL_MODS.errors._error_init(ImportError, self,
|
|
69
|
+
def __init__(self, *args, **kwds):
|
|
70
|
+
_ALL_MODS.errors._error_init(ImportError, self, args, **kwds)
|
|
85
71
|
|
|
86
72
|
|
|
87
73
|
class _Dict(dict):
|
|
@@ -107,9 +93,9 @@ class _Dict(dict):
|
|
|
107
93
|
@raise AssertionError: The B{C{name}} already exists
|
|
108
94
|
with a different B{C{mod_}}.
|
|
109
95
|
'''
|
|
110
|
-
if name in self:
|
|
96
|
+
if name in self: # PYCHOK no cover
|
|
111
97
|
sub = self[name] # duplicate OK
|
|
112
|
-
if sub != mod_ and sub not in subs:
|
|
98
|
+
if sub != mod_ and sub not in subs:
|
|
113
99
|
t = _DOT_(self._name, name)
|
|
114
100
|
t = _COLONSPACE_(t, repr(sub))
|
|
115
101
|
t = _COMMASPACE_(t, _not_(repr(mod_)))
|
|
@@ -118,7 +104,7 @@ class _Dict(dict):
|
|
|
118
104
|
self[name] = mod_
|
|
119
105
|
|
|
120
106
|
def _NAME(self, which):
|
|
121
|
-
self._name = _intern(
|
|
107
|
+
self._name = _intern(_DUNDER_nameof(which).upper())
|
|
122
108
|
|
|
123
109
|
|
|
124
110
|
class _NamedEnum_RO(dict):
|
|
@@ -160,7 +146,7 @@ class _NamedEnum_RO(dict):
|
|
|
160
146
|
for m, t in self.enums():
|
|
161
147
|
_a(m, _DOT_(m, NN, NN)) # import module
|
|
162
148
|
for a in t:
|
|
163
|
-
a, _, as_ = a.partition(
|
|
149
|
+
a, _, as_ = a.partition(_asSPACED_)
|
|
164
150
|
if as_: # import attr as attr_
|
|
165
151
|
_a(as_, _DOT_(m, a, NN), *_SUB_PACKAGES)
|
|
166
152
|
else:
|
|
@@ -168,10 +154,10 @@ class _NamedEnum_RO(dict):
|
|
|
168
154
|
return _D
|
|
169
155
|
|
|
170
156
|
|
|
171
|
-
def
|
|
157
|
+
def _a(*names):
|
|
172
158
|
'''(INTERNAL) Intern all C{names}.
|
|
173
159
|
'''
|
|
174
|
-
return tuple(map(_intern, names)) if names else
|
|
160
|
+
return tuple(map(_intern, names)) if names else _a0
|
|
175
161
|
|
|
176
162
|
|
|
177
163
|
def _ALL_ATTRS(*attrs):
|
|
@@ -179,87 +165,87 @@ def _ALL_ATTRS(*attrs):
|
|
|
179
165
|
'''
|
|
180
166
|
t = ()
|
|
181
167
|
for attr in attrs:
|
|
182
|
-
t += tuple(map(
|
|
168
|
+
t += tuple(map(_getattras, attr))
|
|
183
169
|
return t
|
|
184
170
|
|
|
185
171
|
|
|
186
|
-
_ALL_INIT =
|
|
172
|
+
_ALL_INIT = _a(_pygeodesy_abspath_, _version_)
|
|
187
173
|
|
|
188
174
|
# __all__ value for most modules, accessible as _ALL_LAZY.<module>
|
|
189
175
|
_ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
190
|
-
albers=
|
|
176
|
+
albers=_a('AlbersEqualArea', 'AlbersEqualArea2', 'AlbersEqualArea4',
|
|
191
177
|
'AlbersEqualAreaCylindrical', 'AlbersEqualAreaNorth', 'AlbersEqualAreaSouth',
|
|
192
178
|
'AlbersError', 'Albers7Tuple'),
|
|
193
|
-
auxilats=
|
|
194
|
-
azimuthal=
|
|
179
|
+
auxilats=_a(), # module only
|
|
180
|
+
azimuthal=_a('AzimuthalError', 'Azimuthal7Tuple',
|
|
195
181
|
'Equidistant', 'EquidistantExact', 'EquidistantGeodSolve', 'EquidistantKarney',
|
|
196
182
|
'Gnomonic', 'GnomonicExact', 'GnomonicGeodSolve', 'GnomonicKarney',
|
|
197
183
|
'LambertEqualArea', 'Orthographic', 'Stereographic',
|
|
198
184
|
'equidistant', 'gnomonic'),
|
|
199
|
-
basics=
|
|
185
|
+
basics=_a('clips', 'copysign0', 'copytype', 'halfs2',
|
|
200
186
|
'int1s', 'isbool', 'isCartesian', 'isclass', 'iscomplex', 'isDEPRECATED', 'isfloat',
|
|
201
187
|
'isidentifier', 'isinstanceof', 'isint', 'isiterable', 'isiterablen', 'iskeyword',
|
|
202
188
|
'isLatLon', 'islistuple', 'isNvector', 'isodd', 'isscalar', 'issequence', 'isstr',
|
|
203
189
|
'issubclassof', 'itemsorted',
|
|
204
190
|
'len2', 'map1', 'map2', 'neg', 'neg_',
|
|
205
191
|
'signBit', 'signOf', 'splice', 'str2ub', 'ub2str', 'unsigned0'),
|
|
206
|
-
booleans=
|
|
192
|
+
booleans=_a('BooleanFHP', 'BooleanGH', 'LatLonFHP', 'LatLonGH',
|
|
207
193
|
'isBoolean'),
|
|
208
|
-
cartesianBase=
|
|
209
|
-
clipy=
|
|
194
|
+
cartesianBase=_a('RadiusThetaPhi3Tuple', 'rtp2xyz', 'rtp2xyz_', 'xyz2rtp', 'xyz2rtp_'),
|
|
195
|
+
clipy=_a('ClipCS4Tuple', 'ClipFHP4Tuple', 'ClipGH4Tuple', 'ClipLB6Tuple', 'ClipSH3Tuple',
|
|
210
196
|
'clipCS4', 'clipFHP4', 'clipGH4', 'clipLB6', 'clipSH', 'clipSH3'),
|
|
211
|
-
css=
|
|
197
|
+
css=_a('CassiniSoldner', 'Css', 'CSSError', 'toCss',
|
|
212
198
|
'EasNorAziRk4Tuple', 'EasNorAziRkEqu6Tuple', 'LatLonAziRk4Tuple'),
|
|
213
|
-
constants=
|
|
199
|
+
constants=_a('DIG', 'EPS', 'EPS0', 'EPS02', 'EPS1', 'EPS2', 'EPS4', 'EPS_2',
|
|
214
200
|
'INF', 'INT0', 'MANT_DIG', 'MAX', 'MAX_EXP', 'MIN', 'MIN_EXP', 'NAN', 'NEG0', 'NINF',
|
|
215
201
|
'PI', 'PI2', 'PI_2', 'PI3', 'PI_3', 'PI3_2', 'PI4', 'PI_4',
|
|
216
202
|
'R_FM', 'R_GM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_QM', 'R_SM', 'R_VM',
|
|
217
203
|
'float_', 'float0_', 'isclose', 'isfinite', 'isinf', 'isint0',
|
|
218
204
|
'isnan', 'isnear0', 'isnear1', 'isnear90', 'isneg0', 'isninf', 'isnon0',
|
|
219
205
|
'remainder'),
|
|
220
|
-
datums=
|
|
221
|
-
# deprecated=
|
|
222
|
-
dms=
|
|
206
|
+
datums=_a('Datum', 'Datums', 'Transform', 'Transforms'),
|
|
207
|
+
# deprecated=_a(), # module only
|
|
208
|
+
dms=_a('F_D', 'F_DM', 'F_DMS', 'F_DEG', 'F_MIN', 'F_SEC', 'F_D60', 'F__E', 'F__F', 'F__G', 'F_RAD',
|
|
223
209
|
'F_D_', 'F_DM_', 'F_DMS_', 'F_DEG_', 'F_MIN_', 'F_SEC_', 'F_D60_', 'F__E_', 'F__F_', 'F__G_', 'F_RAD_',
|
|
224
210
|
'F_D__', 'F_DM__', 'F_DMS__', 'F_DEG__', 'F_MIN__', 'F_SEC__', 'F_D60__', 'F__E__', 'F__F__', 'F__G__', 'F_RAD__',
|
|
225
211
|
'S_DEG', 'S_MIN', 'S_SEC', 'S_DMS', 'S_RAD', 'S_SEP',
|
|
226
212
|
'bearingDMS', 'clipDegrees', 'clipRadians', 'compassDMS', 'compassPoint',
|
|
227
213
|
'degDMS', 'latDMS', 'latlonDMS', 'latlonDMS_', 'lonDMS', 'normDMS',
|
|
228
214
|
'parseDDDMMSS', 'parseDMS', 'parseDMS2', 'parse3llh', 'parseRad', 'precision', 'toDMS'),
|
|
229
|
-
ecef=
|
|
215
|
+
ecef=_a('EcefError', 'EcefFarrell21', 'EcefFarrell22', 'EcefKarney', 'EcefMatrix',
|
|
230
216
|
'EcefSudano', 'Ecef9Tuple', 'EcefVeness', 'EcefYou'),
|
|
231
|
-
elevations=
|
|
217
|
+
elevations=_a('Elevation2Tuple', 'GeoidHeight2Tuple',
|
|
232
218
|
'elevation2', 'geoidHeight2'),
|
|
233
|
-
ellipsoidalBase=
|
|
234
|
-
ellipsoidalBaseDI=
|
|
235
|
-
ellipsoidalExact=
|
|
236
|
-
ellipsoidalGeodSolve=
|
|
237
|
-
ellipsoidalKarney=
|
|
238
|
-
ellipsoidalNvector=
|
|
239
|
-
ellipsoidalVincenty=
|
|
240
|
-
ellipsoids=
|
|
219
|
+
ellipsoidalBase=_a(), # module only
|
|
220
|
+
ellipsoidalBaseDI=_a(), # module only
|
|
221
|
+
ellipsoidalExact=_a(), # module only
|
|
222
|
+
ellipsoidalGeodSolve=_a(), # module only
|
|
223
|
+
ellipsoidalKarney=_a(), # module only
|
|
224
|
+
ellipsoidalNvector=_a(), # module only
|
|
225
|
+
ellipsoidalVincenty=_a('VincentyError',), # nothing else
|
|
226
|
+
ellipsoids=_a('a_f2Tuple', 'Circle4Tuple', 'Curvature2Tuple',
|
|
241
227
|
'Ellipsoid', 'Ellipsoid2', 'Ellipsoids',
|
|
242
228
|
'a_b2e', 'a_b2e2', 'a_b2e22', 'a_b2e32', 'a_b2f', 'a_b2f_', 'a_b2f2', 'a_b2n',
|
|
243
229
|
'a_f2b', 'a_f_2b', 'b_f2a', 'b_f_2a',
|
|
244
230
|
'e2f', 'e22f',
|
|
245
231
|
'f2e2', 'f2e22', 'f2e32', 'f_2f', 'f2f_', 'f2f2', 'f2n', 'n2e2', 'n2f', 'n2f_'),
|
|
246
|
-
elliptic=
|
|
247
|
-
epsg=
|
|
248
|
-
errors=
|
|
232
|
+
elliptic=_a('Elliptic', 'EllipticError', 'Elliptic3Tuple'),
|
|
233
|
+
epsg=_a('Epsg', 'EPSGError'),
|
|
234
|
+
errors=_a('AuxError', 'ClipError', 'CrossError', 'GeodesicError', 'IntersectionError',
|
|
249
235
|
'NumPyError', 'LenError', 'LimitError', 'MGRSError',
|
|
250
236
|
'ParseError', 'PointsError', 'RangeError', 'RhumbError',
|
|
251
237
|
'SciPyError', 'SciPyWarning', 'TRFError', 'TriangleError', 'UnitError', 'VectorError',
|
|
252
238
|
'crosserrors', 'exception_chaining', 'isError', 'limiterrors', 'rangerrors'),
|
|
253
|
-
etm=
|
|
239
|
+
etm=_a('Etm', 'ETMError', 'ExactTransverseMercator',
|
|
254
240
|
'parseETM5', 'toEtm8'),
|
|
255
|
-
fmath=
|
|
241
|
+
fmath=_a('Fdot', 'Fhorner', 'Fhypot', 'Fpolynomial', 'Fpowers', 'Fcbrt', 'Froot', 'Fsqrt',
|
|
256
242
|
'bqrt', 'cbrt', 'cbrt2', 'euclid', 'euclid_',
|
|
257
243
|
'facos1', 'fasin1', 'fatan', 'fatan1', 'fatan2', 'favg',
|
|
258
244
|
'fdot', 'fdot3', 'fma', 'fmean', 'fmean_', 'fhorner', 'fidw', 'f2mul_', 'fpolynomial',
|
|
259
245
|
'fpowers', 'fprod', 'frandoms', 'frange', 'freduce', 'fremainder',
|
|
260
246
|
'hypot', 'hypot_', 'hypot1', 'hypot2', 'hypot2_',
|
|
261
247
|
'norm2', 'norm_', 'sqrt0', 'sqrt3', 'sqrt_a', 'zcrt', 'zqrt'),
|
|
262
|
-
formy=
|
|
248
|
+
formy=_a('Radical2Tuple',
|
|
263
249
|
'antipode', 'antipode_', 'bearing', 'bearing_',
|
|
264
250
|
'compassAngle', 'cosineForsytheAndoyerLambert', 'cosineForsytheAndoyerLambert_',
|
|
265
251
|
'cosineAndoyerLambert', 'cosineAndoyerLambert_', 'cosineLaw', 'cosineLaw_',
|
|
@@ -272,34 +258,34 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
272
258
|
'latlon2n_xyz', 'normal', 'normal_', 'n_xyz2latlon', 'n_xyz2philam',
|
|
273
259
|
'opposing', 'opposing_', 'philam2n_xyz', 'radical2',
|
|
274
260
|
'thomas', 'thomas_', 'vincentys', 'vincentys_'),
|
|
275
|
-
frechet=
|
|
261
|
+
frechet=_a('Frechet', 'FrechetDegrees', 'FrechetError', 'FrechetRadians',
|
|
276
262
|
'FrechetCosineAndoyerLambert', 'FrechetCosineForsytheAndoyerLambert',
|
|
277
263
|
'FrechetCosineLaw', 'FrechetDistanceTo', 'FrechetEquirectangular',
|
|
278
264
|
'FrechetEuclidean', 'FrechetExact', 'FrechetFlatLocal', 'FrechetFlatPolar',
|
|
279
265
|
'FrechetHaversine', 'FrechetHubeny', 'FrechetKarney', 'FrechetThomas',
|
|
280
266
|
'FrechetVincentys', 'Frechet6Tuple',
|
|
281
267
|
'frechet_'),
|
|
282
|
-
fstats=
|
|
283
|
-
fsums=
|
|
268
|
+
fstats=_a('Fcook', 'Flinear', 'Fwelford'),
|
|
269
|
+
fsums=_a('Fsum', 'DivMod2Tuple', 'Fsum2Tuple', 'ResidualError',
|
|
284
270
|
'f2product', 'fsum', 'fsum_', 'fsumf_', 'fsum1', 'fsum1_', 'fsum1f_', 'nonfiniterrors'),
|
|
285
|
-
gars=
|
|
286
|
-
geodesici=
|
|
271
|
+
gars=_a('Garef', 'GARSError'),
|
|
272
|
+
geodesici=_a('Intersectool', 'Intersectool5Tuple', 'Intersect7Tuple',
|
|
287
273
|
'Intersector', 'Intersector5Tuple', 'Middle5Tuple', 'XDict'),
|
|
288
|
-
geodesicw=
|
|
289
|
-
geodesicx=
|
|
274
|
+
geodesicw=_a('Geodesic', 'GeodesicLine', 'Geodesic_WGS84'),
|
|
275
|
+
geodesicx=_a('gx', 'gxarea', 'gxbases', 'gxline', # modules
|
|
290
276
|
'GeodesicAreaExact', 'GeodesicExact', 'GeodesicLineExact', 'PolygonArea'),
|
|
291
|
-
geodsolve=
|
|
292
|
-
geohash=
|
|
293
|
-
geoids=
|
|
277
|
+
geodsolve=_a('GeodesicSolve', 'GeodesicLineSolve', 'GeodSolve12Tuple'),
|
|
278
|
+
geohash=_a('Geohash', 'Geohashed', 'GeohashError', 'Neighbors8Dict', 'Resolutions2Tuple', 'Sizes3Tuple'),
|
|
279
|
+
geoids=_a('GeoidError', 'GeoidG2012B', 'GeoidKarney', 'GeoidPGM', 'egmGeoidHeights',
|
|
294
280
|
'PGMError', 'GeoidHeight5Tuple'),
|
|
295
|
-
hausdorff=
|
|
281
|
+
hausdorff=_a('Hausdorff', 'HausdorffDegrees', 'HausdorffError', 'HausdorffRadians',
|
|
296
282
|
'HausdorffCosineAndoyerLambert', 'HausdorffCosineForsytheAndoyerLambert',
|
|
297
283
|
'HausdorffCosineLaw', 'HausdorffDistanceTo', 'HausdorffEquirectangular',
|
|
298
284
|
'HausdorffEuclidean', 'HausdorffExact', 'HausdorffFlatLocal', 'HausdorffFlatPolar',
|
|
299
285
|
'HausdorffHaversine', 'HausdorffHubeny', 'HausdorffKarney', 'HausdorffThomas',
|
|
300
286
|
'HausdorffVincentys', 'Hausdorff6Tuple',
|
|
301
287
|
'hausdorff_', 'randomrangenerator'),
|
|
302
|
-
heights=
|
|
288
|
+
heights=_a('HeightCubic', 'HeightError',
|
|
303
289
|
'HeightIDWcosineAndoyerLambert', 'HeightIDWcosineForsytheAndoyerLambert',
|
|
304
290
|
'HeightIDWcosineLaw', 'HeightIDWdistanceTo', 'HeightIDWequirectangular',
|
|
305
291
|
'HeightIDWeuclidean', 'HeightIDWexact', 'HeightIDWflatLocal', 'HeightIDWflatPolar',
|
|
@@ -307,24 +293,24 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
307
293
|
'HeightIDWvincentys', 'HeightLinear', 'HeightLSQBiSpline', 'HeightSmoothBiSpline'),
|
|
308
294
|
internals=_internals.__all__,
|
|
309
295
|
interns=_interns.__all__,
|
|
310
|
-
iters=
|
|
296
|
+
iters=_a('LatLon2PsxyIter', 'PointsIter', 'points2',
|
|
311
297
|
'isNumpy2', 'isPoints2', 'isTuple2', 'iterNumpy2', 'iterNumpy2over'),
|
|
312
|
-
karney=
|
|
313
|
-
ktm=
|
|
314
|
-
latlonBase=
|
|
315
|
-
lazily=
|
|
316
|
-
lcc=
|
|
317
|
-
ltp=
|
|
298
|
+
karney=_a('Area3Tuple', 'Caps', 'Direct9Tuple', 'GDict', 'Inverse10Tuple', 'Rhumb8Tuple'),
|
|
299
|
+
ktm=_a('KTMError', 'KTransverseMercator'),
|
|
300
|
+
latlonBase=_a(), # module only
|
|
301
|
+
lazily=_a('LazyAttributeError', 'LazyImportError', 'isLazy'),
|
|
302
|
+
lcc=_a('Conic', 'Conics', 'Lcc', 'LCCError', 'toLcc'),
|
|
303
|
+
ltp=_a('Attitude', 'AttitudeError', 'ChLV', 'ChLVa', 'ChLVe', 'Frustum',
|
|
318
304
|
'LocalCartesian', 'LocalError', 'Ltp', 'tyr3d'),
|
|
319
|
-
ltpTuples=
|
|
305
|
+
ltpTuples=_a('Aer', 'Aer4Tuple', 'Attitude4Tuple',
|
|
320
306
|
'ChLVEN2Tuple', 'ChLV9Tuple', 'ChLVYX2Tuple', 'ChLVyx2Tuple',
|
|
321
307
|
'Enu', 'Enu4Tuple', 'Footprint5Tuple', 'Local9Tuple', 'Los',
|
|
322
308
|
'Ned', 'Ned4Tuple', 'Uvw', 'Uvw3Tuple', 'XyzLocal', 'Xyz4Tuple'),
|
|
323
|
-
mgrs=
|
|
324
|
-
named=
|
|
309
|
+
mgrs=_a('Mgrs', 'parseMGRS', 'toMgrs', 'Mgrs4Tuple', 'Mgrs6Tuple'),
|
|
310
|
+
named=_a('ADict',
|
|
325
311
|
'callername', 'classname', 'classnaming', 'modulename',
|
|
326
312
|
'nameof', 'notImplemented', 'notOverloaded'),
|
|
327
|
-
namedTuples=
|
|
313
|
+
namedTuples=_a('Bearing2Tuple', 'Bounds2Tuple', 'Bounds4Tuple',
|
|
328
314
|
'Destination2Tuple', 'Destination3Tuple',
|
|
329
315
|
'Distance2Tuple', 'Distance3Tuple', 'Distance4Tuple',
|
|
330
316
|
'EasNor2Tuple', 'EasNor3Tuple', 'Forward4Tuple', 'Intersection3Tuple',
|
|
@@ -336,47 +322,47 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
336
322
|
'Reverse4Tuple', 'Triangle7Tuple', 'Triangle8Tuple', 'Trilaterate5Tuple',
|
|
337
323
|
'UtmUps2Tuple', 'UtmUps5Tuple', 'UtmUps8Tuple', 'UtmUpsLatLon5Tuple',
|
|
338
324
|
'Vector2Tuple', 'Vector3Tuple', 'Vector4Tuple'),
|
|
339
|
-
nvectorBase=
|
|
340
|
-
osgr=
|
|
341
|
-
points=
|
|
325
|
+
nvectorBase=_a('NorthPole', 'SouthPole'),
|
|
326
|
+
osgr=_a('Osgr', 'OSGRError', 'parseOSGR', 'toOsgr'),
|
|
327
|
+
points=_a('LatLon_', 'LatLon2psxy', 'Numpy2LatLon', 'Shape2Tuple', 'Tuple2LatLon',
|
|
342
328
|
'areaOf', 'boundsOf', 'centroidOf', 'fractional',
|
|
343
329
|
'isclockwise', 'isconvex', 'isconvex_', 'isenclosedBy', 'ispolar',
|
|
344
330
|
'luneOf', 'nearestOn5', 'perimeterOf', 'quadOf'),
|
|
345
|
-
props=
|
|
331
|
+
props=_a('Property', 'Property_RO', 'property_doc_',
|
|
346
332
|
'property_RO', 'property_ROnce', 'property_ROver',
|
|
347
333
|
'deprecated_class', 'deprecated_function', 'deprecated_method',
|
|
348
334
|
'deprecated_Property_RO', 'deprecated_property_RO', 'DeprecationWarnings'),
|
|
349
|
-
resections=
|
|
335
|
+
resections=_a('Collins5Tuple', 'ResectionError', 'Survey3Tuple', 'Tienstra7Tuple',
|
|
350
336
|
'TriAngle5Tuple', 'TriSide2Tuple', 'TriSide4Tuple',
|
|
351
337
|
'cassini', 'collins5', 'pierlot', 'pierlotx', 'tienstra7',
|
|
352
338
|
'snellius3', 'wildberger3',
|
|
353
339
|
'triAngle', 'triAngle5', 'triArea', 'triSide', 'triSide2', 'triSide4'),
|
|
354
|
-
rhumb=
|
|
355
|
-
rhumb_aux_=
|
|
356
|
-
rhumb_ekx=
|
|
357
|
-
rhumb_solve=
|
|
358
|
-
sphericalBase=
|
|
359
|
-
sphericalNvector=
|
|
360
|
-
sphericalTrigonometry=
|
|
361
|
-
simplify=
|
|
362
|
-
solveBase=
|
|
363
|
-
streprs=
|
|
340
|
+
rhumb=_a(), # module only
|
|
341
|
+
rhumb_aux_=_a('RhumbAux', 'RhumbLineAux'),
|
|
342
|
+
rhumb_ekx=_a('Rhumb', 'RhumbLine'),
|
|
343
|
+
rhumb_solve=_a('RhumbSolve', 'RhumbLineSolve', 'RhumbSolve7Tuple'),
|
|
344
|
+
sphericalBase=_a(), # module only
|
|
345
|
+
sphericalNvector=_a(), # module only
|
|
346
|
+
sphericalTrigonometry=_a(), # module only
|
|
347
|
+
simplify=_a('simplify1', 'simplifyRDP', 'simplifyRDPm', 'simplifyRW', 'simplifyVW', 'simplifyVWm'),
|
|
348
|
+
solveBase=_a(), # module only
|
|
349
|
+
streprs=_a('anstr', 'attrs', 'enstr2', 'fstr', 'fstrzs', 'hstr', 'instr',
|
|
364
350
|
'lrstrip', 'pairs', 'reprs', 'strs', 'unstr'),
|
|
365
|
-
trf=
|
|
351
|
+
trf=_a('RefFrame', 'RefFrames', 'TransformXform', 'TRFXform', 'TRFXform7Tuple',
|
|
366
352
|
'date2epoch', 'epoch2date', 'trfTransform0', 'trfTransforms', 'trfXform'),
|
|
367
|
-
triaxials=
|
|
353
|
+
triaxials=_a('BetaOmega2Tuple', 'BetaOmega3Tuple', 'Jacobi2Tuple',
|
|
368
354
|
'JacobiConformal', 'JacobiConformalSpherical',
|
|
369
355
|
'Triaxial', 'Triaxial_', 'TriaxialError', 'Triaxials', 'hartzell4'),
|
|
370
|
-
units=
|
|
356
|
+
units=_a('Azimuth', 'Band', 'Bearing', 'Bearing_', 'Bool',
|
|
371
357
|
'Degrees', 'Degrees_', 'Degrees2', 'Distance', 'Distance_', 'Easting', 'Epoch',
|
|
372
358
|
'Feet', 'FIx', 'Float_', 'Height', 'Height_', 'HeightX', 'Int_',
|
|
373
359
|
'Lam', 'Lamd', 'Lat', 'Lat_', 'Lon', 'Lon_',
|
|
374
360
|
'Meter', 'Meter_', 'Meter2', 'Meter3', 'Northing', 'Number_',
|
|
375
361
|
'Phi', 'Phid', 'Precision_', 'Radians', 'Radians_', 'Radians2',
|
|
376
362
|
'Radius_', 'Scalar', 'Scalar_', 'Zone'),
|
|
377
|
-
unitsBase=
|
|
378
|
-
ups=
|
|
379
|
-
utily=
|
|
363
|
+
unitsBase=_a('Float', 'Int', 'Radius', 'Str'),
|
|
364
|
+
ups=_a('Ups', 'UPSError', 'parseUPS5', 'toUps8', 'upsZoneBand5'),
|
|
365
|
+
utily=_a('acos1', 'acre2ha', 'acre2m2', 'asin1', 'atan1', 'atan1d', 'atan2b', 'atan2d',
|
|
380
366
|
'chain2m', 'circle4', 'cot', 'cot_', 'cotd', 'cotd_',
|
|
381
367
|
'degrees', 'degrees90', 'degrees180', 'degrees360', 'degrees2grades', 'degrees2m',
|
|
382
368
|
# 'degrees2grades as degrees2gons',
|
|
@@ -391,32 +377,32 @@ _ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
|
|
|
391
377
|
'unroll180', 'unrollPI',
|
|
392
378
|
'wrap90', 'wrap180', 'wrap360', 'wrapPI_2', 'wrapPI', 'wrapPI2', 'wrap_normal',
|
|
393
379
|
'yard2m'),
|
|
394
|
-
utm=
|
|
395
|
-
utmups=
|
|
380
|
+
utm=_a('Utm', 'UTMError', 'parseUTM5', 'toUtm8', 'utmZoneBand5'),
|
|
381
|
+
utmups=_a('UtmUps', 'UTMUPSError', 'parseUTMUPS5', 'toUtmUps8',
|
|
396
382
|
'utmupsValidate', 'utmupsValidateOK', 'utmupsZoneBand5'),
|
|
397
|
-
utmupsBase=
|
|
398
|
-
vector2d=
|
|
383
|
+
utmupsBase=_a(), # module only
|
|
384
|
+
vector2d=_a('Circin6Tuple', 'Circum3Tuple', 'Circum4Tuple', 'Meeus2Tuple', 'Radii11Tuple', 'Soddy4Tuple', 'Triaxum5Tuple',
|
|
399
385
|
'circin6', 'circum3', 'circum4', 'circum4_', 'meeus2', 'radii11', 'soddy4', 'triaxum5', 'trilaterate2d2'),
|
|
400
|
-
vector3d=
|
|
386
|
+
vector3d=_a('Vector3d', 'intersection3d3', 'iscolinearWith', 'nearestOn', 'nearestOn6', 'parse3d',
|
|
401
387
|
'trilaterate3d2'),
|
|
402
|
-
vector3dBase=
|
|
403
|
-
webmercator=
|
|
404
|
-
wgrs=
|
|
388
|
+
vector3dBase=_a(), # module only
|
|
389
|
+
webmercator=_a('Wm', 'WebMercatorError', 'parseWM', 'toWm', 'EasNorRadius3Tuple'),
|
|
390
|
+
wgrs=_a('Georef', 'WGRSError'),)
|
|
405
391
|
|
|
406
392
|
_ALL_DEPRECATED = _NamedEnum_RO(_name='_ALL_DEPRECATED',
|
|
407
|
-
deprecated=
|
|
393
|
+
deprecated=_a('bases', 'datum', 'nvector', # DEPRECATED modules and ...
|
|
408
394
|
'rhumbaux', 'rhumbBase', 'rhumbsolve', 'rhumbx'), # ... names
|
|
409
|
-
deprecated_bases=
|
|
410
|
-
deprecated_classes=
|
|
395
|
+
deprecated_bases=_a('LatLonHeightBase', 'points2'),
|
|
396
|
+
deprecated_classes=_a('ClipCS3Tuple', 'EasNorExact4Tuple', 'EcefCartesian', 'Fn_rt',
|
|
411
397
|
'HeightIDW', 'HeightIDW2', 'HeightIDW3', 'Helmert7Tuple',
|
|
412
398
|
'Lam_', 'LatLonExact4Tuple', 'NearestOn4Tuple', 'Ned3Tuple',
|
|
413
399
|
'Phi_', 'RefFrameError', 'Rhumb7Tuple', 'RhumbOrder2Tuple',
|
|
414
400
|
'Transform7Tuple', 'TriAngle4Tuple', 'UtmUps4Tuple', 'XDist'),
|
|
415
|
-
deprecated_consterns=
|
|
416
|
-
deprecated_datum=
|
|
401
|
+
deprecated_consterns=_a('EPS1_2', 'MANTIS', 'OK'),
|
|
402
|
+
deprecated_datum=_a('Curvature2Tuple', 'Datum', 'Ellipsoid', 'Transform', # assert
|
|
417
403
|
'Datums', 'Ellipsoids', 'Transforms',
|
|
418
404
|
'R_FM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_SM', 'R_VM'),
|
|
419
|
-
deprecated_functions=
|
|
405
|
+
deprecated_functions=_a('anStr', 'areaof', 'atand', 'bounds', # most of the DEPRECATED functions, except ellipsoidal ...
|
|
420
406
|
'clipCS3', 'clipDMS', 'clipStr', 'collins', 'copysign', # ... and spherical flavors
|
|
421
407
|
'decodeEPSG2', 'encodeEPSG', 'enStr2', 'equirectangular_', 'equirectangular3',
|
|
422
408
|
'excessAbc', 'excessGirard', 'excessLHuilier',
|
|
@@ -426,7 +412,7 @@ _ALL_DEPRECATED = _NamedEnum_RO(_name='_ALL_DEPRECATED',
|
|
|
426
412
|
'parseUTM', 'perimeterof', 'polygon', 'scalar', 'simplify2',
|
|
427
413
|
'tienstra', 'toUtm', 'triAngle4',
|
|
428
414
|
'unsign0', 'unStr', 'utmZoneBand2'),
|
|
429
|
-
deprecated_nvector=
|
|
415
|
+
deprecated_nvector=_a('LatLonNvectorBase', 'Nvector', 'sumOf', 'NorthPole', 'SouthPole'),)
|
|
430
416
|
|
|
431
417
|
|
|
432
418
|
class _ALL_MODS(_internals._MODS_Base):
|
|
@@ -445,7 +431,7 @@ class _ALL_MODS(_internals._MODS_Base):
|
|
|
445
431
|
v = _lazy_dict[name] # package.__dict__
|
|
446
432
|
except KeyError:
|
|
447
433
|
v = _lazy_module(name) # package.__getattr__
|
|
448
|
-
if _tailof(
|
|
434
|
+
if _tailof(_DUNDER_nameof(v)) != name:
|
|
449
435
|
try:
|
|
450
436
|
v = getattr(v, _tailof(name))
|
|
451
437
|
except AttributeError:
|
|
@@ -479,7 +465,7 @@ class _ALL_MODS(_internals._MODS_Base):
|
|
|
479
465
|
|
|
480
466
|
@raise ImportError: Importing module B{C{name}} failed.
|
|
481
467
|
'''
|
|
482
|
-
if _headof(name) != parent and not
|
|
468
|
+
if _headof(name) != parent and not _is_DUNDER_main(name):
|
|
483
469
|
name = _DOT_(parent, name)
|
|
484
470
|
try:
|
|
485
471
|
return _sys.modules[name]
|
|
@@ -491,14 +477,14 @@ class _ALL_MODS(_internals._MODS_Base):
|
|
|
491
477
|
'''
|
|
492
478
|
return _sys.modules.get(name, None)
|
|
493
479
|
|
|
494
|
-
def into(self, **
|
|
495
|
-
'''Lazily import module C{mod} into module C{
|
|
496
|
-
and set C{
|
|
480
|
+
def into(self, **mod_DUNDER_name):
|
|
481
|
+
'''Lazily import module C{mod} into module C{DUNDER_name}
|
|
482
|
+
and set C{DUNDER_name._mod} to module C{mod}, I{once}.
|
|
497
483
|
'''
|
|
498
484
|
class _Into(object):
|
|
499
485
|
|
|
500
486
|
def __getattr__(unused, name):
|
|
501
|
-
mod, dun = self.errors._xkwds_item2(
|
|
487
|
+
mod, dun = self.errors._xkwds_item2(mod_DUNDER_name)
|
|
502
488
|
_mod = _UNDER_(NN, mod)
|
|
503
489
|
d = self.getmodule(dun) # '__main__' OK
|
|
504
490
|
i = _getattribute(d, _mod, dun)
|
|
@@ -518,29 +504,28 @@ class _ALL_MODS(_internals._MODS_Base):
|
|
|
518
504
|
def items(self): # no module named 'items'
|
|
519
505
|
'''Yield the modules imported so far.
|
|
520
506
|
'''
|
|
521
|
-
_hd = _headof
|
|
522
507
|
for n, m in _sys.modules.items():
|
|
523
|
-
if
|
|
508
|
+
if _headof(n) == _pygeodesy_:
|
|
524
509
|
yield n, m
|
|
525
510
|
|
|
526
511
|
_internals._MODS = _ALL_MODS = _ALL_MODS() # PYCHOK singleton
|
|
527
512
|
|
|
528
513
|
__all__ = _ALL_LAZY.lazily
|
|
529
|
-
__version__ = '24.
|
|
514
|
+
__version__ = '24.10.15'
|
|
530
515
|
|
|
531
516
|
|
|
532
517
|
def _ALL_OTHER(*objs):
|
|
533
518
|
'''(INTERNAL) Get class and function B{C{objs}} for __all__.
|
|
534
519
|
'''
|
|
535
520
|
def _interned(o): # intern'd base name
|
|
536
|
-
n = _tailof(
|
|
521
|
+
n = _tailof(_DUNDER_nameof(o))
|
|
537
522
|
i = NN(_UNDER_, n, _UNDER_) # intern'd
|
|
538
523
|
return getattr(_interns, i, n)
|
|
539
524
|
|
|
540
525
|
return tuple(map(_interned, objs)) # map2
|
|
541
526
|
|
|
542
527
|
|
|
543
|
-
if _FOR_DOCS:
|
|
528
|
+
if _FOR_DOCS: # PYCHOK no cover
|
|
544
529
|
_ALL_DOCS = _ALL_OTHER
|
|
545
530
|
# (INTERNAL) Only export B{C{objs.__name__}} when making the
|
|
546
531
|
# docs to force C{epydoc} to include certain classes, methods,
|
|
@@ -588,7 +573,14 @@ def _all_missing2(_all_):
|
|
|
588
573
|
_alzy = _Dict((a, a) for a in _ALL_INIT)
|
|
589
574
|
_alzy.update(_all_imports()) # without _all_backups!
|
|
590
575
|
return ((_DOT_(_lazily_, _all_imports.__name__), _diff(_all_, _alzy)),
|
|
591
|
-
(_DOT_(_pygeodesy_,
|
|
576
|
+
(_DOT_(_pygeodesy_, _DUNDER_all_), _diff(_alzy.keys(), _all_)))
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def _getattras(attr_as): # test/testDeprecated
|
|
580
|
+
'''(INTERNAL) Get the C{"as name"} or C{"name"} of a lazy entry.
|
|
581
|
+
'''
|
|
582
|
+
a_, _, as_ = attr_as.partition(_asSPACED_)
|
|
583
|
+
return as_ or a_.rstrip(_DOT_)
|
|
592
584
|
|
|
593
585
|
|
|
594
586
|
def _getattribute(m, name, mod=_pygeodesy_):
|
|
@@ -602,13 +594,6 @@ def _getattribute(m, name, mod=_pygeodesy_):
|
|
|
602
594
|
raise LazyAttributeError(_no_(_attribute_), txt=name)
|
|
603
595
|
|
|
604
596
|
|
|
605
|
-
def _getattrof(attr_as): # .testDeprecated
|
|
606
|
-
'''(INTERNAL) Get the C{"as name"} or C{"name"} of a lazy entry.
|
|
607
|
-
'''
|
|
608
|
-
a_, _, as_ = attr_as.partition(__as__)
|
|
609
|
-
return as_ or a_.rstrip(_DOT_)
|
|
610
|
-
|
|
611
|
-
|
|
612
597
|
def _getmodule(name, *parent):
|
|
613
598
|
'''(INTERNAL) Wrapper for C{import_module}.
|
|
614
599
|
'''
|
|
@@ -619,18 +604,18 @@ def _getmodule(name, *parent):
|
|
|
619
604
|
raise LazyImportError(_no_(_module_), txt=name)
|
|
620
605
|
|
|
621
606
|
|
|
622
|
-
# def _lazy_attributes(
|
|
607
|
+
# def _lazy_attributes(DUNDER_name):
|
|
623
608
|
# '''(INTERNAL) Return a function to C{B{__name__}.__getattr__(attr)}
|
|
624
609
|
# on lazily imported modules and sub-modules.
|
|
625
610
|
# '''
|
|
626
611
|
# if _unlazy:
|
|
627
|
-
# raise AssertionError(_COMMASPACE_(
|
|
612
|
+
# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
|
|
628
613
|
#
|
|
629
614
|
# def _getattr(attr, *dflt):
|
|
630
615
|
# try: # a module name
|
|
631
616
|
# return _ALL_MODS.getmodule(attr)
|
|
632
617
|
# except (AttributeError, ImportError):
|
|
633
|
-
# return _ALL_MODS.getattr(
|
|
618
|
+
# return _ALL_MODS.getattr(DUNDER_name, attr, *dflt)
|
|
634
619
|
#
|
|
635
620
|
# return _getattr
|
|
636
621
|
|
|
@@ -664,19 +649,22 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
664
649
|
U{PEP 562<https://www.Python.org/dev/peps/pep-0562>} and the
|
|
665
650
|
U{new way<https://Snarky.Ca/lazy-importing-in-python-3-7/>}.
|
|
666
651
|
'''
|
|
667
|
-
_DOT_
|
|
668
|
-
_SPACE_
|
|
652
|
+
_DOT_ = _interns._DOT_
|
|
653
|
+
_SPACE_ = _interns._SPACE_
|
|
669
654
|
|
|
670
|
-
if pack != _pygeodesy_ or _unlazy: # Python 3.7+
|
|
671
|
-
t =
|
|
672
|
-
raise LazyImportError(t, txt=
|
|
655
|
+
if pack != _pygeodesy_ or _unlazy: # Python 3.7+ # PYCHOK no cover
|
|
656
|
+
t = _DOT_(pack, _DUNDER_nameof(_lazy_import2))
|
|
657
|
+
raise LazyImportError(_no_(t), txt=_versions())
|
|
673
658
|
|
|
674
|
-
package, parent
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
659
|
+
package, parent = _lazy_init2(pack) # _pygeodesy_
|
|
660
|
+
|
|
661
|
+
_DUNDER_package_ = '__package__'
|
|
662
|
+
_lazily_imported_ = _SPACE_(_HASH_, _lazily_, 'imported', parent)
|
|
663
|
+
|
|
664
|
+
sub_packages = set((parent, NN) + tuple(
|
|
665
|
+
_DOT_(parent, s) for s in _SUB_PACKAGES))
|
|
666
|
+
imports = _all_imports()
|
|
667
|
+
deprecates = _all_deprecates()
|
|
680
668
|
|
|
681
669
|
def __getattr__(name): # __getattr__ only for Python 3.7+
|
|
682
670
|
# only called once for each undefined pygeodesy attribute
|
|
@@ -690,13 +678,13 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
690
678
|
else: # from mod import name
|
|
691
679
|
attr = name
|
|
692
680
|
v = _getmodule(_DOT_(pack, mod), parent)
|
|
693
|
-
t = getattr(v,
|
|
681
|
+
t = getattr(v, _DUNDER_package_, None)
|
|
694
682
|
if t not in sub_packages: # invalid module package
|
|
695
|
-
raise LazyImportError(_DOT_(mod,
|
|
683
|
+
raise LazyImportError(_DOT_(mod, _DUNDER_package_), t)
|
|
696
684
|
if attr: # get mod.attr
|
|
697
685
|
v = _getattribute(v, attr, mod)
|
|
698
686
|
|
|
699
|
-
elif name in (
|
|
687
|
+
elif name in (_DUNDER_all_,): # XXX _DUNDER_dir_, _DUNDER_members_?
|
|
700
688
|
v = _ALL_INIT + tuple(imports.keys())
|
|
701
689
|
else: # PYCHOK no cover
|
|
702
690
|
t = _no_(_module_, _or_, _attribute_)
|
|
@@ -705,7 +693,7 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
705
693
|
|
|
706
694
|
setattr(package, name, v) # package.__dict__[name] = val
|
|
707
695
|
if isLazy > 1:
|
|
708
|
-
t =
|
|
696
|
+
t = _DOT_(_lazily_imported_, name)
|
|
709
697
|
if mod and _tailof(mod) != name:
|
|
710
698
|
t = _SPACE_(t, _from_, _DOT_(NN, mod))
|
|
711
699
|
if isLazy > 2:
|
|
@@ -725,24 +713,24 @@ def _lazy_import2(pack): # MCCABE 14
|
|
|
725
713
|
return package, __getattr__ # _lazy_import2
|
|
726
714
|
|
|
727
715
|
|
|
728
|
-
# def _lazy_import_all(
|
|
716
|
+
# def _lazy_import_all(DUNDER_name):
|
|
729
717
|
# '''(INTERNAL) Return a function mimicking C{from B{__name__} import *},
|
|
730
718
|
# of all items, see .deprecated.__init__
|
|
731
719
|
# '''
|
|
732
720
|
# if _unlazy:
|
|
733
|
-
# raise AssertionError(_COMMASPACE_(
|
|
721
|
+
# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
|
|
734
722
|
#
|
|
735
|
-
# _getattr = _lazy_attributes(
|
|
736
|
-
# _import_start = _lazy_import_star(
|
|
723
|
+
# _getattr = _lazy_attributes(DUNDER_name) # __name__.__getattr__
|
|
724
|
+
# _import_start = _lazy_import_star(DUNDER_name, ALL_=_ALL_IMPORTS)
|
|
737
725
|
#
|
|
738
726
|
# def _import_all(attr, *dflt):
|
|
739
|
-
# return _import_star(
|
|
727
|
+
# return _import_star(DUNDER_name) if attr == _DUNDER_all_ else \
|
|
740
728
|
# _getattr(attr, *dflt)
|
|
741
729
|
#
|
|
742
730
|
# return _import_all
|
|
743
731
|
|
|
744
732
|
|
|
745
|
-
def _lazy_import_as(
|
|
733
|
+
def _lazy_import_as(DUNDER_name):
|
|
746
734
|
'''(INTERNAL) Return a function to C{import B{__name__}.mod as mod}
|
|
747
735
|
I{of modules only}, see .deprecated, .rhumb or get an attribute
|
|
748
736
|
lazily exported by C{__name__}.
|
|
@@ -752,29 +740,28 @@ def _lazy_import_as(_dunder_name_):
|
|
|
752
740
|
|
|
753
741
|
def _import_as(mod):
|
|
754
742
|
try:
|
|
755
|
-
return _ALL_MODS.getmodule(_DOT_(
|
|
743
|
+
return _ALL_MODS.getmodule(_DOT_(DUNDER_name, mod))
|
|
756
744
|
except ImportError:
|
|
757
745
|
return _lazy_module(mod)
|
|
758
746
|
|
|
759
747
|
return _import_as
|
|
760
748
|
|
|
761
749
|
|
|
762
|
-
# def _lazy_import_star(
|
|
750
|
+
# def _lazy_import_star(DUNDER_name, ALL_=_ALL_DEPRECATES):
|
|
763
751
|
# '''(INTERNAL) Return a function to mimick C{from B{__name__} import *},
|
|
764
752
|
# of all DEPRECATED items, see .deprecated, .testDeprecated
|
|
765
753
|
# '''
|
|
766
754
|
# if _unlazy:
|
|
767
|
-
# raise AssertionError(_COMMASPACE_(
|
|
755
|
+
# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
|
|
768
756
|
#
|
|
769
757
|
# def _import_star(_into_):
|
|
770
758
|
# '''Do C{from B{__name__} import *} inside module C{B{__into__}}.
|
|
771
759
|
# '''
|
|
772
760
|
# d = dict()
|
|
773
|
-
# nm = _tailof(
|
|
761
|
+
# nm = _tailof(DUNDER_name)
|
|
774
762
|
# _g = _ALL_MODS.getattr # pygeodesy.__getattr__
|
|
775
|
-
# _h = _headof
|
|
776
763
|
# for a, m in ALL_.items():
|
|
777
|
-
# if
|
|
764
|
+
# if _headof(m) == nm:
|
|
778
765
|
# try:
|
|
779
766
|
# d[a] = _g(m, a)
|
|
780
767
|
# except (AttributeError, ImportError):
|
|
@@ -803,18 +790,19 @@ def _lazy_init2(pack):
|
|
|
803
790
|
'''
|
|
804
791
|
global isLazy, _unLazy0
|
|
805
792
|
|
|
806
|
-
z =
|
|
807
|
-
if z is None: #
|
|
808
|
-
isLazy = 1 # ...
|
|
793
|
+
z = _getPYGEODESY('LAZY_IMPORT', None)
|
|
794
|
+
if z is None: # not set, but ...
|
|
795
|
+
isLazy = 1 # ... default on 3.7+
|
|
809
796
|
else:
|
|
810
797
|
z = z.strip() # like PYTHONVERBOSE et.al.
|
|
811
798
|
isLazy = int(z) if z.isdigit() else (1 if z else 0)
|
|
812
799
|
|
|
813
800
|
_unLazy0 = _unlazy or not isLazy # pre-3.7 or w/o lazy import
|
|
814
801
|
|
|
815
|
-
if isLazy < 1: # not enabled
|
|
816
|
-
|
|
817
|
-
|
|
802
|
+
if isLazy < 1: # invalid, not enabled
|
|
803
|
+
e = _internals._PYGEODESY('LAZY_IMPORT')
|
|
804
|
+
raise LazyImportError(e, repr(z), txt_not_='enabled')
|
|
805
|
+
if _sys.flags.verbose: # PYCHOK no cover
|
|
818
806
|
isLazy += 1
|
|
819
807
|
|
|
820
808
|
try: # to initialize in Python 3+
|
|
@@ -826,7 +814,8 @@ def _lazy_init2(pack):
|
|
|
826
814
|
|
|
827
815
|
except (AttributeError, ImportError) as x:
|
|
828
816
|
isLazy = False # failed
|
|
829
|
-
|
|
817
|
+
z = _DUNDER_nameof(_lazy_init2)
|
|
818
|
+
raise LazyImportError(z, pack, cause=x)
|
|
830
819
|
|
|
831
820
|
return package, parent
|
|
832
821
|
|
|
@@ -842,19 +831,19 @@ def _lazy_module(name): # overwritten by _lazy_import2
|
|
|
842
831
|
return m
|
|
843
832
|
|
|
844
833
|
|
|
845
|
-
# def _lazy_subs(
|
|
834
|
+
# def _lazy_subs(DUNDER_name, force=_FOR_DOCS, over=False):
|
|
846
835
|
# '''(INTERNAL) Return the names of a package's sub-packages and
|
|
847
836
|
# update the package's C{__dict__} accordingly.
|
|
848
837
|
# '''
|
|
849
838
|
# sm = dict()
|
|
850
|
-
# if force and not
|
|
851
|
-
# nm = _tailof(
|
|
839
|
+
# if force and not _is_DUNDER_main(DUNDER_name):
|
|
840
|
+
# nm = _tailof(DUNDER_name)
|
|
852
841
|
# _a = _ALL_MODS.getattr
|
|
853
842
|
# _m = _ALL_MODS.getmodule
|
|
854
|
-
# d = _a(
|
|
855
|
-
# for n in _a(
|
|
843
|
+
# d = _a(DUNDER_name, _DUNDER_dict_, {})
|
|
844
|
+
# for n in _a(DUNDER_name, _DUNDER_all_, ()):
|
|
856
845
|
# try: # n is a class name, get its mod name
|
|
857
|
-
# m = _a(
|
|
846
|
+
# m = _a(DUNDER_name, n).__module__
|
|
858
847
|
# n, s = m.split(_DOT_)[-2:]
|
|
859
848
|
# if n == nm and s not in sm:
|
|
860
849
|
# # like import m as s
|
|
@@ -866,44 +855,47 @@ def _lazy_module(name): # overwritten by _lazy_import2
|
|
|
866
855
|
#
|
|
867
856
|
# return _ALL_OTHER(*sm.values())
|
|
868
857
|
|
|
869
|
-
# del
|
|
858
|
+
# del _a, _a0
|
|
870
859
|
|
|
871
|
-
|
|
860
|
+
if _is_DUNDER_main(__name__): # PYCHOK no cover
|
|
872
861
|
|
|
873
|
-
|
|
862
|
+
def _main():
|
|
863
|
+
from timeit import timeit
|
|
874
864
|
|
|
875
|
-
|
|
876
|
-
|
|
865
|
+
def t1():
|
|
866
|
+
from pygeodesy.trf import RefFrame
|
|
867
|
+
return RefFrame
|
|
877
868
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
return RefFrame
|
|
869
|
+
def t2():
|
|
870
|
+
return _ALL_MODS.trf.RefFrame
|
|
881
871
|
|
|
882
|
-
|
|
883
|
-
return _ALL_MODS.trf.RefFrame
|
|
872
|
+
assert t1() is t2() # prime each
|
|
884
873
|
|
|
885
|
-
|
|
874
|
+
t1 = timeit(t1, number=1000000)
|
|
875
|
+
t2 = timeit(t2, number=1000000)
|
|
876
|
+
A = _DUNDER_nameof(_ALL_MODS.__class__)
|
|
877
|
+
v = _versions()
|
|
878
|
+
printf('%.6f import vs %.6f %s: %.2fX, %s', t1, t2, A, (t1 / t2), v)
|
|
886
879
|
|
|
887
|
-
|
|
888
|
-
t2 = timeit(t2, number=1000000)
|
|
889
|
-
printf('%.6f import vs %.6f _ALL_MODS: %.2fX, %s', t1, t2, t1 / t2, _versions())
|
|
890
|
-
|
|
891
|
-
# del t1, t2, timeit, v
|
|
880
|
+
_main()
|
|
892
881
|
|
|
893
882
|
# % python3.13 -W ignore -m pygeodesy.lazily
|
|
894
|
-
# 0.
|
|
883
|
+
# 0.106602 import vs 0.078136 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.13.0 64bit arm64 macOS 14.6.1
|
|
895
884
|
|
|
896
885
|
# % python3.12 -W ignore -m pygeodesy.lazily
|
|
897
|
-
# 0.
|
|
886
|
+
# 0.138844 import vs 0.080458 _ALL_MODS: 1.73X, pygeodesy 24.10.24 Python 3.12.7 64bit arm64 macOS 14.6.1
|
|
898
887
|
|
|
899
888
|
# % python3.11 -W ignore -m pygeodesy.lazily
|
|
900
|
-
# 0.
|
|
889
|
+
# 0.387520 import vs 0.254229 _ALL_MODS: 1.52X, pygeodesy 24.10.24 Python 3.11.5 64bit arm64 macOS 14.6.1
|
|
890
|
+
|
|
891
|
+
# % python3.10 -W ignore -m pygeodesy.lazily
|
|
892
|
+
# 0.371269 import vs 0.272897 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.10.8 64bit arm64 macOS 14.6.1
|
|
901
893
|
|
|
902
894
|
# % python3.8 -W ignore -m pygeodesy.lazily
|
|
903
|
-
# 0.
|
|
895
|
+
# 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
|
|
904
896
|
|
|
905
897
|
# % python2 -m pygeodesy.lazily
|
|
906
|
-
# 1.
|
|
898
|
+
# 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
|
|
907
899
|
|
|
908
900
|
# **) MIT License
|
|
909
901
|
#
|