pygeodesy 25.4.8__py2.py3-none-any.whl → 25.4.25__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/__init__.py +30 -27
- pygeodesy/__main__.py +3 -3
- pygeodesy/albers.py +29 -36
- pygeodesy/auxilats/_CX_4.py +2 -2
- pygeodesy/auxilats/_CX_6.py +2 -2
- pygeodesy/auxilats/_CX_8.py +2 -2
- pygeodesy/auxilats/_CX_Rs.py +9 -9
- pygeodesy/auxilats/__init__.py +3 -3
- pygeodesy/auxilats/__main__.py +8 -6
- pygeodesy/auxilats/auxAngle.py +2 -2
- pygeodesy/auxilats/auxLat.py +5 -5
- pygeodesy/auxilats/auxily.py +5 -3
- pygeodesy/azimuthal.py +7 -6
- pygeodesy/basics.py +31 -17
- pygeodesy/booleans.py +12 -10
- pygeodesy/cartesianBase.py +21 -20
- pygeodesy/clipy.py +11 -10
- pygeodesy/constants.py +11 -10
- pygeodesy/css.py +14 -11
- pygeodesy/datums.py +8 -8
- pygeodesy/deprecated/bases.py +2 -2
- pygeodesy/deprecated/classes.py +2 -2
- pygeodesy/deprecated/consterns.py +4 -4
- pygeodesy/dms.py +8 -8
- pygeodesy/ecef.py +10 -7
- pygeodesy/elevations.py +9 -8
- pygeodesy/ellipsoidalBase.py +19 -8
- pygeodesy/ellipsoidalBaseDI.py +17 -15
- pygeodesy/ellipsoidalNvector.py +6 -3
- pygeodesy/ellipsoidalVincenty.py +4 -1
- pygeodesy/ellipsoids.py +167 -138
- pygeodesy/elliptic.py +9 -9
- pygeodesy/errors.py +44 -43
- pygeodesy/etm.py +7 -7
- pygeodesy/fmath.py +10 -9
- pygeodesy/formy.py +11 -12
- pygeodesy/frechet.py +216 -109
- pygeodesy/fstats.py +5 -4
- pygeodesy/fsums.py +78 -77
- pygeodesy/gars.py +4 -3
- pygeodesy/geodesici.py +15 -14
- pygeodesy/geodesicw.py +34 -32
- pygeodesy/geodesicx/__init__.py +1 -1
- pygeodesy/geodesicx/__main__.py +11 -9
- pygeodesy/geodesicx/gx.py +30 -33
- pygeodesy/geodesicx/gxarea.py +2 -2
- pygeodesy/geodesicx/gxline.py +5 -5
- pygeodesy/geodsolve.py +18 -17
- pygeodesy/geohash.py +5 -5
- pygeodesy/geoids.py +34 -31
- pygeodesy/hausdorff.py +17 -13
- pygeodesy/heights.py +2 -4
- pygeodesy/internals.py +28 -44
- pygeodesy/interns.py +10 -7
- pygeodesy/iters.py +8 -8
- pygeodesy/karney.py +68 -62
- pygeodesy/ktm.py +5 -5
- pygeodesy/latlonBase.py +14 -18
- pygeodesy/lazily.py +65 -63
- pygeodesy/lcc.py +11 -9
- pygeodesy/ltp.py +8 -7
- pygeodesy/ltpTuples.py +2 -2
- pygeodesy/mgrs.py +7 -6
- pygeodesy/named.py +47 -31
- pygeodesy/nvectorBase.py +7 -7
- pygeodesy/osgr.py +9 -8
- pygeodesy/points.py +12 -10
- pygeodesy/props.py +25 -25
- pygeodesy/resections.py +11 -10
- pygeodesy/rhumb/__init__.py +1 -1
- pygeodesy/rhumb/aux_.py +7 -7
- pygeodesy/rhumb/bases.py +22 -20
- pygeodesy/rhumb/ekx.py +6 -6
- pygeodesy/rhumb/solve.py +15 -15
- pygeodesy/solveBase.py +3 -3
- pygeodesy/sphericalBase.py +6 -6
- pygeodesy/sphericalNvector.py +6 -5
- pygeodesy/sphericalTrigonometry.py +8 -7
- pygeodesy/streprs.py +14 -14
- pygeodesy/trf.py +14 -12
- pygeodesy/triaxials.py +29 -26
- pygeodesy/units.py +5 -4
- pygeodesy/unitsBase.py +5 -4
- pygeodesy/ups.py +3 -3
- pygeodesy/utily.py +4 -4
- pygeodesy/utmups.py +4 -4
- pygeodesy/utmupsBase.py +88 -18
- pygeodesy/vector2d.py +18 -11
- pygeodesy/vector3d.py +7 -6
- pygeodesy/webmercator.py +6 -5
- pygeodesy/wgrs.py +6 -5
- {pygeodesy-25.4.8.dist-info → pygeodesy-25.4.25.dist-info}/METADATA +27 -23
- pygeodesy-25.4.25.dist-info/RECORD +118 -0
- pygeodesy-25.4.8.dist-info/RECORD +0 -118
- {pygeodesy-25.4.8.dist-info → pygeodesy-25.4.25.dist-info}/WHEEL +0 -0
- {pygeodesy-25.4.8.dist-info → pygeodesy-25.4.25.dist-info}/top_level.txt +0 -0
pygeodesy/fsums.py
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
4
|
u'''Class L{Fsum} for precision floating point summation similar to
|
|
5
|
-
Python's C{math.fsum} enhanced with I{running} summation
|
|
6
|
-
|
|
5
|
+
Python's C{math.fsum}, but enhanced with I{precision running} summation
|
|
6
|
+
plus optionally, accurate I{TwoProduct} multiplication.
|
|
7
7
|
|
|
8
|
-
Accurate multiplication is based on the C{math.fma} function
|
|
9
|
-
Python 3.13 and newer or
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
Accurate multiplication is based on the C{math.fma} function from
|
|
9
|
+
Python 3.13 and newer or an equivalent C{fma} implementation for
|
|
10
|
+
Python 3.12 and older. To enable accurate multiplication, set env
|
|
11
|
+
variable C{PYGEODESY_FSUM_F2PRODUCT} to C{"std"} or any non-empty
|
|
12
12
|
string or invoke function C{pygeodesy.f2product(True)} or set. With
|
|
13
13
|
C{"std"} the C{fma} implemention follows the C{math.fma} function,
|
|
14
14
|
otherwise the C{PyGeodesy 24.09.09} release.
|
|
@@ -48,12 +48,12 @@ from pygeodesy.errors import _AssertionError, _OverflowError, _TypeError, \
|
|
|
48
48
|
_ValueError, _xError, _xError2, _xkwds, \
|
|
49
49
|
_xkwds_get, _xkwds_get1, _xkwds_not, \
|
|
50
50
|
_xkwds_pop, _xsError
|
|
51
|
-
from pygeodesy.internals import _enquote,
|
|
52
|
-
from pygeodesy.interns import NN, _arg_, _COMMASPACE_, _DOT_, _from_, \
|
|
51
|
+
from pygeodesy.internals import _enquote, _envPYGEODESY, _passarg, typename
|
|
52
|
+
from pygeodesy.interns import NN, _arg_, _COMMASPACE_, _DMAIN_, _DOT_, _from_, \
|
|
53
53
|
_not_finite_, _SPACE_, _std_, _UNDER_
|
|
54
|
-
# from pygeodesy.lazily import _ALL_LAZY # from .named
|
|
54
|
+
# from pygeodesy.lazily import _ALL_LAZY, _ALL_MODS as _MODS # from .named
|
|
55
55
|
from pygeodesy.named import _name__, _name2__, _Named, _NamedTuple, \
|
|
56
|
-
_NotImplemented, _ALL_LAZY
|
|
56
|
+
_NotImplemented, _ALL_LAZY, _MODS
|
|
57
57
|
from pygeodesy.props import _allPropertiesOf_n, deprecated_method, \
|
|
58
58
|
deprecated_property_RO, Property, \
|
|
59
59
|
Property_RO, property_RO
|
|
@@ -64,7 +64,7 @@ from math import fabs, isinf, isnan, \
|
|
|
64
64
|
ceil as _ceil, floor as _floor # PYCHOK used! .ltp
|
|
65
65
|
|
|
66
66
|
__all__ = _ALL_LAZY.fsums
|
|
67
|
-
__version__ = '25.
|
|
67
|
+
__version__ = '25.04.14'
|
|
68
68
|
|
|
69
69
|
from pygeodesy.interns import (
|
|
70
70
|
_PLUS_ as _add_op_, # in .auxilats.auxAngle
|
|
@@ -80,14 +80,14 @@ from pygeodesy.interns import (
|
|
|
80
80
|
_SLASH_ as _truediv_op_
|
|
81
81
|
)
|
|
82
82
|
_divmod_op_ = _floordiv_op_ + _mod_op_
|
|
83
|
-
_F2PRODUCT =
|
|
83
|
+
_F2PRODUCT = _envPYGEODESY('FSUM_F2PRODUCT')
|
|
84
84
|
_iadd_op_ = _add_op_ + _fset_op_ # in .auxilats.auxAngle, .fstats
|
|
85
85
|
_integer_ = 'integer'
|
|
86
86
|
_isub_op_ = _sub_op_ + _fset_op_ # in .auxilats.auxAngle
|
|
87
87
|
_NONFINITEr = _0_0 # NOT INT0!
|
|
88
|
-
_NONFINITES =
|
|
88
|
+
_NONFINITES = _envPYGEODESY('FSUM_NONFINITES')
|
|
89
89
|
_non_zero_ = 'non-zero'
|
|
90
|
-
_RESIDUAL_0_0 =
|
|
90
|
+
_RESIDUAL_0_0 = _envPYGEODESY('FSUM_RESIDUAL', _0_0)
|
|
91
91
|
_significant_ = 'significant'
|
|
92
92
|
_threshold_ = 'threshold'
|
|
93
93
|
|
|
@@ -137,10 +137,12 @@ except ImportError: # PYCHOK DSPACE! Python 3.12-
|
|
|
137
137
|
def _fma(*a_b_c): # PYCHOK no cover
|
|
138
138
|
# mimick C{math.fma} from Python 3.13+,
|
|
139
139
|
# the same accuracy, but ~14x slower
|
|
140
|
-
(
|
|
141
|
-
n
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
(n, d), (nb, db), (nc, dc) = map(_integer_ratio2, a_b_c)
|
|
141
|
+
# n, d = (n * nb * dc + d * db * nc), (d * db * dc)
|
|
142
|
+
d *= db
|
|
143
|
+
n *= nb * dc
|
|
144
|
+
n += nc * d
|
|
145
|
+
d *= dc
|
|
144
146
|
try:
|
|
145
147
|
n, d = _n_d2(n, d)
|
|
146
148
|
r = float(n / d)
|
|
@@ -270,20 +272,19 @@ def _isOK(unused):
|
|
|
270
272
|
def _isOK_or_finite(x, _isfine=_isfinite):
|
|
271
273
|
'''(INTERNAL) Is C{x} finite or is I{non-finite} OK?
|
|
272
274
|
'''
|
|
273
|
-
# assert _isfine
|
|
275
|
+
# assert _isin(_isfine, _isOK, _isfinite)
|
|
274
276
|
return _isfine(x) # C{bool}
|
|
275
277
|
|
|
276
278
|
|
|
277
279
|
def _n_d2(n, d):
|
|
278
280
|
'''(INTERNAL) Reduce C{n} and C{d} by C{gcd}.
|
|
279
281
|
'''
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
pass
|
|
282
|
+
try:
|
|
283
|
+
c = _gcd(n, d)
|
|
284
|
+
if c > 1:
|
|
285
|
+
return (n // c), (d // c)
|
|
286
|
+
except TypeError: # non-int float
|
|
287
|
+
pass
|
|
287
288
|
return n, d
|
|
288
289
|
|
|
289
290
|
|
|
@@ -402,7 +403,7 @@ def _s_r2(s, r):
|
|
|
402
403
|
def _strcomplex(s, *args):
|
|
403
404
|
'''(INTERNAL) C{Complex} 2- or 3-arg C{pow} error as C{str}.
|
|
404
405
|
'''
|
|
405
|
-
c =
|
|
406
|
+
c = typename(_strcomplex)[4:]
|
|
406
407
|
n = _sub_op_(len(args), _arg_)
|
|
407
408
|
t = unstr(pow, *args)
|
|
408
409
|
return _SPACE_(c, s, _from_, n, t)
|
|
@@ -411,8 +412,8 @@ def _strcomplex(s, *args):
|
|
|
411
412
|
def _stresidual(prefix, residual, R=0, **mod_ratio):
|
|
412
413
|
'''(INTERNAL) Residual error txt C{str}.
|
|
413
414
|
'''
|
|
414
|
-
p = _stresidual
|
|
415
|
-
t =
|
|
415
|
+
p = typename(_stresidual)[3:]
|
|
416
|
+
t = Fmt.PARENSPACED(p, Fmt(residual))
|
|
416
417
|
for n, v in itemsorted(mod_ratio):
|
|
417
418
|
p = Fmt.PARENSPACED(n, Fmt(v))
|
|
418
419
|
t = _COMMASPACE_(t, p)
|
|
@@ -532,7 +533,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
532
533
|
'''Return C{abs(self)} as an L{Fsum}.
|
|
533
534
|
'''
|
|
534
535
|
s = self.signOf() # == self._cmp_0(0)
|
|
535
|
-
return (-self) if s < 0 else self.
|
|
536
|
+
return (-self) if s < 0 else self._copyd(self.__abs__)
|
|
536
537
|
|
|
537
538
|
def __add__(self, other):
|
|
538
539
|
'''Return C{B{self} + B{other}} as an L{Fsum}.
|
|
@@ -543,7 +544,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
543
544
|
|
|
544
545
|
@see: Methods L{Fsum.fadd_} and L{Fsum.fadd}.
|
|
545
546
|
'''
|
|
546
|
-
f = self.
|
|
547
|
+
f = self._copyd(self.__add__)
|
|
547
548
|
return f._fadd(other)
|
|
548
549
|
|
|
549
550
|
def __bool__(self): # PYCHOK Python 3+
|
|
@@ -576,7 +577,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
576
577
|
|
|
577
578
|
@raise TypeError: Incompatible B{C{other}} C{type}.
|
|
578
579
|
'''
|
|
579
|
-
s = self._cmp_0(other, self.cmp
|
|
580
|
+
s = self._cmp_0(other, typename(self.cmp))
|
|
580
581
|
return _signOf(s, 0)
|
|
581
582
|
|
|
582
583
|
def __divmod__(self, other, **raiser_RESIDUAL):
|
|
@@ -594,7 +595,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
594
595
|
|
|
595
596
|
@see: Method L{Fsum.fdiv}.
|
|
596
597
|
'''
|
|
597
|
-
f = self.
|
|
598
|
+
f = self._copyd(self.__divmod__)
|
|
598
599
|
return f._fdivmod2(other, _divmod_op_, **raiser_RESIDUAL)
|
|
599
600
|
|
|
600
601
|
def __eq__(self, other):
|
|
@@ -628,7 +629,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
628
629
|
|
|
629
630
|
@see: Methods L{Fsum.__ifloordiv__}.
|
|
630
631
|
'''
|
|
631
|
-
f = self.
|
|
632
|
+
f = self._copyd(self.__floordiv__)
|
|
632
633
|
return f._floordiv(other, _floordiv_op_)
|
|
633
634
|
|
|
634
635
|
def __ge__(self, other):
|
|
@@ -843,7 +844,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
843
844
|
|
|
844
845
|
@see: Method L{Fsum.__imod__}.
|
|
845
846
|
'''
|
|
846
|
-
f = self.
|
|
847
|
+
f = self._copyd(self.__mod__)
|
|
847
848
|
return f._fdivmod2(other, _mod_op_).mod
|
|
848
849
|
|
|
849
850
|
def __mul__(self, other):
|
|
@@ -851,7 +852,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
851
852
|
|
|
852
853
|
@see: Method L{Fsum.__imul__}.
|
|
853
854
|
'''
|
|
854
|
-
f = self.
|
|
855
|
+
f = self._copyd(self.__mul__)
|
|
855
856
|
return f._fmul(other, _mul_op_)
|
|
856
857
|
|
|
857
858
|
def __ne__(self, other):
|
|
@@ -862,20 +863,20 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
862
863
|
def __neg__(self):
|
|
863
864
|
'''Return C{copy(B{self})}, I{negated}.
|
|
864
865
|
'''
|
|
865
|
-
f = self.
|
|
866
|
+
f = self._copyd(self.__neg__)
|
|
866
867
|
return f._fset(self._neg)
|
|
867
868
|
|
|
868
869
|
def __pos__(self):
|
|
869
870
|
'''Return this instance I{as-is}, like C{float.__pos__()}.
|
|
870
871
|
'''
|
|
871
|
-
return self if _pos_self else self.
|
|
872
|
+
return self if _pos_self else self._copyd(self.__pos__)
|
|
872
873
|
|
|
873
874
|
def __pow__(self, other, *mod): # PYCHOK 2 vs 3 args
|
|
874
875
|
'''Return C{B{self}**B{other}} as an L{Fsum}.
|
|
875
876
|
|
|
876
877
|
@see: Method L{Fsum.__ipow__}.
|
|
877
878
|
'''
|
|
878
|
-
f = self.
|
|
879
|
+
f = self._copyd(self.__pow__)
|
|
879
880
|
return f._fpow(other, _pow_op_, *mod)
|
|
880
881
|
|
|
881
882
|
def __radd__(self, other):
|
|
@@ -883,7 +884,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
883
884
|
|
|
884
885
|
@see: Method L{Fsum.__iadd__}.
|
|
885
886
|
'''
|
|
886
|
-
f = self.
|
|
887
|
+
f = self._rcopyd(other, self.__radd__)
|
|
887
888
|
return f._fadd(self)
|
|
888
889
|
|
|
889
890
|
def __rdivmod__(self, other):
|
|
@@ -892,7 +893,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
892
893
|
|
|
893
894
|
@see: Method L{Fsum.__divmod__}.
|
|
894
895
|
'''
|
|
895
|
-
f = self.
|
|
896
|
+
f = self._rcopyd(other, self.__rdivmod__)
|
|
896
897
|
return f._fdivmod2(self, _divmod_op_)
|
|
897
898
|
|
|
898
899
|
# turned off, called by _deepcopy and _copy
|
|
@@ -901,7 +902,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
901
902
|
# <https://docs.Python.org/3/library/pickle.html#object.__reduce__>}
|
|
902
903
|
# '''
|
|
903
904
|
# dict_ = self._Fsum_as().__dict__ # no __setstate__
|
|
904
|
-
# return (self
|
|
905
|
+
# return (type(self), self.partials, dict_)
|
|
905
906
|
|
|
906
907
|
# def __repr__(self):
|
|
907
908
|
# '''Return the default C{repr(this)}.
|
|
@@ -913,7 +914,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
913
914
|
|
|
914
915
|
@see: Method L{Fsum.__ifloordiv__}.
|
|
915
916
|
'''
|
|
916
|
-
f = self.
|
|
917
|
+
f = self._rcopyd(other, self.__rfloordiv__)
|
|
917
918
|
return f._floordiv(self, _floordiv_op_)
|
|
918
919
|
|
|
919
920
|
def __rmatmul__(self, other): # PYCHOK no coveS
|
|
@@ -925,7 +926,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
925
926
|
|
|
926
927
|
@see: Method L{Fsum.__imod__}.
|
|
927
928
|
'''
|
|
928
|
-
f = self.
|
|
929
|
+
f = self._rcopyd(other, self.__rmod__)
|
|
929
930
|
return f._fdivmod2(self, _mod_op_).mod
|
|
930
931
|
|
|
931
932
|
def __rmul__(self, other):
|
|
@@ -933,7 +934,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
933
934
|
|
|
934
935
|
@see: Method L{Fsum.__imul__}.
|
|
935
936
|
'''
|
|
936
|
-
f = self.
|
|
937
|
+
f = self._rcopyd(other, self.__rmul__)
|
|
937
938
|
return f._fmul(self, _mul_op_)
|
|
938
939
|
|
|
939
940
|
def __round__(self, *ndigits): # PYCHOK Python 3+
|
|
@@ -941,7 +942,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
941
942
|
|
|
942
943
|
@arg ndigits: Optional number of digits (C{int}).
|
|
943
944
|
'''
|
|
944
|
-
f = self.
|
|
945
|
+
f = self._copyd(self.__round__)
|
|
945
946
|
# <https://docs.Python.org/3.12/reference/datamodel.html?#object.__round__>
|
|
946
947
|
return f._fset(round(float(self), *ndigits)) # can be C{int}
|
|
947
948
|
|
|
@@ -950,7 +951,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
950
951
|
|
|
951
952
|
@see: Method L{Fsum.__ipow__}.
|
|
952
953
|
'''
|
|
953
|
-
f = self.
|
|
954
|
+
f = self._rcopyd(other, self.__rpow__)
|
|
954
955
|
return f._fpow(self, _pow_op_, *mod)
|
|
955
956
|
|
|
956
957
|
def __rsub__(self, other):
|
|
@@ -958,7 +959,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
958
959
|
|
|
959
960
|
@see: Method L{Fsum.__isub__}.
|
|
960
961
|
'''
|
|
961
|
-
f = self.
|
|
962
|
+
f = self._rcopyd(other, self.__rsub__)
|
|
962
963
|
return f._fsub(self, _sub_op_)
|
|
963
964
|
|
|
964
965
|
def __rtruediv__(self, other, **raiser_RESIDUAL):
|
|
@@ -966,7 +967,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
966
967
|
|
|
967
968
|
@see: Method L{Fsum.__itruediv__}.
|
|
968
969
|
'''
|
|
969
|
-
f = self.
|
|
970
|
+
f = self._rcopyd(other, self.__rtruediv__)
|
|
970
971
|
return f._ftruediv(self, _truediv_op_, **raiser_RESIDUAL)
|
|
971
972
|
|
|
972
973
|
def __str__(self):
|
|
@@ -983,7 +984,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
983
984
|
|
|
984
985
|
@see: Method L{Fsum.__isub__}.
|
|
985
986
|
'''
|
|
986
|
-
f = self.
|
|
987
|
+
f = self._copyd(self.__sub__)
|
|
987
988
|
return f._fsub(other, _sub_op_)
|
|
988
989
|
|
|
989
990
|
def __truediv__(self, other, **raiser_RESIDUAL):
|
|
@@ -1088,10 +1089,10 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1088
1089
|
# assert f._RESIDUAL is self._RESIDUAL
|
|
1089
1090
|
return f
|
|
1090
1091
|
|
|
1091
|
-
def
|
|
1092
|
+
def _copyd(self, which, name=NN):
|
|
1092
1093
|
'''(INTERNAL) Copy for I{dyadic} operators.
|
|
1093
1094
|
'''
|
|
1094
|
-
n = name or which
|
|
1095
|
+
n = name or typename(which)
|
|
1095
1096
|
# NOT .classof due to .Fdot(a, *b) args, etc.
|
|
1096
1097
|
f = _Named.copy(self, deep=False, name=n)
|
|
1097
1098
|
f._ps = list(self._ps) # separate list
|
|
@@ -1102,12 +1103,6 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1102
1103
|
# assert f._RESIDUAL is self._RESIDUAL
|
|
1103
1104
|
return f
|
|
1104
1105
|
|
|
1105
|
-
def _copy_2r(self, other, which):
|
|
1106
|
-
'''(INTERNAL) Copy for I{reverse-dyadic} operators.
|
|
1107
|
-
'''
|
|
1108
|
-
return other._copy_2(which) if _isFsum(other) else \
|
|
1109
|
-
self._copy_2(which)._fset(other)
|
|
1110
|
-
|
|
1111
1106
|
divmod = __divmod__
|
|
1112
1107
|
|
|
1113
1108
|
def _Error(self, op, other, Error, **txt_cause):
|
|
@@ -1193,7 +1188,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1193
1188
|
|
|
1194
1189
|
_Pow, p, s, r = _Pow4(power)
|
|
1195
1190
|
if p: # and xs:
|
|
1196
|
-
op = which
|
|
1191
|
+
op = typename(which)
|
|
1197
1192
|
_FsT = _Fsum_2Tuple_types
|
|
1198
1193
|
_pow = self._pow_2_3
|
|
1199
1194
|
|
|
@@ -1230,8 +1225,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1230
1225
|
'''(INTERNAL) Accumulate all C{xs}, each C{scalar}, an L{Fsum} or
|
|
1231
1226
|
L{Fsum2Tuple}, like function C{_xsum}.
|
|
1232
1227
|
'''
|
|
1233
|
-
|
|
1234
|
-
fs = _xs(xs, **_x_isfine(self.nonfinitesOK, _Cdot=_C,
|
|
1228
|
+
fs = _xs(xs, **_x_isfine(self.nonfinitesOK, _Cdot=type(self),
|
|
1235
1229
|
**origin_which)) # PYCHOK yield
|
|
1236
1230
|
return self._facc_scalar(fs, up=up)
|
|
1237
1231
|
|
|
@@ -1447,7 +1441,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1447
1441
|
override L{nonfinites<Fsum.nonfinites>} and
|
|
1448
1442
|
L{nonfiniterrors} default (C{bool}).
|
|
1449
1443
|
'''
|
|
1450
|
-
op = self.fma
|
|
1444
|
+
op = typename(self.fma)
|
|
1451
1445
|
_fs = self._ps_other
|
|
1452
1446
|
try:
|
|
1453
1447
|
s, r = self._fprs2
|
|
@@ -1512,7 +1506,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1512
1506
|
def _f2mul(self, where, others, f2product=True, **nonfinites_raiser):
|
|
1513
1507
|
'''(INTERNAL) See methods C{fma} and C{f2mul_}.
|
|
1514
1508
|
'''
|
|
1515
|
-
|
|
1509
|
+
n = typename(where)
|
|
1510
|
+
f = _Psum(self._ps, f2product=f2product, name=n)
|
|
1516
1511
|
if others and f:
|
|
1517
1512
|
if f.f2product():
|
|
1518
1513
|
def _pfs(f, ps):
|
|
@@ -1521,7 +1516,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1521
1516
|
def _pfs(f, ps): # PYCHOK redef
|
|
1522
1517
|
return (f * p for p in ps)
|
|
1523
1518
|
|
|
1524
|
-
op, ps =
|
|
1519
|
+
op, ps = n, f._ps
|
|
1525
1520
|
try: # as if self.f2product(True)
|
|
1526
1521
|
for other in others: # to pinpoint errors
|
|
1527
1522
|
for p in self._ps_other(op, other):
|
|
@@ -1760,7 +1755,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1760
1755
|
|
|
1761
1756
|
@return: Copy of this updated instance (L{Fsum}).
|
|
1762
1757
|
'''
|
|
1763
|
-
return self._facc_args(xs).
|
|
1758
|
+
return self._facc_args(xs)._copyd(self.Fsum_, **name)
|
|
1764
1759
|
|
|
1765
1760
|
def Fsum2Tuple_(self, *xs, **name):
|
|
1766
1761
|
'''Like method L{Fsum.fsum_} but returning a named L{Fsum2Tuple}.
|
|
@@ -1773,7 +1768,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1773
1768
|
|
|
1774
1769
|
@property_RO
|
|
1775
1770
|
def _Fsum(self): # like L{Fsum2Tuple._Fsum}, in .fstats
|
|
1776
|
-
return self # NOT @Property_RO, see .copy and .
|
|
1771
|
+
return self # NOT @Property_RO, see .copy and ._copyd
|
|
1777
1772
|
|
|
1778
1773
|
def _Fsum_as(self, *xs, **name_f2product_nonfinites_RESIDUAL):
|
|
1779
1774
|
'''(INTERNAL) Return an C{Fsum} with this C{Fsum}'s C{.f2product},
|
|
@@ -1848,7 +1843,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
1848
1843
|
'''Like method L{Fsum.Fsum_} iff I{all} C{B{xs}}, each I{known to be}
|
|
1849
1844
|
C{scalar}, an L{Fsum} or L{Fsum2Tuple}.
|
|
1850
1845
|
'''
|
|
1851
|
-
return self._facc_scalarf(xs, which=self.Fsumf_).
|
|
1846
|
+
return self._facc_scalarf(xs, which=self.Fsumf_)._copyd(self.Fsumf_) # origin=1?
|
|
1852
1847
|
|
|
1853
1848
|
def fsum2f_(self, *xs):
|
|
1854
1849
|
'''Like method L{Fsum.fsum2_} iff I{all} C{B{xs}}, each I{known to be}
|
|
@@ -2132,7 +2127,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
2132
2127
|
@see: Methods L{Fsum.__ipow__}, L{Fsum.fint}, L{Fsum.is_integer}
|
|
2133
2128
|
and L{Fsum.root}.
|
|
2134
2129
|
'''
|
|
2135
|
-
f = self.
|
|
2130
|
+
f = self._copyd(self.pow)
|
|
2136
2131
|
return f._fpow(x, _pow_op_, *mod, **raiser_RESIDUAL) # f = pow(f, x, *mod)
|
|
2137
2132
|
|
|
2138
2133
|
def _pow(self, other, unused, op, **raiser_RESIDUAL):
|
|
@@ -2354,6 +2349,12 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
2354
2349
|
return dict(ratio=q, R=t)
|
|
2355
2350
|
return {}
|
|
2356
2351
|
|
|
2352
|
+
def _rcopyd(self, other, which):
|
|
2353
|
+
'''(INTERNAL) Copy for I{reverse-dyadic} operators.
|
|
2354
|
+
'''
|
|
2355
|
+
return other._copyd(which) if _isFsum(other) else \
|
|
2356
|
+
self._copyd(which)._fset(other)
|
|
2357
|
+
|
|
2357
2358
|
rdiv = __rtruediv__
|
|
2358
2359
|
|
|
2359
2360
|
@property_RO
|
|
@@ -2434,7 +2435,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
2434
2435
|
@see: Method L{Fsum.pow}.
|
|
2435
2436
|
'''
|
|
2436
2437
|
x = self._1_Over(root, _truediv_op_, **raiser_RESIDUAL)
|
|
2437
|
-
f = self.
|
|
2438
|
+
f = self._copyd(self.root)
|
|
2438
2439
|
return f._fpow(x, f.name, **raiser_RESIDUAL) # == pow(f, x)
|
|
2439
2440
|
|
|
2440
2441
|
def _scalar(self, other, op, **txt):
|
|
@@ -2486,7 +2487,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase, .fstats
|
|
|
2486
2487
|
def _truediv(self, other, op, **raiser_RESIDUAL):
|
|
2487
2488
|
'''(INTERNAL) Return C{B{self} / B{other}} as an L{Fsum}.
|
|
2488
2489
|
'''
|
|
2489
|
-
f = self.
|
|
2490
|
+
f = self._copyd(self.__truediv__)
|
|
2490
2491
|
return f._ftruediv(other, op, **raiser_RESIDUAL)
|
|
2491
2492
|
|
|
2492
2493
|
def _update(self, updated=True): # see ._fset
|
|
@@ -2533,8 +2534,8 @@ class Fsum2Tuple(_NamedTuple): # in .fstats
|
|
|
2533
2534
|
@note: If the C{residual is INT0}, the C{fsum} is considered
|
|
2534
2535
|
to be I{exact}, see method L{Fsum2Tuple.is_exact}.
|
|
2535
2536
|
'''
|
|
2536
|
-
_Names_ = ( Fsum.fsum
|
|
2537
|
-
_Units_ = (_Float_Int,
|
|
2537
|
+
_Names_ = ( typename(Fsum.fsum), Fsum.residual.name)
|
|
2538
|
+
_Units_ = (_Float_Int, _Float_Int)
|
|
2538
2539
|
|
|
2539
2540
|
def __abs__(self): # in .fmath
|
|
2540
2541
|
return self._Fsum.__abs__()
|
|
@@ -2626,7 +2627,7 @@ class Fsum2Tuple(_NamedTuple): # in .fstats
|
|
|
2626
2627
|
|
|
2627
2628
|
def _other_op(self, other, which):
|
|
2628
2629
|
C, s = (tuple, self) if isinstance(other, tuple) else (Fsum, self._Fsum)
|
|
2629
|
-
return getattr(C, which
|
|
2630
|
+
return getattr(C, typename(which))(s, other)
|
|
2630
2631
|
|
|
2631
2632
|
@property_RO
|
|
2632
2633
|
def _ps(self):
|
|
@@ -2807,9 +2808,9 @@ def _xsum(which, xs, nonfinites=None, primed=0, **floats): # origin=0
|
|
|
2807
2808
|
# delete all decorators, etc.
|
|
2808
2809
|
del _allPropertiesOf_n, deprecated_method, deprecated_property_RO, \
|
|
2809
2810
|
Property, Property_RO, property_RO, _ALL_LAZY, _F2PRODUCT, \
|
|
2810
|
-
MANT_DIG, _NONFINITES, _RESIDUAL_0_0,
|
|
2811
|
+
MANT_DIG, _NONFINITES, _RESIDUAL_0_0, _envPYGEODESY, _std_
|
|
2811
2812
|
|
|
2812
|
-
if __name__ ==
|
|
2813
|
+
if __name__ == _DMAIN_:
|
|
2813
2814
|
|
|
2814
2815
|
# usage: python3 -m pygeodesy.fsums
|
|
2815
2816
|
|
|
@@ -2817,8 +2818,8 @@ if __name__ == '__main__':
|
|
|
2817
2818
|
# copied from Hettinger, see L{Fsum} reference
|
|
2818
2819
|
from pygeodesy import frandoms, printf
|
|
2819
2820
|
|
|
2820
|
-
printf(_fsum
|
|
2821
|
-
printf(_psum
|
|
2821
|
+
printf(typename(_fsum), end=_COMMASPACE_)
|
|
2822
|
+
printf(typename(_psum), end=_COMMASPACE_)
|
|
2822
2823
|
|
|
2823
2824
|
F = Fsum()
|
|
2824
2825
|
if F.is_math_fsum():
|
pygeodesy/gars.py
CHANGED
|
@@ -14,10 +14,11 @@ Transcoded from I{Charles Karney}'s C++ class U{GARS
|
|
|
14
14
|
(GARS)<https://Earth-Info.NGA.mil/GandG/coordsys/grids/gars.html>}.
|
|
15
15
|
'''
|
|
16
16
|
|
|
17
|
-
from pygeodesy.basics import isstr, _splituple
|
|
17
|
+
from pygeodesy.basics import isstr, _splituple, typename
|
|
18
18
|
from pygeodesy.constants import _off90, _1_over, _0_5, \
|
|
19
19
|
_1_0 # PYCHOK used!
|
|
20
20
|
from pygeodesy.errors import _ValueError, _xkwds, _xStrError
|
|
21
|
+
# from pygeodesy.internals import typename # from .basics
|
|
21
22
|
from pygeodesy.interns import NN, _0to9_, _AtoZnoIO_, _INV_
|
|
22
23
|
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
|
|
23
24
|
from pygeodesy.named import _name__, Fmt, Property_RO
|
|
@@ -29,7 +30,7 @@ from pygeodesy.units import Int_, Lat, Lon, Precision_, Scalar_, Str
|
|
|
29
30
|
from math import floor
|
|
30
31
|
|
|
31
32
|
__all__ = _ALL_LAZY.gars
|
|
32
|
-
__version__ = '25.
|
|
33
|
+
__version__ = '25.04.14'
|
|
33
34
|
|
|
34
35
|
_Digits = _0to9_
|
|
35
36
|
_LatLen = 2
|
|
@@ -92,7 +93,7 @@ def _2garstr2(garef):
|
|
|
92
93
|
return garstr, _2Precision(n - _MinLen)
|
|
93
94
|
|
|
94
95
|
except (AttributeError, TypeError, ValueError) as x:
|
|
95
|
-
raise GARSError(Garef
|
|
96
|
+
raise GARSError(typename(Garef), garef, cause=x)
|
|
96
97
|
|
|
97
98
|
|
|
98
99
|
def _2Precision(precision):
|
pygeodesy/geodesici.py
CHANGED
|
@@ -26,7 +26,7 @@ on the ellipsoid<https://riunet.UPV.ES/bitstream/handle/10251/122902/Revised_Man
|
|
|
26
26
|
from __future__ import division as _; del _ # PYCHOK semicolon
|
|
27
27
|
|
|
28
28
|
from pygeodesy.basics import _copy, _enumereverse, map1, \
|
|
29
|
-
_xinstanceof, _xor
|
|
29
|
+
_xinstanceof, _xor, typename
|
|
30
30
|
from pygeodesy.constants import EPS, INF, INT0, PI, PI2, PI_4, \
|
|
31
31
|
_0_0, _0_5, _1_0, _1_5, _2_0, _3_0, \
|
|
32
32
|
_45_0, _64_0, _90_0, isfinite, \
|
|
@@ -38,8 +38,9 @@ from pygeodesy.errors import GeodesicError, IntersectionError, _an, \
|
|
|
38
38
|
# from pygeodesy.errors import exception_chaining # _MODS
|
|
39
39
|
from pygeodesy.fmath import euclid, fdot
|
|
40
40
|
from pygeodesy.fsums import Fsum, fsum1_, _ceil
|
|
41
|
-
from pygeodesy.
|
|
42
|
-
|
|
41
|
+
# from pygeodesy.internals import typename # from .basics
|
|
42
|
+
from pygeodesy.interns import NN, _A_, _B_, _c_, _COMMASPACE_, _DMAIN_, \
|
|
43
|
+
_HASH_, _M_, _not_, _SPACE_, _too_
|
|
43
44
|
from pygeodesy.karney import Caps, _diff182, GDict, _sincos2de, _Xables
|
|
44
45
|
from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS
|
|
45
46
|
from pygeodesy.named import ADict, _NamedBase, _NamedTuple, _Pass
|
|
@@ -56,7 +57,7 @@ from pygeodesy.utily import atan2, sincos2, fabs, radians
|
|
|
56
57
|
# from math import ceil as _ceil, fabs, radians # .fsums, .utily
|
|
57
58
|
|
|
58
59
|
__all__ = _ALL_LAZY.geodesici
|
|
59
|
-
__version__ = '
|
|
60
|
+
__version__ = '25.04.14'
|
|
60
61
|
|
|
61
62
|
_0t = 0, # int
|
|
62
63
|
_1_1t = -1, +1
|
|
@@ -312,7 +313,7 @@ class _IntersectBase(_NamedBase):
|
|
|
312
313
|
G.set_(lat1=il.lat1, lon1=il.lon1, azi1=il.azi1, a12=il.a13, # .Arc()
|
|
313
314
|
lat2=il.lat2, lon2=il.lon2, azi2=il.azi2, s12=il.s13) # .Distance()
|
|
314
315
|
except AttributeError:
|
|
315
|
-
r = il.Position(il.s13, outmask=Caps.
|
|
316
|
+
r = il.Position(il.s13, outmask=Caps.STANDARD_LINE) # isfinite(il.s13)
|
|
316
317
|
G.set_(**r)
|
|
317
318
|
# for n, v in r.items():
|
|
318
319
|
# if not hasattr(il, n):
|
|
@@ -469,7 +470,7 @@ class Intersectool(_IntersectBase, _SolveCapsBase):
|
|
|
469
470
|
_Names_ABs = _latA_, _lonA_, 'latB', 'lonB', _sAB_ # -C to stderr
|
|
470
471
|
_Names_XDict = 'sA', 'sB', _c_ # plus 'k' from -i or 'sX0' from -R
|
|
471
472
|
_o_alt = _o__, # Offset latA lonA aziA latB lonB aziB x0 y0
|
|
472
|
-
_Xable_name = _Xables.IntersectTool.__name__
|
|
473
|
+
_Xable_name = _Xables.IntersectTool.__name__ # typename
|
|
473
474
|
_Xable_path = _Xables.IntersectTool()
|
|
474
475
|
|
|
475
476
|
def __init__(self, a_geodesic=None, f=None, **name):
|
|
@@ -660,7 +661,7 @@ class Intersectool(_IntersectBase, _SolveCapsBase):
|
|
|
660
661
|
raise GeodesicError(n, gl, cause=x)
|
|
661
662
|
s = il.s13
|
|
662
663
|
m = s * _0_5
|
|
663
|
-
return s, m, il, (il.Position(m, outmask=Caps.
|
|
664
|
+
return s, m, il, (il.Position(m, outmask=Caps.STANDARD_LINE) if _C else None)
|
|
664
665
|
|
|
665
666
|
sA, mA, iA, A = _smi4(glA=glA)
|
|
666
667
|
sB, mB, iB, B = _smi4(glB=glB)
|
|
@@ -1276,7 +1277,7 @@ class Intersector(_IntersectBase):
|
|
|
1276
1277
|
return s, lat1
|
|
1277
1278
|
|
|
1278
1279
|
def _Position(self, gl, s):
|
|
1279
|
-
return gl.Position(s, outmask=Caps.
|
|
1280
|
+
return gl.Position(s, outmask=Caps.STANDARD_LINE)
|
|
1280
1281
|
|
|
1281
1282
|
def Segment(self, glA, glB, proven=None, raiser=True, **_C):
|
|
1282
1283
|
'''Find the intersection between two geodesic line segments.
|
|
@@ -1413,13 +1414,13 @@ class Intersector(_IntersectBase):
|
|
|
1413
1414
|
try:
|
|
1414
1415
|
_xgeodesics(gl.geodesic, self.geodesic)
|
|
1415
1416
|
if s13 and not isfinite(gl.s13): # or not gl.caps & Caps.DISTANCE_IN
|
|
1416
|
-
t = gl.geodesic.InverseLine
|
|
1417
|
-
raise TypeError(_not_(
|
|
1417
|
+
t = _an(typename(gl.geodesic.InverseLine))
|
|
1418
|
+
raise TypeError(_not_(t))
|
|
1418
1419
|
c = gl.caps & C
|
|
1419
1420
|
if c != C: # not gl.caps_(C)
|
|
1420
1421
|
c, C, x = map1(bin, c, C, _xor(c, C))
|
|
1421
|
-
|
|
1422
|
-
raise GeodesicError(caps=c, LINE_CAPS=C, txt=
|
|
1422
|
+
t = _SPACE_(typename(_xor), repr(x))[1:]
|
|
1423
|
+
raise GeodesicError(caps=c, LINE_CAPS=C, txt=t)
|
|
1423
1424
|
except Exception as x:
|
|
1424
1425
|
raise GeodesicError(n, gl, cause=x)
|
|
1425
1426
|
|
|
@@ -1524,7 +1525,7 @@ def _L1(a, b):
|
|
|
1524
1525
|
|
|
1525
1526
|
__all__ += _ALL_DOCS(_IntersectBase)
|
|
1526
1527
|
|
|
1527
|
-
if __name__ ==
|
|
1528
|
+
if __name__ == _DMAIN_: # MCCABE 14
|
|
1528
1529
|
|
|
1529
1530
|
from pygeodesy import printf
|
|
1530
1531
|
__help_ = '--help'
|
|
@@ -1627,7 +1628,7 @@ if __name__ == '__main__': # MCCABE 14
|
|
|
1627
1628
|
glA = I.Line(*args[:n])
|
|
1628
1629
|
glB = I.Line(*args[n:])
|
|
1629
1630
|
|
|
1630
|
-
m = _DOT_(I
|
|
1631
|
+
m = _DOT_(*map1(typename, type(I), M))
|
|
1631
1632
|
if _V:
|
|
1632
1633
|
X = _SPACE_(_X_, _EQUAL_, m)
|
|
1633
1634
|
printf(unstr(X, glA, glB, **kwds))
|