pygeodesy 24.5.8__py2.py3-none-any.whl → 24.5.15__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.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/METADATA +2 -2
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/RECORD +51 -50
- pygeodesy/__init__.py +16 -12
- pygeodesy/__main__.py +9 -10
- pygeodesy/albers.py +2 -2
- pygeodesy/auxilats/__main__.py +7 -10
- pygeodesy/auxilats/auxLat.py +2 -1
- pygeodesy/basics.py +158 -171
- pygeodesy/booleans.py +4 -4
- pygeodesy/constants.py +8 -6
- pygeodesy/datums.py +9 -8
- pygeodesy/ecef.py +5 -4
- pygeodesy/elevations.py +2 -2
- pygeodesy/ellipsoidalBaseDI.py +7 -5
- pygeodesy/elliptic.py +10 -7
- pygeodesy/errors.py +6 -6
- pygeodesy/etm.py +3 -2
- pygeodesy/fmath.py +13 -12
- pygeodesy/fstats.py +32 -33
- pygeodesy/fsums.py +103 -89
- pygeodesy/geodesicw.py +14 -14
- pygeodesy/geodesicx/__main__.py +4 -4
- pygeodesy/geodesicx/gxarea.py +4 -4
- pygeodesy/geodsolve.py +3 -2
- pygeodesy/geoids.py +6 -6
- pygeodesy/heights.py +4 -4
- pygeodesy/internals.py +571 -0
- pygeodesy/interns.py +4 -202
- pygeodesy/iters.py +3 -2
- pygeodesy/karney.py +4 -4
- pygeodesy/ktm.py +7 -7
- pygeodesy/lazily.py +139 -217
- pygeodesy/mgrs.py +3 -2
- pygeodesy/named.py +13 -10
- pygeodesy/nvectorBase.py +4 -3
- pygeodesy/osgr.py +14 -12
- pygeodesy/points.py +5 -5
- pygeodesy/props.py +7 -7
- pygeodesy/rhumb/bases.py +3 -2
- pygeodesy/rhumb/solve.py +2 -2
- pygeodesy/solveBase.py +3 -2
- pygeodesy/streprs.py +5 -4
- pygeodesy/trf.py +4 -4
- pygeodesy/units.py +15 -17
- pygeodesy/ups.py +7 -6
- pygeodesy/utily.py +4 -4
- pygeodesy/utm.py +5 -4
- pygeodesy/utmupsBase.py +4 -3
- pygeodesy/vector3dBase.py +2 -1
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/WHEEL +0 -0
- {PyGeodesy-24.5.8.dist-info → PyGeodesy-24.5.15.dist-info}/top_level.txt +0 -0
pygeodesy/constants.py
CHANGED
|
@@ -9,12 +9,13 @@ L{pygeodesy.isnon0} and L{pygeodesy.remainder}.
|
|
|
9
9
|
# make sure int/int division yields float quotient, see .basics
|
|
10
10
|
from __future__ import division as _; del _ # PYCHOK semicolon
|
|
11
11
|
|
|
12
|
-
from pygeodesy.basics import
|
|
12
|
+
from pygeodesy.basics import _copysign, isbool, iscomplex, isint, _0_0
|
|
13
13
|
from pygeodesy.errors import _xError, _xError2, _xkwds_get, _xkwds_item2
|
|
14
|
+
# from pygeodesy.internals import _0_0 # from .basics
|
|
14
15
|
from pygeodesy.interns import _INF_, _NAN_, _UNDER_
|
|
15
|
-
# from pygeodesy.lazily import _ALL_LAZY # from .
|
|
16
|
+
# from pygeodesy.lazily import _ALL_LAZY # from .unitsBase
|
|
16
17
|
# from pygeodesy.streprs import Fmt # from .unitsBase
|
|
17
|
-
from pygeodesy.unitsBase import Float, Int, Radius, Fmt
|
|
18
|
+
from pygeodesy.unitsBase import Float, Int, Radius, _ALL_LAZY, Fmt
|
|
18
19
|
|
|
19
20
|
from math import fabs, isinf, isnan, pi as _PI, sqrt
|
|
20
21
|
try:
|
|
@@ -23,7 +24,7 @@ except ImportError: # Python 2-
|
|
|
23
24
|
_inf, _nan = float(_INF_), float(_NAN_)
|
|
24
25
|
|
|
25
26
|
__all__ = _ALL_LAZY.constants
|
|
26
|
-
__version__ = '24.
|
|
27
|
+
__version__ = '24.05.14'
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
def _copysign_0_0(y):
|
|
@@ -355,8 +356,9 @@ def isint0(obj, both=False):
|
|
|
355
356
|
@return: C{True} if B{C{obj}} is L{INT0}, C{int(0)} or
|
|
356
357
|
C{float(0)}, C{False} otherwise.
|
|
357
358
|
'''
|
|
358
|
-
return (obj is INT0 or obj is int(0) or
|
|
359
|
-
|
|
359
|
+
return (obj is INT0 or obj is int(0) or
|
|
360
|
+
bool(both and (not obj) and isint(obj, both=True))) and \
|
|
361
|
+
not isbool(obj)
|
|
360
362
|
|
|
361
363
|
|
|
362
364
|
def isnear0(x, eps0=EPS0):
|
pygeodesy/datums.py
CHANGED
|
@@ -67,7 +67,7 @@ datum, q.v. U{"A Guide to Coordinate Systems in Great Britain", Section 6
|
|
|
67
67
|
# make sure int/int division yields float quotient, see .basics
|
|
68
68
|
from __future__ import division as _; del _ # PYCHOK semicolon
|
|
69
69
|
|
|
70
|
-
from pygeodesy.basics import islistuple, map2, neg,
|
|
70
|
+
from pygeodesy.basics import islistuple, map2, neg, _xinstanceof, _zip
|
|
71
71
|
from pygeodesy.constants import R_M, _float as _F, _0_0, _1_0, _2_0, _8_0, _3600_0
|
|
72
72
|
# from pygeodesy.ellipsoidalBase import CartesianEllipsoidalBase as _CEB, \
|
|
73
73
|
# LatLonEllipsoidalBase as _LLEB # MODS
|
|
@@ -76,12 +76,13 @@ from pygeodesy.ellipsoids import a_f2Tuple, Ellipsoid, Ellipsoid2, Ellipsoids, _
|
|
|
76
76
|
from pygeodesy.errors import _IsnotError, _TypeError, _xattr, _xellipsoidall, _xkwds, \
|
|
77
77
|
_xkwds_pop2
|
|
78
78
|
from pygeodesy.fmath import fdot, fmean, Fmt, _operator
|
|
79
|
+
from pygeodesy.internals import _passarg, _under
|
|
79
80
|
from pygeodesy.interns import NN, _a_, _Airy1830_, _AiryModified_, _BAR_, _Bessel1841_, \
|
|
80
|
-
_Clarke1866_, _Clarke1880IGN_, _COMMASPACE_, _DOT_, \
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
_Clarke1866_, _Clarke1880IGN_, _COMMASPACE_, _DOT_, _earth_, \
|
|
82
|
+
_ellipsoid_, _ellipsoidal_, _GRS80_, _Intl1924_, _MINUS_, \
|
|
83
|
+
_Krassovski1940_, _Krassowsky1940_, _NAD27_, _NAD83_, _s_, \
|
|
84
|
+
_PLUS_, _Sphere_, _spherical_, _transform_, _UNDER_, \
|
|
85
|
+
_WGS72_, _WGS84_
|
|
85
86
|
from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS
|
|
86
87
|
from pygeodesy.named import _NamedEnum, _NamedEnumItem, _lazyNamedEnumItem as _lazy
|
|
87
88
|
# from pygeodesy.namedTuples import Vector3Tuple # from .ellipsoids
|
|
@@ -93,7 +94,7 @@ from pygeodesy.units import _isRadius, Radius_, radians
|
|
|
93
94
|
# import operator as _operator # from .fmath
|
|
94
95
|
|
|
95
96
|
__all__ = _ALL_LAZY.datums
|
|
96
|
-
__version__ = '24.
|
|
97
|
+
__version__ = '24.05.14'
|
|
97
98
|
|
|
98
99
|
_a_ellipsoid_ = _UNDER_(_a_, _ellipsoid_)
|
|
99
100
|
_BD72_ = 'BD72'
|
|
@@ -722,7 +723,7 @@ assert _WGS84.ellipsoid is _EWGS84
|
|
|
722
723
|
if __name__ == '__main__':
|
|
723
724
|
|
|
724
725
|
from pygeodesy.interns import _COMMA_, _NL_, _NLATvar_
|
|
725
|
-
from pygeodesy
|
|
726
|
+
from pygeodesy import printf
|
|
726
727
|
|
|
727
728
|
# __doc__ of this file, force all into registery
|
|
728
729
|
for r in (Datums, Transforms):
|
pygeodesy/ecef.py
CHANGED
|
@@ -86,7 +86,7 @@ from pygeodesy.utily import atan1, atan1d, atan2d, degrees90, degrees180, \
|
|
|
86
86
|
from math import atan2, cos, degrees, fabs, radians, sqrt
|
|
87
87
|
|
|
88
88
|
__all__ = _ALL_LAZY.ecef
|
|
89
|
-
__version__ = '24.05.
|
|
89
|
+
__version__ = '24.05.10'
|
|
90
90
|
|
|
91
91
|
_Ecef_ = 'Ecef'
|
|
92
92
|
_prolate_ = 'prolate'
|
|
@@ -646,7 +646,7 @@ class EcefSudano(_EcefBase):
|
|
|
646
646
|
|
|
647
647
|
_a = fabs
|
|
648
648
|
lat = atan1d(z, R * E.e21)
|
|
649
|
-
sa, ca = sincos2d(
|
|
649
|
+
sa, ca = sincos2d(_a(lat))
|
|
650
650
|
# Sudano's Eq (A-6) and (A-7) refactored/reduced,
|
|
651
651
|
# replacing Rn from Eq (A-4) with n = E.a / ca:
|
|
652
652
|
# N = ca**2 * ((z + E.e2 * n * sa) * ca - R * sa)
|
|
@@ -656,17 +656,18 @@ class EcefSudano(_EcefBase):
|
|
|
656
656
|
# = ca**2 * (E.e2 * E.a / E.e2s2(sa) - R / ca**2)
|
|
657
657
|
# N / D = (z * ca + (E.e2 * E.a - R) * sa) /
|
|
658
658
|
# (E.e2 * E.a / E.e2s2(sa) - R / ca**2)
|
|
659
|
+
_E = EPS_2
|
|
659
660
|
tol = self.tolerance
|
|
660
661
|
_S2 = Fsum(sa).fsum2f_
|
|
661
662
|
_rt = sqrt
|
|
662
663
|
for i in range(1, _TRIPS):
|
|
663
664
|
ca2 = _1_0 - sa**2
|
|
664
|
-
if ca2 <
|
|
665
|
+
if ca2 < _E: # PYCHOK no cover
|
|
665
666
|
ca = _0_0
|
|
666
667
|
break
|
|
667
668
|
ca = _rt(ca2)
|
|
668
669
|
r = e / E.e2s2(sa) - R / ca2
|
|
669
|
-
if _a(r) <
|
|
670
|
+
if _a(r) < _E:
|
|
670
671
|
break
|
|
671
672
|
lat = None
|
|
672
673
|
sa, r = _S2(-z * ca / r, -d * sa / r)
|
pygeodesy/elevations.py
CHANGED
|
@@ -34,7 +34,7 @@ from pygeodesy.units import Lat, Lon, Meter, Scalar, Str
|
|
|
34
34
|
# from math import fabs # from .karney
|
|
35
35
|
|
|
36
36
|
__all__ = _ALL_LAZY.elevations
|
|
37
|
-
__version__ = '
|
|
37
|
+
__version__ = '24.05.13'
|
|
38
38
|
|
|
39
39
|
try:
|
|
40
40
|
from urllib2 import urlopen # quote, urlcleanup
|
|
@@ -245,7 +245,7 @@ def geoidHeight2(lat, lon, model=0, timeout=2.0):
|
|
|
245
245
|
|
|
246
246
|
if __name__ == '__main__':
|
|
247
247
|
|
|
248
|
-
from pygeodesy
|
|
248
|
+
from pygeodesy import printf
|
|
249
249
|
# <https://WikiPedia.org/wiki/Mount_Diablo>
|
|
250
250
|
for f in (elevation2, # (1173.79, '3DEP 1/3 arc-second')
|
|
251
251
|
geoidHeight2): # (-31.699, u'GEOID12B')
|
pygeodesy/ellipsoidalBaseDI.py
CHANGED
|
@@ -17,10 +17,12 @@ from pygeodesy.errors import _AssertionError, IntersectionError, _IsnotError, \
|
|
|
17
17
|
from pygeodesy.fmath import favg, fmean_
|
|
18
18
|
from pygeodesy.fsums import Fmt, fsumf_
|
|
19
19
|
from pygeodesy.formy import _isequalTo, opposing, _radical2
|
|
20
|
-
from pygeodesy.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
# from pygeodesy.internals import _dunder_nameof # from .lazily
|
|
21
|
+
from pygeodesy.interns import _antipodal_, _concentric_, _ellipsoidal_, \
|
|
22
|
+
_exceed_PI_radians_, _low_, _near_, \
|
|
23
|
+
_SPACE_, _too_
|
|
24
|
+
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS, \
|
|
25
|
+
_dunder_nameof
|
|
24
26
|
from pygeodesy.namedTuples import Bearing2Tuple, Destination2Tuple, \
|
|
25
27
|
Intersection3Tuple, NearestOn2Tuple, \
|
|
26
28
|
NearestOn8Tuple, _LL4Tuple
|
|
@@ -34,7 +36,7 @@ from pygeodesy.utily import m2km, unroll180, _unrollon, _unrollon3, \
|
|
|
34
36
|
from math import degrees, radians
|
|
35
37
|
|
|
36
38
|
__all__ = _ALL_LAZY.ellipsoidalBaseDI
|
|
37
|
-
__version__ = '24.
|
|
39
|
+
__version__ = '24.05.13'
|
|
38
40
|
|
|
39
41
|
_polar__ = 'polar?'
|
|
40
42
|
_B2END = _1_5 # _intersect3 bearing to pseudo-end point factor
|
pygeodesy/elliptic.py
CHANGED
|
@@ -82,11 +82,12 @@ from pygeodesy.constants import EPS, INF, NAN, PI, PI_2, PI_4, \
|
|
|
82
82
|
_360_0, _over
|
|
83
83
|
# from pygeodesy.errors import _ValueError # from .fmath
|
|
84
84
|
from pygeodesy.fmath import fdot, hypot1, zqrt, _ValueError
|
|
85
|
-
from pygeodesy.fsums import Fsum, _sum
|
|
86
|
-
from pygeodesy.
|
|
87
|
-
|
|
85
|
+
from pygeodesy.fsums import Fsum, _sum
|
|
86
|
+
# from pygeodesy.internals import _dunder_nameof # from .lazily
|
|
87
|
+
from pygeodesy.interns import NN, _delta_, _DOT_, _f_, _invalid_, \
|
|
88
|
+
_invokation_, _negative_, _SPACE_
|
|
88
89
|
from pygeodesy.karney import _K_2_0, _norm180, _signBit, _sincos2
|
|
89
|
-
|
|
90
|
+
from pygeodesy.lazily import _ALL_LAZY, _dunder_nameof
|
|
90
91
|
from pygeodesy.named import _Named, _NamedTuple, Fmt, unstr
|
|
91
92
|
from pygeodesy.props import _allPropertiesOf_n, Property_RO, _update_all
|
|
92
93
|
# from pygeodesy.streprs import Fmt, unstr # from .named
|
|
@@ -97,7 +98,7 @@ from math import asinh, atan, atan2, ceil, cosh, fabs, floor, \
|
|
|
97
98
|
radians, sin, sqrt, tanh
|
|
98
99
|
|
|
99
100
|
__all__ = _ALL_LAZY.elliptic
|
|
100
|
-
__version__ = '24.
|
|
101
|
+
__version__ = '24.05.13'
|
|
101
102
|
|
|
102
103
|
_TolRD = zqrt(EPS * 0.002)
|
|
103
104
|
_TolRF = zqrt(EPS * 0.030)
|
|
@@ -402,10 +403,12 @@ class Elliptic(_Named):
|
|
|
402
403
|
Phi = Fsum(phi)
|
|
403
404
|
# first order correction
|
|
404
405
|
phi = Phi.fsum_(self.eps * sin(phi * _2_0) / _N_2_0)
|
|
406
|
+
self._iteration = 0
|
|
405
407
|
# For kp2 close to zero use asin(r / cE) or J. P. Boyd,
|
|
406
408
|
# Applied Math. and Computation 218, 7005-7013 (2012)
|
|
407
409
|
# <https://DOI.org/10.1016/j.amc.2011.12.021>
|
|
408
|
-
_Phi2
|
|
410
|
+
_Phi2 = Phi.fsum2f_ # aggregate
|
|
411
|
+
_abs = fabs
|
|
409
412
|
for i in range(1, _TRIPS): # GEOGRAPHICLIB_PANIC
|
|
410
413
|
sn, cn, dn = self._sncndn3(phi)
|
|
411
414
|
if dn:
|
|
@@ -413,7 +416,7 @@ class Elliptic(_Named):
|
|
|
413
416
|
phi, d = _Phi2((r - sn) / dn)
|
|
414
417
|
else: # PYCHOK no cover
|
|
415
418
|
d = _0_0 # XXX continue?
|
|
416
|
-
if
|
|
419
|
+
if _abs(d) < _TolJAC: # 3-4 trips
|
|
417
420
|
_iterations(self, i)
|
|
418
421
|
break
|
|
419
422
|
else: # PYCHOK no cover
|
pygeodesy/errors.py
CHANGED
|
@@ -14,18 +14,18 @@ C{PYGEODESY_EXCEPTION_CHAINING=std} or to any non-empty string.
|
|
|
14
14
|
# from pygeodesy.basics import isint, isodd, issubclassof, itemsorted, _xinstanceof, _zip # _MODS
|
|
15
15
|
# from pygeodesy.ellipsoidalBase import CartesianEllipsoidalBase, LatLonEllipsoidalBase # _MODS
|
|
16
16
|
# from pygeodesy import errors # _MODS, _MODS.getattr
|
|
17
|
-
from pygeodesy.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
_specified_, _UNDER_, _vs_, _with_
|
|
21
|
-
from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS, _getenv, _PYTHON_X_DEV
|
|
17
|
+
# from pygeodesy.internals import _tailof # from .lazily
|
|
18
|
+
from pygeodesy.interns import MISSING, NN, _a_, _an_, _and_, _clip_, _COLON_, _COLONSPACE_, \
|
|
19
|
+
_COMMASPACE_, _datum_, _ellipsoidal_, _incompatible_, _invalid_, \
|
|
20
|
+
_len_, _not_, _or_, _SPACE_, _specified_, _UNDER_, _vs_, _with_
|
|
21
|
+
from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS, _getenv, _PYTHON_X_DEV, _tailof
|
|
22
22
|
# from pygeodesy.streprs import Fmt, unstr # _MODS
|
|
23
23
|
# from pygeodesy.vector3dBase import Vector3dBase # _MODS
|
|
24
24
|
|
|
25
25
|
from copy import copy as _copy
|
|
26
26
|
|
|
27
27
|
__all__ = _ALL_LAZY.errors # _ALL_DOCS('_InvalidError', '_IsnotError') _under
|
|
28
|
-
__version__ = '24.05.
|
|
28
|
+
__version__ = '24.05.15'
|
|
29
29
|
|
|
30
30
|
_box_ = 'box'
|
|
31
31
|
_limiterrors = True # in .formy
|
pygeodesy/etm.py
CHANGED
|
@@ -74,7 +74,7 @@ from pygeodesy.elliptic import _ALL_LAZY, Elliptic
|
|
|
74
74
|
from pygeodesy.fmath import cbrt, hypot, hypot1, hypot2
|
|
75
75
|
from pygeodesy.fsums import Fsum, fsum1f_
|
|
76
76
|
from pygeodesy.interns import NN, _COMMASPACE_, _DASH_, _near_, _SPACE_, \
|
|
77
|
-
_spherical_
|
|
77
|
+
_spherical_
|
|
78
78
|
from pygeodesy.karney import _copyBit, _diff182, _fix90, _norm2, _norm180, \
|
|
79
79
|
_tand, _unsigned2
|
|
80
80
|
# from pygeodesy.lazily import _ALL_LAZY # from .elliptic
|
|
@@ -92,7 +92,7 @@ from pygeodesy.utm import _cmlon, _LLEB, _parseUTM5, _toBand, _toXtm8, \
|
|
|
92
92
|
from math import asinh, atan2, degrees, radians, sinh, sqrt
|
|
93
93
|
|
|
94
94
|
__all__ = _ALL_LAZY.etm
|
|
95
|
-
__version__ = '24.
|
|
95
|
+
__version__ = '24.05.13'
|
|
96
96
|
|
|
97
97
|
_OVERFLOW = _1_EPS**2 # about 2e+31
|
|
98
98
|
_TAYTOL = pow(EPS, 0.6)
|
|
@@ -1109,6 +1109,7 @@ def toEtm8(latlon, lon=None, datum=None, Etm=Etm, falsed=True,
|
|
|
1109
1109
|
|
|
1110
1110
|
if __name__ == '__main__': # MCCABE 13
|
|
1111
1111
|
|
|
1112
|
+
from pygeodesy.internals import _usage
|
|
1112
1113
|
from pygeodesy import fstr, KTransverseMercator, printf
|
|
1113
1114
|
from sys import argv, exit as _exit
|
|
1114
1115
|
|
pygeodesy/fmath.py
CHANGED
|
@@ -7,7 +7,7 @@ u'''Utilities using precision floating point summation.
|
|
|
7
7
|
from __future__ import division as _; del _ # PYCHOK semicolon
|
|
8
8
|
|
|
9
9
|
from pygeodesy.basics import _copysign, copysign0, isbool, isint, isscalar, \
|
|
10
|
-
len2, map1
|
|
10
|
+
len2, map1, _xiterable
|
|
11
11
|
from pygeodesy.constants import EPS0, EPS02, EPS1, NAN, PI, PI_2, PI_4, \
|
|
12
12
|
_0_0, _0_125, _1_6th, _0_25, _1_3rd, _0_5, _1_0, \
|
|
13
13
|
_N_1_0, _1_5, _copysign_0_0, _isfinite, remainder
|
|
@@ -24,7 +24,7 @@ from math import fabs, sqrt # pow
|
|
|
24
24
|
import operator as _operator # in .datums, .trf, .utm
|
|
25
25
|
|
|
26
26
|
__all__ = _ALL_LAZY.fmath
|
|
27
|
-
__version__ = '24.05.
|
|
27
|
+
__version__ = '24.05.10'
|
|
28
28
|
|
|
29
29
|
# sqrt(2) <https://WikiPedia.org/wiki/Square_root_of_2>
|
|
30
30
|
_0_4142 = 0.41421356237309504880 # ... sqrt(2) - 1
|
|
@@ -521,17 +521,18 @@ def fidw(xs, ds, beta=2):
|
|
|
521
521
|
_F = Fsum
|
|
522
522
|
W = _F()
|
|
523
523
|
X = _F()
|
|
524
|
-
for i, d in enumerate(ds):
|
|
524
|
+
for i, d in enumerate(_xiterable(ds)):
|
|
525
525
|
x = xs[i]
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
D = _F(d)
|
|
527
|
+
if D < EPS0:
|
|
528
|
+
if D < 0:
|
|
528
529
|
raise ValueError(_negative_)
|
|
529
530
|
x = float(x)
|
|
530
531
|
i = n
|
|
531
532
|
break
|
|
532
|
-
D
|
|
533
|
-
|
|
534
|
-
|
|
533
|
+
if D.fpow(b):
|
|
534
|
+
W += D
|
|
535
|
+
X += D.fmul(x)
|
|
535
536
|
else:
|
|
536
537
|
x = X.fover(W, raiser=False)
|
|
537
538
|
i += 1 # len(xs) >= len(ds)
|
|
@@ -630,12 +631,12 @@ except ImportError:
|
|
|
630
631
|
def fprod(xs, start=1):
|
|
631
632
|
'''Iterable product, like C{math.prod} or C{numpy.prod}.
|
|
632
633
|
|
|
633
|
-
@arg xs:
|
|
634
|
-
|
|
635
|
-
@kwarg start: Initial
|
|
634
|
+
@arg xs: Iterable of values to be multiplied (each
|
|
635
|
+
C{scalar} or an L{Fsum}).
|
|
636
|
+
@kwarg start: Initial value, also the value returned
|
|
636
637
|
for an empty B{C{xs}} (C{scalar}).
|
|
637
638
|
|
|
638
|
-
@return: The product (C{float}).
|
|
639
|
+
@return: The product (C{float} or an L{Fsum}).
|
|
639
640
|
|
|
640
641
|
@see: U{NumPy.prod<https://docs.SciPy.org/doc/
|
|
641
642
|
numpy/reference/generated/numpy.prod.html>}.
|
pygeodesy/fstats.py
CHANGED
|
@@ -11,17 +11,16 @@ from pygeodesy.basics import isscalar, isodd, _xinstanceof, \
|
|
|
11
11
|
_xiterable, _xsubclassof, _zip
|
|
12
12
|
from pygeodesy.constants import _0_0, _1_0, _2_0, _3_0, _4_0, _6_0
|
|
13
13
|
from pygeodesy.errors import _AssertionError, _ValueError, _xError
|
|
14
|
-
from pygeodesy.fmath import Fsqrt
|
|
15
|
-
from pygeodesy.fsums import _2finite,
|
|
16
|
-
_isAn, _isFsumTuple, _Tuple, Fmt
|
|
14
|
+
from pygeodesy.fmath import Fsqrt, Fmt
|
|
15
|
+
from pygeodesy.fsums import _2finite, Fsum, _iadd_op_, _isFsumTuple
|
|
17
16
|
from pygeodesy.interns import NN, _odd_, _SPACE_
|
|
18
17
|
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
|
|
19
18
|
from pygeodesy.named import _Named, _NotImplemented, property_RO
|
|
20
19
|
# from pygeodesy.props import property_RO # from .named
|
|
21
|
-
# from pygeodesy.streprs import Fmt # from .
|
|
20
|
+
# from pygeodesy.streprs import Fmt # from .fmath
|
|
22
21
|
|
|
23
22
|
__all__ = _ALL_LAZY.fstats
|
|
24
|
-
__version__ = '24.05.
|
|
23
|
+
__version__ = '24.05.10'
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
def _2Floats(**xs):
|
|
@@ -33,11 +32,12 @@ def _2Floats(**xs):
|
|
|
33
32
|
raise _AssertionError(xs=xs, cause=X)
|
|
34
33
|
|
|
35
34
|
try:
|
|
36
|
-
i
|
|
37
|
-
for i, x in enumerate(xs): # don't unravel Fsums
|
|
35
|
+
i = None
|
|
36
|
+
for i, x in enumerate(_xiterable(xs)): # don't unravel Fsums
|
|
38
37
|
yield x._Fsum if _isFsumTuple(x) else _2finite(x)
|
|
39
38
|
except Exception as X:
|
|
40
|
-
raise _xError(X,
|
|
39
|
+
raise _xError(X, name, xs) if i is None else \
|
|
40
|
+
_xError(X, Fmt.INDEX(name, i), x)
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def _sampled(n, sample):
|
|
@@ -105,8 +105,8 @@ class _FstatsBase(_FstatsNamed):
|
|
|
105
105
|
'''(INTERNAL) Copy C{B{c} = B{s}}.
|
|
106
106
|
'''
|
|
107
107
|
_xinstanceof(self.__class__, d=d, s=s)
|
|
108
|
-
d._Ms =
|
|
109
|
-
d._n =
|
|
108
|
+
d._Ms = tuple(M.copy() for M in s._Ms) # deep=False
|
|
109
|
+
d._n = s._n
|
|
110
110
|
return d
|
|
111
111
|
|
|
112
112
|
def fadd(self, xs, sample=False): # PYCHOK no cover
|
|
@@ -130,7 +130,7 @@ class _FstatsBase(_FstatsNamed):
|
|
|
130
130
|
|
|
131
131
|
@see: Method C{fadd}.
|
|
132
132
|
'''
|
|
133
|
-
return
|
|
133
|
+
return float(self._Mean(xs))
|
|
134
134
|
|
|
135
135
|
def fmean_(self, *xs):
|
|
136
136
|
'''Accumulate and return the current mean.
|
|
@@ -151,7 +151,7 @@ class _FstatsBase(_FstatsNamed):
|
|
|
151
151
|
|
|
152
152
|
@see: Method C{fadd}.
|
|
153
153
|
'''
|
|
154
|
-
return
|
|
154
|
+
return float(self._Stdev(xs, **sample))
|
|
155
155
|
|
|
156
156
|
def fstdev_(self, *xs, **sample):
|
|
157
157
|
'''Accumulate and return the current standard deviation.
|
|
@@ -172,7 +172,7 @@ class _FstatsBase(_FstatsNamed):
|
|
|
172
172
|
|
|
173
173
|
@see: Method C{fadd}.
|
|
174
174
|
'''
|
|
175
|
-
return
|
|
175
|
+
return float(self._Variance(xs, **sample))
|
|
176
176
|
|
|
177
177
|
def fvariance_(self, *xs, **sample):
|
|
178
178
|
'''Accumulate and return the current variance.
|
|
@@ -189,12 +189,11 @@ class _FstatsBase(_FstatsNamed):
|
|
|
189
189
|
self.fadd_(other._Fsum)
|
|
190
190
|
elif isscalar(other):
|
|
191
191
|
self.fadd_(_2finite(other))
|
|
192
|
-
|
|
193
|
-
_xiterable(other)
|
|
192
|
+
elif _xiterable(other):
|
|
194
193
|
self.fadd(other)
|
|
195
|
-
except Exception as
|
|
194
|
+
except Exception as X:
|
|
196
195
|
t = _SPACE_(self, _iadd_op_, repr(other))
|
|
197
|
-
raise _xError(
|
|
196
|
+
raise _xError(X, t)
|
|
198
197
|
|
|
199
198
|
@property_RO
|
|
200
199
|
def _M1(self):
|
|
@@ -244,7 +243,7 @@ class Fcook(_FstatsBase):
|
|
|
244
243
|
|
|
245
244
|
@see: Method L{Fcook.fadd}.
|
|
246
245
|
'''
|
|
247
|
-
self._Ms =
|
|
246
|
+
self._Ms = tuple(Fsum() for _ in range(4)) # 1st, 2nd ... Moment
|
|
248
247
|
if name:
|
|
249
248
|
self.name = name
|
|
250
249
|
if xs:
|
|
@@ -265,7 +264,7 @@ class Fcook(_FstatsBase):
|
|
|
265
264
|
|
|
266
265
|
@see: Method L{Fcook.fadd}.
|
|
267
266
|
'''
|
|
268
|
-
if
|
|
267
|
+
if isinstance(other, Fcook):
|
|
269
268
|
nb = len(other)
|
|
270
269
|
if nb > 0:
|
|
271
270
|
na = len(self)
|
|
@@ -374,7 +373,7 @@ class Fcook(_FstatsBase):
|
|
|
374
373
|
|
|
375
374
|
@see: Method L{Fcook.fadd}.
|
|
376
375
|
'''
|
|
377
|
-
return
|
|
376
|
+
return float(self._JarqueBera(xs, excess, sample=sample))
|
|
378
377
|
|
|
379
378
|
def fjb_(self, *xs, **sample_excess):
|
|
380
379
|
'''Accumulate and compute the current U{Jarque-Bera
|
|
@@ -401,7 +400,7 @@ class Fcook(_FstatsBase):
|
|
|
401
400
|
@see: Method L{Fcook.fadd}.
|
|
402
401
|
'''
|
|
403
402
|
n = self.fadd(xs, **sample)
|
|
404
|
-
return
|
|
403
|
+
return float(self._Kurtosis(n, excess, **sample))
|
|
405
404
|
|
|
406
405
|
def fkurtosis_(self, *xs, **excess_sample):
|
|
407
406
|
'''Accumulate and return the current kurtosis.
|
|
@@ -423,7 +422,7 @@ class Fcook(_FstatsBase):
|
|
|
423
422
|
https://TowardsDataScience.com/skewness-kurtosis-simplified-1338e094fc85>}
|
|
424
423
|
and method L{Fcook.fadd}.
|
|
425
424
|
'''
|
|
426
|
-
return
|
|
425
|
+
return float(self._Median(xs))
|
|
427
426
|
|
|
428
427
|
def fmedian_(self, *xs):
|
|
429
428
|
'''Accumulate and return the current median.
|
|
@@ -448,7 +447,7 @@ class Fcook(_FstatsBase):
|
|
|
448
447
|
@see: Method L{Fcook.fadd}.
|
|
449
448
|
'''
|
|
450
449
|
n = self.fadd(xs, **sample)
|
|
451
|
-
return
|
|
450
|
+
return float(self._Skewness(n, **sample))
|
|
452
451
|
|
|
453
452
|
def fskewness_(self, *xs, **sample):
|
|
454
453
|
'''Accumulate and return the current skewness.
|
|
@@ -552,7 +551,7 @@ class Fwelford(_FstatsBase):
|
|
|
552
551
|
@see: Method L{Fwelford.fadd} and U{Parallel algorithm<https//
|
|
553
552
|
WikiPedia.org/wiki/Algorithms_for_calculating_variance>}.
|
|
554
553
|
'''
|
|
555
|
-
if
|
|
554
|
+
if isinstance(other, Fwelford):
|
|
556
555
|
nb = len(other)
|
|
557
556
|
if nb > 0:
|
|
558
557
|
na = len(self)
|
|
@@ -579,7 +578,7 @@ class Fwelford(_FstatsBase):
|
|
|
579
578
|
else:
|
|
580
579
|
self._copy(self, other)
|
|
581
580
|
|
|
582
|
-
elif
|
|
581
|
+
elif isinstance(other, Fcook):
|
|
583
582
|
self += other.toFwelford()
|
|
584
583
|
else:
|
|
585
584
|
self._iadd_other(other)
|
|
@@ -661,7 +660,7 @@ class Flinear(_FstatsNamed):
|
|
|
661
660
|
|
|
662
661
|
@see: Method L{Flinear.fadd_}.
|
|
663
662
|
'''
|
|
664
|
-
if
|
|
663
|
+
if isinstance(other, Flinear):
|
|
665
664
|
if len(other) > 0:
|
|
666
665
|
if len(self) > 0:
|
|
667
666
|
n = other._n
|
|
@@ -676,11 +675,11 @@ class Flinear(_FstatsNamed):
|
|
|
676
675
|
self._copy(self, other)
|
|
677
676
|
else:
|
|
678
677
|
try:
|
|
679
|
-
_xiterable(other)
|
|
680
|
-
|
|
681
|
-
except Exception as
|
|
678
|
+
if _xiterable(other):
|
|
679
|
+
self.fadd_(*other)
|
|
680
|
+
except Exception as X:
|
|
682
681
|
op = _SPACE_(self, _iadd_op_, repr(other))
|
|
683
|
-
raise _xError(
|
|
682
|
+
raise _xError(X, op)
|
|
684
683
|
return self
|
|
685
684
|
|
|
686
685
|
def _copy(self, d, s):
|
|
@@ -752,7 +751,7 @@ class Flinear(_FstatsNamed):
|
|
|
752
751
|
@kwarg sample: Use C{B{sample}=True} for the I{sample} correlation
|
|
753
752
|
instead of the I{population} correlation (C{bool}).
|
|
754
753
|
'''
|
|
755
|
-
return
|
|
754
|
+
return float(self._Correlation(**sample))
|
|
756
755
|
|
|
757
756
|
def fintercept(self, **sample):
|
|
758
757
|
'''Return the current, running (sample) intercept (C{float}).
|
|
@@ -760,7 +759,7 @@ class Flinear(_FstatsNamed):
|
|
|
760
759
|
@kwarg sample: Use C{B{sample}=True} for the I{sample} intercept
|
|
761
760
|
instead of the I{population} intercept (C{bool}).
|
|
762
761
|
'''
|
|
763
|
-
return
|
|
762
|
+
return float(self._Intercept(**sample))
|
|
764
763
|
|
|
765
764
|
def fslope(self, **sample):
|
|
766
765
|
'''Return the current, running (sample) slope (C{float}).
|
|
@@ -768,7 +767,7 @@ class Flinear(_FstatsNamed):
|
|
|
768
767
|
@kwarg sample: Use C{B{sample}=True} for the I{sample} slope
|
|
769
768
|
instead of the I{population} slope (C{bool}).
|
|
770
769
|
'''
|
|
771
|
-
return
|
|
770
|
+
return float(self._Slope(**sample))
|
|
772
771
|
|
|
773
772
|
def _Intercept(self, **sample):
|
|
774
773
|
'''(INTERNAL) Return the current (sample) intercept as L{Fsum}.
|