pygeodesy 24.5.6__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.6.dist-info → PyGeodesy-24.5.15.dist-info}/METADATA +4 -4
- {PyGeodesy-24.5.6.dist-info → PyGeodesy-24.5.15.dist-info}/RECORD +51 -50
- pygeodesy/__init__.py +18 -14
- 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 +161 -165
- 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 +14 -13
- pygeodesy/fstats.py +281 -219
- pygeodesy/fsums.py +133 -104
- 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 +5 -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.6.dist-info → PyGeodesy-24.5.15.dist-info}/WHEEL +0 -0
- {PyGeodesy-24.5.6.dist-info → PyGeodesy-24.5.15.dist-info}/top_level.txt +0 -0
pygeodesy/fsums.py
CHANGED
|
@@ -23,16 +23,18 @@ and L{Fsum.__itruediv__}.
|
|
|
23
23
|
# make sure int/int division yields float quotient, see .basics
|
|
24
24
|
from __future__ import division as _; del _ # PYCHOK semicolon
|
|
25
25
|
|
|
26
|
-
from pygeodesy.basics import isbool, iscomplex, isint, isscalar,
|
|
27
|
-
|
|
26
|
+
from pygeodesy.basics import isbool, iscomplex, isint, isscalar, \
|
|
27
|
+
_signOf, itemsorted, signOf, _xiterable, \
|
|
28
|
+
_enquote
|
|
28
29
|
from pygeodesy.constants import INT0, _isfinite, NEG0, _pos_self, \
|
|
29
30
|
_0_0, _1_0, _N_1_0, Float, Int
|
|
30
31
|
from pygeodesy.errors import _OverflowError, _TypeError, _ValueError, \
|
|
31
32
|
_xError, _xError2, _xkwds_get
|
|
33
|
+
# from pygeodesy.internals import _enquote # from .basics
|
|
32
34
|
from pygeodesy.interns import NN, _arg_, _COMMASPACE_, _DASH_, _DOT_, \
|
|
33
|
-
|
|
34
|
-
_not_finite_, _PERCENT_, _PLUS_,
|
|
35
|
-
_SLASH_, _SPACE_, _STAR_, _UNDER_
|
|
35
|
+
_EQUAL_, _from_, _LANGLE_, _NOTEQUAL_, \
|
|
36
|
+
_not_finite_, _PERCENT_, _PLUS_, \
|
|
37
|
+
_RANGLE_, _SLASH_, _SPACE_, _STAR_, _UNDER_
|
|
36
38
|
from pygeodesy.lazily import _ALL_LAZY, _getenv, _sys_version_info2
|
|
37
39
|
from pygeodesy.named import _Named, _NamedTuple, _NotImplemented
|
|
38
40
|
from pygeodesy.props import _allPropertiesOf_n, deprecated_property_RO, \
|
|
@@ -43,23 +45,18 @@ from pygeodesy.streprs import Fmt, fstr, unstr
|
|
|
43
45
|
from math import ceil as _ceil, fabs, floor as _floor # PYCHOK used! .ltp
|
|
44
46
|
|
|
45
47
|
__all__ = _ALL_LAZY.fsums
|
|
46
|
-
__version__ = '24.05.
|
|
48
|
+
__version__ = '24.05.13'
|
|
47
49
|
|
|
48
|
-
_abs = abs
|
|
49
50
|
_add_op_ = _PLUS_ # in .auxilats.auxAngle
|
|
50
51
|
_eq_op_ = _EQUAL_ * 2 # _DEQUAL_
|
|
51
52
|
_div_ = 'div'
|
|
52
|
-
_Float = float # in .fstats
|
|
53
53
|
_floordiv_op_ = _SLASH_ * 2 # _DSLASH_
|
|
54
54
|
_fset_op_ = _EQUAL_
|
|
55
55
|
_ge_op_ = _RANGLE_ + _EQUAL_
|
|
56
56
|
_gt_op_ = _RANGLE_
|
|
57
57
|
_iadd_op_ = _add_op_ + _EQUAL_ # in .auxilats.auxAngle, .fstats
|
|
58
58
|
_integer_ = 'integer'
|
|
59
|
-
_isAn = isinstance # in .fstats
|
|
60
59
|
_le_op_ = _LANGLE_ + _EQUAL_
|
|
61
|
-
_len = len
|
|
62
|
-
_List = list
|
|
63
60
|
_lt_op_ = _LANGLE_
|
|
64
61
|
_mod_ = 'mod'
|
|
65
62
|
_mod_op_ = _PERCENT_
|
|
@@ -71,7 +68,6 @@ _significant_ = 'significant'
|
|
|
71
68
|
_sub_op_ = _DASH_ # in .auxilats.auxAngle
|
|
72
69
|
_threshold_ = 'threshold'
|
|
73
70
|
_truediv_op_ = _SLASH_
|
|
74
|
-
_Tuple = tuple
|
|
75
71
|
_divmod_op_ = _floordiv_op_ + _mod_op_
|
|
76
72
|
_isub_op_ = _sub_op_ + _fset_op_ # in .auxilats.auxAngle
|
|
77
73
|
|
|
@@ -83,22 +79,28 @@ def _2delta(*ab):
|
|
|
83
79
|
a, b = _2sum(*ab)
|
|
84
80
|
except _OverflowError:
|
|
85
81
|
a, b = ab
|
|
86
|
-
return
|
|
82
|
+
return float(a if fabs(a) > fabs(b) else b)
|
|
87
83
|
|
|
88
84
|
|
|
89
|
-
def _2error(unused):
|
|
85
|
+
def _2error(unused): # in .fstats
|
|
90
86
|
'''(INTERNAL) Throw a C{not-finite} exception.
|
|
91
87
|
'''
|
|
92
88
|
raise ValueError(_not_finite_)
|
|
93
89
|
|
|
94
90
|
|
|
91
|
+
def _2finite(x):
|
|
92
|
+
'''(INTERNAL) return C{float(x)} if finite.
|
|
93
|
+
'''
|
|
94
|
+
x = float(x)
|
|
95
|
+
return x if _isfinite(x) else _2error(x)
|
|
96
|
+
|
|
97
|
+
|
|
95
98
|
def _2float(index=None, **name_value): # in .fmath, .fstats
|
|
96
99
|
'''(INTERNAL) Raise C{TypeError} or C{ValueError} if not scalar or infinite.
|
|
97
100
|
'''
|
|
98
101
|
n, v = name_value.popitem() # _xkwds_item2(name_value)
|
|
99
102
|
try:
|
|
100
|
-
|
|
101
|
-
return v if _isfinite(v) else _2error(v)
|
|
103
|
+
return _2finite(v)
|
|
102
104
|
except Exception as X:
|
|
103
105
|
raise _xError(X, Fmt.INDEX(n, index), v)
|
|
104
106
|
|
|
@@ -107,16 +109,16 @@ def _X_ps(X): # for _2floats only
|
|
|
107
109
|
return X._ps
|
|
108
110
|
|
|
109
111
|
|
|
110
|
-
def _2floats(xs, origin=0, _X=_X_ps, _x=
|
|
112
|
+
def _2floats(xs, origin=0, _X=_X_ps, _x=float):
|
|
111
113
|
'''(INTERNAL) Yield each B{C{xs}} as a C{float}.
|
|
112
114
|
'''
|
|
113
115
|
try:
|
|
114
|
-
i, x = origin,
|
|
116
|
+
i, x = origin, _X
|
|
115
117
|
_fin = _isfinite
|
|
116
118
|
_FsT = _Fsum_Fsum2Tuple_types
|
|
117
|
-
|
|
118
|
-
for x in xs:
|
|
119
|
-
if
|
|
119
|
+
_isa = isinstance
|
|
120
|
+
for x in _xiterable(xs):
|
|
121
|
+
if _isa(x, _FsT):
|
|
120
122
|
for p in _X(x._Fsum):
|
|
121
123
|
yield p
|
|
122
124
|
else:
|
|
@@ -124,7 +126,8 @@ def _2floats(xs, origin=0, _X=_X_ps, _x=_Float):
|
|
|
124
126
|
yield f if _fin(f) else _2error(f)
|
|
125
127
|
i += 1
|
|
126
128
|
except Exception as X:
|
|
127
|
-
raise _xError(X,
|
|
129
|
+
raise _xError(X, xs=xs) if x is _X else \
|
|
130
|
+
_xError(X, Fmt.INDEX(xs=i), x)
|
|
128
131
|
|
|
129
132
|
|
|
130
133
|
def _Fsumf_(*xs): # floats=True, in .auxLat, ...
|
|
@@ -154,13 +157,13 @@ def _2halfeven(s, r, p):
|
|
|
154
157
|
def _isFsum(x): # in .fmath
|
|
155
158
|
'''(INTERNAL) Is C{x} an C{Fsum} instance?
|
|
156
159
|
'''
|
|
157
|
-
return
|
|
160
|
+
return isinstance(x, Fsum)
|
|
158
161
|
|
|
159
162
|
|
|
160
163
|
def _isFsumTuple(x): # in .fmath
|
|
161
164
|
'''(INTERNAL) Is C{x} an C{Fsum} or C{Fsum2Tuple} instance?
|
|
162
165
|
'''
|
|
163
|
-
return
|
|
166
|
+
return isinstance(x, _Fsum_Fsum2Tuple_types)
|
|
164
167
|
|
|
165
168
|
|
|
166
169
|
def _1_Over(x, op, **raiser_RESIDUAL): # vs _1_over
|
|
@@ -182,8 +185,8 @@ def _1primed(xs): # in .fmath
|
|
|
182
185
|
def _psum(ps): # PYCHOK used!
|
|
183
186
|
'''(INTERNAL) Partials summation, updating C{ps}.
|
|
184
187
|
'''
|
|
185
|
-
# assert
|
|
186
|
-
i =
|
|
188
|
+
# assert isinstance(ps, list)
|
|
189
|
+
i = len(ps) - 1
|
|
187
190
|
s = _0_0 if i < 0 else ps[i]
|
|
188
191
|
_2s = _2sum
|
|
189
192
|
while i > 0:
|
|
@@ -206,7 +209,7 @@ def _Psum(ps, **name_RESIDUAL):
|
|
|
206
209
|
f = Fsum(**name_RESIDUAL) if name_RESIDUAL else Fsum()
|
|
207
210
|
if ps:
|
|
208
211
|
f._ps[:] = ps
|
|
209
|
-
f._n =
|
|
212
|
+
f._n = len(f._ps)
|
|
210
213
|
return f
|
|
211
214
|
|
|
212
215
|
|
|
@@ -249,7 +252,7 @@ def _strcomplex(s, *args):
|
|
|
249
252
|
'''(INTERNAL) C{Complex} 2- or 3-arg C{pow} error as C{str}.
|
|
250
253
|
'''
|
|
251
254
|
c = _strcomplex.__name__[4:]
|
|
252
|
-
n = _DASH_(
|
|
255
|
+
n = _DASH_(len(args), _arg_)
|
|
253
256
|
t = unstr(pow, *args)
|
|
254
257
|
return _SPACE_(c, s, _from_, n, t)
|
|
255
258
|
|
|
@@ -282,8 +285,7 @@ def _threshold(threshold):
|
|
|
282
285
|
'''(INTERNAL) Get the L{ResidualError}s threshold.
|
|
283
286
|
'''
|
|
284
287
|
try:
|
|
285
|
-
|
|
286
|
-
return t if _isfinite(t) else _2error(t) # PYCHOK None
|
|
288
|
+
return _2finite(threshold) # PYCHOK None
|
|
287
289
|
except Exception as x:
|
|
288
290
|
raise ResidualError(threshold=threshold, cause=x)
|
|
289
291
|
|
|
@@ -312,7 +314,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
312
314
|
_math_fsum = None
|
|
313
315
|
_n = 0
|
|
314
316
|
# _ps = [] # partial sums
|
|
315
|
-
# _ps_max = 0 # max(Fsum._ps_max,
|
|
317
|
+
# _ps_max = 0 # max(Fsum._ps_max, len(Fsum._ps))
|
|
316
318
|
_RESIDUAL = _threshold(_getenv('PYGEODESY_FSUM_RESIDUAL', _0_0))
|
|
317
319
|
|
|
318
320
|
def __init__(self, *xs, **name_RESIDUAL):
|
|
@@ -411,7 +413,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
411
413
|
|
|
412
414
|
@see: Methods L{Fsum.fsum} and L{Fsum.int_float}.
|
|
413
415
|
'''
|
|
414
|
-
return
|
|
416
|
+
return float(self._fprs)
|
|
415
417
|
|
|
416
418
|
def __floor__(self): # PYCHOK not special in Python 2-
|
|
417
419
|
'''Return this instance' C{math.floor} as C{int} or C{float}.
|
|
@@ -456,7 +458,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
456
458
|
def __iadd__(self, other):
|
|
457
459
|
'''Apply C{B{self} += B{other}} to this instance.
|
|
458
460
|
|
|
459
|
-
@arg other: An L{Fsum}, L{Fsum2Tuple} or C{scalar}
|
|
461
|
+
@arg other: An L{Fsum}, L{Fsum2Tuple} or C{scalar} value or
|
|
462
|
+
an iterable of several of the former.
|
|
460
463
|
|
|
461
464
|
@return: This instance, updated (L{Fsum}).
|
|
462
465
|
|
|
@@ -465,7 +468,10 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
465
468
|
|
|
466
469
|
@see: Methods L{Fsum.fadd_} and L{Fsum.fadd}.
|
|
467
470
|
'''
|
|
468
|
-
|
|
471
|
+
try:
|
|
472
|
+
return self._fadd(other, _iadd_op_)
|
|
473
|
+
except TypeError:
|
|
474
|
+
return self._facc_inplace(other, _iadd_op_, self._facc)
|
|
469
475
|
|
|
470
476
|
def __ifloordiv__(self, other):
|
|
471
477
|
'''Apply C{B{self} //= B{other}} to this instance.
|
|
@@ -572,7 +578,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
572
578
|
def __isub__(self, other):
|
|
573
579
|
'''Apply C{B{self} -= B{other}} to this instance.
|
|
574
580
|
|
|
575
|
-
@arg other: An L{Fsum}, L{Fsum2Tuple} or C{scalar}
|
|
581
|
+
@arg other: An L{Fsum}, L{Fsum2Tuple} or C{scalar} value or
|
|
582
|
+
an iterable of several of the former.
|
|
576
583
|
|
|
577
584
|
@return: This instance, updated (L{Fsum}).
|
|
578
585
|
|
|
@@ -580,7 +587,10 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
580
587
|
|
|
581
588
|
@see: Methods L{Fsum.fsub_} and L{Fsum.fsub}.
|
|
582
589
|
'''
|
|
583
|
-
|
|
590
|
+
try:
|
|
591
|
+
return self._fsub(other, _isub_op_)
|
|
592
|
+
except TypeError:
|
|
593
|
+
return self._facc_inplace(other, _isub_op_, self._facc_neg)
|
|
584
594
|
|
|
585
595
|
def __iter__(self):
|
|
586
596
|
'''Return an C{iter}ator over a C{partials} duplicate.
|
|
@@ -728,7 +738,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
728
738
|
'''
|
|
729
739
|
f = self._copy_2(self.__round__)
|
|
730
740
|
# <https://docs.Python.org/3.12/reference/datamodel.html?#object.__round__>
|
|
731
|
-
return f._fset(round(
|
|
741
|
+
return f._fset(round(float(self), *ndigits)) # can be C{int}
|
|
732
742
|
|
|
733
743
|
def __rpow__(self, other, *mod):
|
|
734
744
|
'''Return C{B{other}**B{self}} as an L{Fsum}.
|
|
@@ -809,7 +819,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
809
819
|
'''
|
|
810
820
|
n, r = self._fint2
|
|
811
821
|
if r:
|
|
812
|
-
i, d =
|
|
822
|
+
i, d = float(r).as_integer_ratio()
|
|
813
823
|
n *= d
|
|
814
824
|
n += i
|
|
815
825
|
else: # PYCHOK no cover
|
|
@@ -838,7 +848,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
838
848
|
c = _ceil(s) + int(r) - 1
|
|
839
849
|
while r > (c - s): # (s + r) > c
|
|
840
850
|
c += 1
|
|
841
|
-
return c
|
|
851
|
+
return c # _ceil(self._n_d)
|
|
842
852
|
|
|
843
853
|
cmp = __cmp__
|
|
844
854
|
|
|
@@ -860,7 +870,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
860
870
|
'''
|
|
861
871
|
f = _Named.copy(self, deep=deep, name=name)
|
|
862
872
|
if f._ps is self._ps:
|
|
863
|
-
f._ps =
|
|
873
|
+
f._ps = list(self._ps) # separate list
|
|
864
874
|
if not deep:
|
|
865
875
|
f._n = 1
|
|
866
876
|
# assert f._Fsum is f
|
|
@@ -872,7 +882,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
872
882
|
n = name or which.__name__
|
|
873
883
|
# NOT .classof due to .Fdot(a, *b) args, etc.
|
|
874
884
|
f = _Named.copy(self, deep=False, name=n)
|
|
875
|
-
f._ps =
|
|
885
|
+
f._ps = list(self._ps) # separate list
|
|
876
886
|
# assert f._n == self._n
|
|
877
887
|
# assert f._Fsum is f
|
|
878
888
|
return f
|
|
@@ -909,7 +919,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
909
919
|
'''(INTERNAL) Format the caught exception C{X}.
|
|
910
920
|
'''
|
|
911
921
|
E, t = _xError2(X)
|
|
912
|
-
u = unstr(self.named3, *xs[:3], _ELLIPSIS=
|
|
922
|
+
u = unstr(self.named3, *xs[:3], _ELLIPSIS=len(xs) > 3, **kwds)
|
|
913
923
|
return E(u, txt=t, cause=X)
|
|
914
924
|
|
|
915
925
|
def _facc(self, xs, up=True, **origin_X_x):
|
|
@@ -918,16 +928,24 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
918
928
|
if xs:
|
|
919
929
|
_xs = _2floats(xs, **origin_X_x) # PYCHOK yield
|
|
920
930
|
ps = self._ps
|
|
921
|
-
ps[:] = self._ps_acc(
|
|
931
|
+
ps[:] = self._ps_acc(list(ps), _xs, up=up)
|
|
922
932
|
return self
|
|
923
933
|
|
|
924
934
|
def _facc_1(self, xs, **up):
|
|
925
935
|
'''(INTERNAL) Accumulate 0, 1 or more C{scalars} or L{Fsum}s,
|
|
926
936
|
all positional C{xs} in the caller of this method.
|
|
927
937
|
'''
|
|
928
|
-
return self._fadd(xs[0], _add_op_, **up) if
|
|
938
|
+
return self._fadd(xs[0], _add_op_, **up) if len(xs) == 1 else \
|
|
929
939
|
self._facc(xs, origin=1, **up)
|
|
930
940
|
|
|
941
|
+
def _facc_inplace(self, other, op, _facc):
|
|
942
|
+
'''(INTERNAL) Accumulate from an iterable.
|
|
943
|
+
'''
|
|
944
|
+
try:
|
|
945
|
+
return _facc(other, origin=1) if _xiterable(other) else self
|
|
946
|
+
except Exception as X:
|
|
947
|
+
raise self._ErrorX(X, op, other)
|
|
948
|
+
|
|
931
949
|
def _facc_neg(self, xs, **up_origin):
|
|
932
950
|
'''(INTERNAL) Accumulate more C{scalars} or L{Fsum}s, negated.
|
|
933
951
|
'''
|
|
@@ -935,7 +953,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
935
953
|
return X._ps_neg
|
|
936
954
|
|
|
937
955
|
def _n(x):
|
|
938
|
-
return -
|
|
956
|
+
return -float(x)
|
|
939
957
|
|
|
940
958
|
return self._facc(xs, _X=_N, _x=_n, **up_origin)
|
|
941
959
|
|
|
@@ -961,16 +979,17 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
961
979
|
_Pow, p, s, r = _Pow4(power)
|
|
962
980
|
if p: # and xs:
|
|
963
981
|
op = which.__name__
|
|
982
|
+
_flt = float
|
|
964
983
|
_Fs = Fsum
|
|
965
|
-
|
|
984
|
+
_isa = isinstance
|
|
966
985
|
_pow = self._pow_2_3
|
|
967
986
|
|
|
968
987
|
def _P(X):
|
|
969
988
|
f = _Pow(X, p, power, op, **raiser_RESIDUAL)
|
|
970
|
-
return f._ps if
|
|
989
|
+
return f._ps if _isa(f, _Fs) else (f,)
|
|
971
990
|
|
|
972
991
|
def _p(x):
|
|
973
|
-
x =
|
|
992
|
+
x = _flt(x)
|
|
974
993
|
f = _pow(x, s, power, op, **raiser_RESIDUAL)
|
|
975
994
|
if f and r:
|
|
976
995
|
f *= _pow(x, r, power, op, **raiser_RESIDUAL)
|
|
@@ -978,7 +997,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
978
997
|
|
|
979
998
|
f = self._facc(xs, origin=1, _X=_P, _x=_p)
|
|
980
999
|
else:
|
|
981
|
-
f = self._facc_scalar_(
|
|
1000
|
+
f = self._facc_scalar_(float(len(xs))) # x**0 == 1
|
|
982
1001
|
return f
|
|
983
1002
|
|
|
984
1003
|
def _facc_scalar(self, xs, **up):
|
|
@@ -1000,7 +1019,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1000
1019
|
# and re-accumulating the final C{partial}.
|
|
1001
1020
|
# '''
|
|
1002
1021
|
# ps = self._ps
|
|
1003
|
-
# while
|
|
1022
|
+
# while len(ps) > 1:
|
|
1004
1023
|
# p = ps.pop()
|
|
1005
1024
|
# if p:
|
|
1006
1025
|
# n = self._n
|
|
@@ -1024,10 +1043,10 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1024
1043
|
@raise ValueError: Invalid or non-finite B{C{xs}} value.
|
|
1025
1044
|
'''
|
|
1026
1045
|
if _isFsumTuple(xs):
|
|
1027
|
-
self._facc_scalar(xs._ps)
|
|
1046
|
+
self._facc_scalar(xs._ps)
|
|
1028
1047
|
elif isscalar(xs): # for backward compatibility
|
|
1029
1048
|
self._facc_scalar_(_2float(x=xs)) # PYCHOK no cover
|
|
1030
|
-
elif xs: #
|
|
1049
|
+
elif xs: # _xiterable(xs)
|
|
1031
1050
|
self._facc(xs)
|
|
1032
1051
|
return self
|
|
1033
1052
|
|
|
@@ -1045,9 +1064,9 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1045
1064
|
'''(INTERNAL) Apply C{B{self} += B{other}}.
|
|
1046
1065
|
'''
|
|
1047
1066
|
if not self._ps: # new Fsum(x)
|
|
1048
|
-
self._fset(other,
|
|
1067
|
+
self._fset(other, op=op, **up)
|
|
1049
1068
|
elif _isFsumTuple(other):
|
|
1050
|
-
self._facc_scalar(other._ps, **up)
|
|
1069
|
+
self._facc_scalar(other._ps, **up)
|
|
1051
1070
|
elif self._scalar(other, op):
|
|
1052
1071
|
self._facc_scalar_(other, **up)
|
|
1053
1072
|
return self
|
|
@@ -1125,9 +1144,9 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1125
1144
|
'''(INTERNAL) Get 2-tuple (C{int}, I{integer} residual).
|
|
1126
1145
|
'''
|
|
1127
1146
|
s, r = self._fprs2
|
|
1128
|
-
i =
|
|
1129
|
-
n =
|
|
1130
|
-
r =
|
|
1147
|
+
i = int(s)
|
|
1148
|
+
n = len(self._ps)
|
|
1149
|
+
r = self._ps_1sum(i) if r and n > 1 else float(s - i)
|
|
1131
1150
|
return i, (r or INT0) # Fsum2Tuple?
|
|
1132
1151
|
|
|
1133
1152
|
@deprecated_property_RO
|
|
@@ -1149,7 +1168,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1149
1168
|
f = _floor(s) + _floor(r) + 1
|
|
1150
1169
|
while (f - s) > r: # f > (s + r)
|
|
1151
1170
|
f -= 1
|
|
1152
|
-
return f
|
|
1171
|
+
return f # _floor(self._n_d)
|
|
1153
1172
|
|
|
1154
1173
|
# ffloordiv = __ifloordiv__ # for naming consistency
|
|
1155
1174
|
# floordiv = __floordiv__ # for naming consistency
|
|
@@ -1166,16 +1185,16 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1166
1185
|
'''(INTERNAL) Apply C{B{self} *= B{other}}.
|
|
1167
1186
|
'''
|
|
1168
1187
|
if _isFsumTuple(other):
|
|
1169
|
-
if
|
|
1188
|
+
if len(self._ps) != 1:
|
|
1170
1189
|
f = self._mul_Fsum(other, op)
|
|
1171
|
-
elif
|
|
1190
|
+
elif len(other._ps) != 1: # and len(self._ps) == 1
|
|
1172
1191
|
f = other._mul_scalar(self._ps[0], op)
|
|
1173
|
-
else: #
|
|
1192
|
+
else: # len(other._ps) == len(self._ps) == 1
|
|
1174
1193
|
f = self._finite(self._ps[0] * other._ps[0])
|
|
1175
1194
|
else:
|
|
1176
1195
|
s = self._scalar(other, op)
|
|
1177
1196
|
f = self._mul_scalar(s, op)
|
|
1178
|
-
return self._fset(f) # n=
|
|
1197
|
+
return self._fset(f) # n=len(self) + 1
|
|
1179
1198
|
|
|
1180
1199
|
def fover(self, over, **raiser_RESIDUAL):
|
|
1181
1200
|
'''Apply C{B{self} /= B{over}} and summate.
|
|
@@ -1192,7 +1211,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1192
1211
|
|
|
1193
1212
|
@see: Methods L{Fsum.fsum} and L{Fsum.__itruediv__}.
|
|
1194
1213
|
'''
|
|
1195
|
-
return
|
|
1214
|
+
return float(self.fdiv(over, **raiser_RESIDUAL)._fprs)
|
|
1196
1215
|
|
|
1197
1216
|
fpow = __ipow__
|
|
1198
1217
|
|
|
@@ -1212,7 +1231,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1212
1231
|
f = self._pow(other, other, op, **raiser_RESIDUAL)
|
|
1213
1232
|
else: # pow(self, other)
|
|
1214
1233
|
f = self._pow(other, other, op, **raiser_RESIDUAL)
|
|
1215
|
-
return self._fset(f
|
|
1234
|
+
return self._fset(f) # n=max(len(self), 1)
|
|
1216
1235
|
|
|
1217
1236
|
@Property_RO
|
|
1218
1237
|
def _fprs(self):
|
|
@@ -1222,27 +1241,28 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1222
1241
|
@note: The precision running C{fsum} after a C{//=} or
|
|
1223
1242
|
C{//} C{floor} division is C{int} in Python 3+.
|
|
1224
1243
|
'''
|
|
1225
|
-
|
|
1244
|
+
s, _ = self._fprs2
|
|
1245
|
+
return s # ._fprs2.fsum
|
|
1226
1246
|
|
|
1227
1247
|
@Property_RO
|
|
1228
1248
|
def _fprs2(self):
|
|
1229
1249
|
'''(INTERNAL) Get and cache this instance' precision
|
|
1230
1250
|
running sum and residual (L{Fsum2Tuple}).
|
|
1231
1251
|
'''
|
|
1232
|
-
ps =
|
|
1233
|
-
n =
|
|
1234
|
-
if n > 0: #
|
|
1252
|
+
ps = self._ps
|
|
1253
|
+
n = len(ps) - 2
|
|
1254
|
+
if n > 0: # len(ps) > 2
|
|
1235
1255
|
s = _psum(ps)
|
|
1236
|
-
n =
|
|
1256
|
+
n = len(ps) - 2
|
|
1237
1257
|
if n > 0:
|
|
1238
1258
|
r = self._ps_1sum(s)
|
|
1239
1259
|
return Fsum2Tuple(*_s_r(s, r))
|
|
1240
|
-
if n == 0: #
|
|
1260
|
+
if n == 0: # len(ps) == 2
|
|
1241
1261
|
s, r = _s_r(*_2sum(*ps))
|
|
1242
1262
|
ps[:] = (r, s) if r else (s,)
|
|
1243
|
-
elif ps: #
|
|
1263
|
+
elif ps: # len(ps) == 1
|
|
1244
1264
|
s, r = ps[0], INT0
|
|
1245
|
-
else: #
|
|
1265
|
+
else: # len(ps) == 0
|
|
1246
1266
|
s, r = _0_0, INT0
|
|
1247
1267
|
ps[:] = s,
|
|
1248
1268
|
# assert self._ps is ps
|
|
@@ -1259,10 +1279,11 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1259
1279
|
|
|
1260
1280
|
@see: Method L{Fsum.fadd} for further details.
|
|
1261
1281
|
'''
|
|
1262
|
-
f =
|
|
1282
|
+
f = xs[0] if len(xs) == 1 else (
|
|
1283
|
+
Fsum(*xs) if xs else _0_0)
|
|
1263
1284
|
return self._fset(f)
|
|
1264
1285
|
|
|
1265
|
-
def _fset(self, other,
|
|
1286
|
+
def _fset(self, other, n=0, up=True, **op):
|
|
1266
1287
|
'''(INTERNAL) Overwrite this instance with an other or a C{scalar}.
|
|
1267
1288
|
'''
|
|
1268
1289
|
if other is self:
|
|
@@ -1276,7 +1297,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1276
1297
|
Fsum._fprs ._update_from(self, other)
|
|
1277
1298
|
Fsum._fprs2._update_from(self, other)
|
|
1278
1299
|
elif isscalar(other):
|
|
1279
|
-
s = other if
|
|
1300
|
+
s = float(self._finite(other, **op)) if op else other
|
|
1280
1301
|
self._ps[:] = s,
|
|
1281
1302
|
self._n = n or 1
|
|
1282
1303
|
if up:
|
|
@@ -1286,7 +1307,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1286
1307
|
# Property's _fset zaps the value just set by the @setter
|
|
1287
1308
|
self.__dict__.update(_fint2=t, _fprs=s, _fprs2=Fsum2Tuple(s, INT0))
|
|
1288
1309
|
else: # PYCHOK no cover
|
|
1289
|
-
|
|
1310
|
+
op = _xkwds_get(op, op=_fset_op_)
|
|
1311
|
+
raise self._Error(op, other, _TypeError)
|
|
1290
1312
|
return self
|
|
1291
1313
|
|
|
1292
1314
|
def _fset_ps(self, other, n=0): # in .fmath
|
|
@@ -1312,7 +1334,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1312
1334
|
|
|
1313
1335
|
@see: Method L{Fsum.fadd_} for further details.
|
|
1314
1336
|
'''
|
|
1315
|
-
return self._fsub(xs[0], _sub_op_) if
|
|
1337
|
+
return self._fsub(xs[0], _sub_op_) if len(xs) == 1 else \
|
|
1316
1338
|
self._facc_neg(xs, origin=1)
|
|
1317
1339
|
|
|
1318
1340
|
def _fsub(self, other, op):
|
|
@@ -1320,7 +1342,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1320
1342
|
'''
|
|
1321
1343
|
if _isFsumTuple(other):
|
|
1322
1344
|
if other is self: # or other._fprs2 == self._fprs2:
|
|
1323
|
-
self._fset(_0_0, n=
|
|
1345
|
+
self._fset(_0_0, n=len(self) * 2)
|
|
1324
1346
|
elif other._ps:
|
|
1325
1347
|
self._facc_scalar(other._ps_neg)
|
|
1326
1348
|
elif self._scalar(other, op):
|
|
@@ -1356,7 +1378,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1356
1378
|
return self._facc_1(xs)._fprs
|
|
1357
1379
|
|
|
1358
1380
|
@property_RO
|
|
1359
|
-
def _Fsum(self): # like L{Fsum2Tuple._Fsum}, for C{_2floats}.
|
|
1381
|
+
def _Fsum(self): # like L{Fsum2Tuple._Fsum}, for C{_2floats}, .fstats
|
|
1360
1382
|
return self # NOT @Property_RO, see .copy and ._copy_2
|
|
1361
1383
|
|
|
1362
1384
|
def Fsum_(self, *xs, **name):
|
|
@@ -1411,12 +1433,12 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1411
1433
|
'''
|
|
1412
1434
|
return self._fsum2(xs, self._facc_1)
|
|
1413
1435
|
|
|
1414
|
-
def _fsum2(self, xs,
|
|
1436
|
+
def _fsum2(self, xs, _facc, **origin):
|
|
1415
1437
|
'''(INTERNAL) Helper for L{Fsum.fsum2_} and L{Fsum.fsum2f_}.
|
|
1416
1438
|
'''
|
|
1417
1439
|
p, q = self._fprs2
|
|
1418
1440
|
if xs:
|
|
1419
|
-
s, r =
|
|
1441
|
+
s, r = _facc(xs, **origin)._fprs2
|
|
1420
1442
|
return s, _2delta(s - p, r - q) # _fsum(_1primed((s, -p, r, -q))
|
|
1421
1443
|
else:
|
|
1422
1444
|
return p, _0_0
|
|
@@ -1444,7 +1466,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1444
1466
|
n = _1_0
|
|
1445
1467
|
if _isFsumTuple(other):
|
|
1446
1468
|
if other is self or self == other:
|
|
1447
|
-
return self._fset(n
|
|
1469
|
+
return self._fset(n, n=len(self))
|
|
1448
1470
|
d, r = other._fprs2
|
|
1449
1471
|
if r:
|
|
1450
1472
|
R = self._raiser(r, d, **raiser_RESIDUAL)
|
|
@@ -1458,7 +1480,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1458
1480
|
except Exception as X:
|
|
1459
1481
|
raise self._ErrorX(X, op, other)
|
|
1460
1482
|
f = self._mul_scalar(s, _mul_op_) # handles 0, INF, NAN
|
|
1461
|
-
return self._fset(f)
|
|
1483
|
+
return self._fset(f)
|
|
1462
1484
|
|
|
1463
1485
|
@property_RO
|
|
1464
1486
|
def imag(self):
|
|
@@ -1493,7 +1515,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1493
1515
|
if R:
|
|
1494
1516
|
t = _stresidual(_non_zero_, r, **R)
|
|
1495
1517
|
raise ResidualError(int_float=s, txt=t)
|
|
1496
|
-
s =
|
|
1518
|
+
s = float(s)
|
|
1497
1519
|
return s
|
|
1498
1520
|
|
|
1499
1521
|
def is_exact(self):
|
|
@@ -1559,13 +1581,18 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1559
1581
|
'''
|
|
1560
1582
|
# assert isscalar(factor)
|
|
1561
1583
|
if self._ps and self._finite(factor, op):
|
|
1562
|
-
f = self if factor == _1_0
|
|
1584
|
+
f = self if factor == _1_0 else (
|
|
1563
1585
|
self._neg if factor == _N_1_0 else
|
|
1564
1586
|
self._ps_mul(op, factor).as_iscalar)
|
|
1565
1587
|
else:
|
|
1566
1588
|
f = _0_0
|
|
1567
1589
|
return f
|
|
1568
1590
|
|
|
1591
|
+
# @property_RO
|
|
1592
|
+
# def _n_d(self):
|
|
1593
|
+
# n, d = self.as_integer_ratio()
|
|
1594
|
+
# return n / d
|
|
1595
|
+
|
|
1569
1596
|
@property_RO
|
|
1570
1597
|
def _neg(self):
|
|
1571
1598
|
'''(INTERNAL) Return C{Fsum(-self)} or scalar C{NEG0}.
|
|
@@ -1576,7 +1603,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1576
1603
|
def partials(self):
|
|
1577
1604
|
'''Get this instance' current, partial sums (C{tuple} of C{float}s).
|
|
1578
1605
|
'''
|
|
1579
|
-
return
|
|
1606
|
+
return tuple(self._ps)
|
|
1580
1607
|
|
|
1581
1608
|
def pow(self, x, *mod, **raiser_RESIDUAL):
|
|
1582
1609
|
'''Return C{B{self}**B{x}} as L{Fsum}.
|
|
@@ -1664,7 +1691,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1664
1691
|
'''
|
|
1665
1692
|
# assert isint(x) and x >= 0
|
|
1666
1693
|
ps = self._ps
|
|
1667
|
-
if
|
|
1694
|
+
if len(ps) > 1:
|
|
1668
1695
|
_mul_Fsum = Fsum._mul_Fsum
|
|
1669
1696
|
if x > 4:
|
|
1670
1697
|
p = self
|
|
@@ -1696,8 +1723,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1696
1723
|
if r:
|
|
1697
1724
|
# assert s != 0
|
|
1698
1725
|
if isint(x, both=True): # self**int
|
|
1699
|
-
x =
|
|
1700
|
-
y =
|
|
1726
|
+
x = int(x)
|
|
1727
|
+
y = abs(x)
|
|
1701
1728
|
if y > 1:
|
|
1702
1729
|
f = self._pow_int(y, other, op, **raiser_RESIDUAL)
|
|
1703
1730
|
if x > 0: # i.e. > 1
|
|
@@ -1721,7 +1748,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1721
1748
|
if R:
|
|
1722
1749
|
raise self._ResidualError(op, other, r, **R)
|
|
1723
1750
|
n, d = self.as_integer_ratio()
|
|
1724
|
-
if
|
|
1751
|
+
if abs(n) > abs(d):
|
|
1725
1752
|
n, d, x = d, n, (-x)
|
|
1726
1753
|
s = n / d
|
|
1727
1754
|
# assert isscalar(s) and isscalar(x)
|
|
@@ -1732,7 +1759,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1732
1759
|
'''
|
|
1733
1760
|
n = 0
|
|
1734
1761
|
_2s = _2sum
|
|
1735
|
-
for x in (
|
|
1762
|
+
for x in (tuple(xs) if xs is ps else xs):
|
|
1736
1763
|
# assert isscalar(x) and _isfinite(x)
|
|
1737
1764
|
if x:
|
|
1738
1765
|
i = 0
|
|
@@ -1745,17 +1772,17 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1745
1772
|
n += 1
|
|
1746
1773
|
if n:
|
|
1747
1774
|
self._n += n
|
|
1748
|
-
# Fsum._ps_max = max(Fsum._ps_max,
|
|
1775
|
+
# Fsum._ps_max = max(Fsum._ps_max, len(ps))
|
|
1749
1776
|
if up:
|
|
1750
1777
|
self._update()
|
|
1751
1778
|
return ps
|
|
1752
1779
|
|
|
1753
1780
|
def _ps_mul(self, op, *factors):
|
|
1754
|
-
'''(INTERNAL) Multiply this instance' C{partials} with
|
|
1755
|
-
|
|
1781
|
+
'''(INTERNAL) Multiply this instance' C{partials} with
|
|
1782
|
+
each scalar C{factor} and accumulate into an C{Fsum}.
|
|
1756
1783
|
'''
|
|
1757
1784
|
def _pfs(ps, fs):
|
|
1758
|
-
if
|
|
1785
|
+
if len(ps) < len(fs):
|
|
1759
1786
|
ps, fs = fs, ps
|
|
1760
1787
|
_fin = _isfinite
|
|
1761
1788
|
for f in fs:
|
|
@@ -1763,7 +1790,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1763
1790
|
p *= f
|
|
1764
1791
|
yield p if _fin(p) else self._finite(p, op)
|
|
1765
1792
|
|
|
1766
|
-
return
|
|
1793
|
+
return Fsum()._facc_scalar(_pfs(self._ps, factors), up=False)
|
|
1767
1794
|
|
|
1768
1795
|
@property_RO
|
|
1769
1796
|
def _ps_neg(self):
|
|
@@ -1773,7 +1800,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1773
1800
|
yield -p
|
|
1774
1801
|
|
|
1775
1802
|
def _ps_1sum(self, *less):
|
|
1776
|
-
'''(INTERNAL) Return the partials sum, 1-primed C{less}
|
|
1803
|
+
'''(INTERNAL) Return the partials sum, 1-primed C{less} some scalars.
|
|
1777
1804
|
'''
|
|
1778
1805
|
def _1pls(ps, ls):
|
|
1779
1806
|
yield _1_0
|
|
@@ -1800,6 +1827,8 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1800
1827
|
return dict(ratio=q, R=t)
|
|
1801
1828
|
return {}
|
|
1802
1829
|
|
|
1830
|
+
rdiv = __rtruediv__
|
|
1831
|
+
|
|
1803
1832
|
@property_RO
|
|
1804
1833
|
def real(self):
|
|
1805
1834
|
'''Get the C{real} part of this instance (C{float}).
|
|
@@ -1808,7 +1837,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1808
1837
|
and properties L{Fsum.ceil}, L{Fsum.floor},
|
|
1809
1838
|
L{Fsum.imag} and L{Fsum.residual}.
|
|
1810
1839
|
'''
|
|
1811
|
-
return
|
|
1840
|
+
return float(self._fprs)
|
|
1812
1841
|
|
|
1813
1842
|
@property_RO
|
|
1814
1843
|
def residual(self):
|
|
@@ -1922,7 +1951,7 @@ class Fsum(_Named): # sync __methods__ with .vector3dBase.Vector3dBase
|
|
|
1922
1951
|
'''
|
|
1923
1952
|
p = self.classname
|
|
1924
1953
|
if lenc:
|
|
1925
|
-
p = Fmt.SQUARE(p,
|
|
1954
|
+
p = Fmt.SQUARE(p, len(self))
|
|
1926
1955
|
n = _enquote(self.name, white=_UNDER_)
|
|
1927
1956
|
t = self._fprs2.toStr(**prec_sep_fmt)
|
|
1928
1957
|
return NN(p, _SPACE_, n, t)
|
|
@@ -1966,7 +1995,7 @@ class DivMod2Tuple(_NamedTuple):
|
|
|
1966
1995
|
_Units_ = (_Float_Int, Fsum)
|
|
1967
1996
|
|
|
1968
1997
|
|
|
1969
|
-
class Fsum2Tuple(_NamedTuple):
|
|
1998
|
+
class Fsum2Tuple(_NamedTuple): # in .fstats
|
|
1970
1999
|
'''2-Tuple C{(fsum, residual)} with the precision running C{fsum}
|
|
1971
2000
|
and the C{residual}, the sum of the remaining partials. Each
|
|
1972
2001
|
item is C{float} or C{int}.
|
|
@@ -2031,7 +2060,7 @@ class Fsum2Tuple(_NamedTuple):
|
|
|
2031
2060
|
return self._Fsum._fprs2
|
|
2032
2061
|
|
|
2033
2062
|
@Property_RO
|
|
2034
|
-
def _Fsum(self): # this C{Fsum2Tuple} as L{Fsum}
|
|
2063
|
+
def _Fsum(self): # this C{Fsum2Tuple} as L{Fsum}, in .fstats
|
|
2035
2064
|
s, r = _s_r(*self)
|
|
2036
2065
|
ps = (r, s) if r else (s,)
|
|
2037
2066
|
return _Psum(ps, name=self.name)
|
|
@@ -2060,7 +2089,7 @@ class Fsum2Tuple(_NamedTuple):
|
|
|
2060
2089
|
return self._Fsum._n
|
|
2061
2090
|
|
|
2062
2091
|
def _other_op(self, other, which):
|
|
2063
|
-
C, s = (
|
|
2092
|
+
C, s = (tuple, self) if isinstance(other, tuple) else (Fsum, self._Fsum)
|
|
2064
2093
|
return getattr(C, which.__name__)(s, other)
|
|
2065
2094
|
|
|
2066
2095
|
@property_RO
|
|
@@ -2085,7 +2114,7 @@ class Fsum2Tuple(_NamedTuple):
|
|
|
2085
2114
|
'''
|
|
2086
2115
|
return Fmt.PAREN(fstr(self, fmt=fmt, strepr=str, force=False, **prec_sep))
|
|
2087
2116
|
|
|
2088
|
-
_Fsum_Fsum2Tuple_types = Fsum, Fsum2Tuple # PYCHOK
|
|
2117
|
+
_Fsum_Fsum2Tuple_types = Fsum, Fsum2Tuple # PYCHOK lines
|
|
2089
2118
|
|
|
2090
2119
|
|
|
2091
2120
|
class ResidualError(_ValueError):
|
|
@@ -2217,7 +2246,7 @@ if __name__ == '__main__':
|
|
|
2217
2246
|
F = Fsum()
|
|
2218
2247
|
if F.is_math_fsum():
|
|
2219
2248
|
for t in frandoms(n, seeded=True):
|
|
2220
|
-
assert
|
|
2249
|
+
assert float(F.fset_(*t)) == _fsum(t)
|
|
2221
2250
|
printf(_DOT_, end=NN)
|
|
2222
2251
|
printf(NN)
|
|
2223
2252
|
|