pygeodesy 24.4.2__py2.py3-none-any.whl → 24.4.12__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/fmath.py CHANGED
@@ -8,9 +8,9 @@ from __future__ import division as _; del _ # PYCHOK semicolon
8
8
 
9
9
  from pygeodesy.basics import _copysign, copysign0, isint, len2
10
10
  from pygeodesy.constants import EPS0, EPS02, EPS1, NAN, PI, PI_2, PI_4, \
11
- _0_0, _0_125, _0_25, _0_5, _1_0, _N_1_0, \
12
- _1_3rd, _1_5, _1_6th, _2_0, _2_3rd, _3_0, \
13
- _isfinite, isnear1, _over, remainder
11
+ _0_0, _0_125, _0_25, _0_5, _1_0, _1_3rd, \
12
+ _1_5, _1_6th, _2_0, _2_3rd, _3_0, \
13
+ _copysign_0_0, _isfinite, _over, remainder
14
14
  from pygeodesy.errors import _IsnotError, LenError, _TypeError, _ValueError, \
15
15
  _xError, _xkwds_get, _xkwds_pop2
16
16
  from pygeodesy.fsums import _2float, Fsum, _fsum, fsum, fsum1_, _pow_op_, \
@@ -25,7 +25,7 @@ from math import fabs, sqrt # pow
25
25
  import operator as _operator # in .datums, .trf, .utm
26
26
 
27
27
  __all__ = _ALL_LAZY.fmath
28
- __version__ = '24.03.31'
28
+ __version__ = '24.04.04'
29
29
 
30
30
  # sqrt(2) <https://WikiPedia.org/wiki/Square_root_of_2>
31
31
  _0_4142 = 0.41421356237309504880 # ... sqrt(2) - 1
@@ -116,8 +116,8 @@ class Fhypot(Fsum):
116
116
  self._fpow(r, _pow_op_)
117
117
  else:
118
118
  self._fset(_0_0)
119
- except Exception as X:
120
- raise self._ErrorX(X, xs, power=p)
119
+ except Exception as x:
120
+ raise self._ErrorXs(x, xs, power=p)
121
121
 
122
122
 
123
123
  class Fpolynomial(Fsum):
@@ -169,7 +169,7 @@ class Fpowers(Fsum):
169
169
  else:
170
170
  self._fset(_0_0)
171
171
  except Exception as x:
172
- raise self._ErrorX(x, xs, power=power)
172
+ raise self._ErrorXs(x, xs, power=power)
173
173
 
174
174
 
175
175
  class Fn_rt(Fsum):
@@ -193,7 +193,7 @@ class Fn_rt(Fsum):
193
193
  else:
194
194
  self._fset(_0_0)
195
195
  except Exception as x:
196
- raise self._ErrorX(x, xs, root=root)
196
+ raise self._ErrorXs(x, xs, root=root)
197
197
 
198
198
 
199
199
  class Fcbrt(Fn_rt):
@@ -359,7 +359,7 @@ def fatan1(x):
359
359
  # Eq (9): PI_4 * x - x * (abs(x) - 1) * (0.2447 + 0.0663 * abs(x)), for -1 < x < 1
360
360
  # PI_4 * x - (x**2 - x) * (0.2447 + 0.0663 * x), for 0 < x - 1
361
361
  # x * (1.0300981633974482 + x * (-0.1784 - x * 0.0663))
362
- H = Fhorner(x, _0_0, 1.0300982, -0.1784, -0.0663)
362
+ H = Fhorner(x, _0_0, 1.0300981634, -0.1784, -0.0663)
363
363
  return float(H)
364
364
 
365
365
 
@@ -716,7 +716,7 @@ if _sys_version_info2 < (3, 8): # PYCHOK no cover
716
716
  computed as M{hypot_(*((c1 - c2) for c1, c2 in zip(p1, p2)))},
717
717
  provided I{p1} and I{p2} have the same, non-zero length I{n}.
718
718
  '''
719
- h, x2 = _h_x2(xs)
719
+ h, x2 = _h_x2(xs, hypot_)
720
720
  return (h * sqrt(x2)) if x2 else _0_0
721
721
 
722
722
  elif _sys_version_info2 < (3, 10):
@@ -747,22 +747,23 @@ else:
747
747
  hypot_ = hypot
748
748
 
749
749
 
750
- def _h_x2(xs):
750
+ def _h_x2(xs, which):
751
751
  '''(INTERNAL) Helper for L{hypot_} and L{hypot2_}.
752
752
  '''
753
- if xs:
754
- n, xs = len2(xs)
755
- if n > 0:
756
- h = float(max(map(fabs, xs)))
757
- if h < EPS0:
758
- x2 = _0_0
759
- elif h in (_1_0, _N_1_0):
760
- x2 = _fsum(_1primed(x**2 for x in xs))
761
- else: # math.fsum
762
- x2 = _fsum(_1primed((x / h)**2 for x in xs))
763
- return h, x2
753
+ n, xs = len2(xs)
754
+ if n > 0:
755
+ h = float(max(map(fabs, xs)))
756
+ if h < EPS0:
757
+ x2 = _0_0
758
+ elif n > 1:
759
+ _h = (_1_0 / h) if h != _1_0 else _1_0
760
+ x2 = _fsum(_1primed((x * _h)**2 for x in xs))
761
+ else:
762
+ x2 = _1_0
763
+ return h, x2
764
764
 
765
- raise _ValueError(xs=xs, txt=_too_(_few_))
765
+ t = Fmt.PAREN(which.__name__, xs)
766
+ raise _ValueError(t, txt=_too_(_few_))
766
767
 
767
768
 
768
769
  def hypot1(x):
@@ -783,15 +784,12 @@ def hypot2(x, y):
783
784
 
784
785
  @return: C{B{x}**2 + B{y}**2} (C{float}).
785
786
  '''
787
+ if fabs(x) < fabs(y):
788
+ x, y = y, x
786
789
  if x:
790
+ h2 = x**2
787
791
  if y:
788
- if fabs(x) < fabs(y):
789
- x, y = y, x
790
- h2 = x**2 * ((y / x)**2 + _1_0)
791
- else:
792
- h2 = x**2
793
- elif y:
794
- h2 = y**2
792
+ h2 *= (y / x)**2 + _1_0
795
793
  else:
796
794
  h2 = _0_0
797
795
  return h2
@@ -810,7 +808,7 @@ def hypot2_(*xs):
810
808
 
811
809
  @see: Function L{hypot_}.
812
810
  '''
813
- h, x2 = _h_x2(xs)
811
+ h, x2 = _h_x2(xs, hypot2_)
814
812
  return (h**2 * x2) if x2 else _0_0
815
813
 
816
814
 
@@ -840,14 +838,15 @@ def norm2(x, y):
840
838
  @raise ValueError: Invalid B{C{x}} or B{C{y}}
841
839
  or zero norm.
842
840
  '''
843
- h = hypot(x, y)
844
- if not h:
845
- x = y = _0_0 # pass?
846
- elif not isnear1(h):
847
- try:
848
- x, y = x / h, y / h
849
- except Exception as e:
850
- raise _xError(e, x=x, y=y, h=h)
841
+ try:
842
+ h = hypot(x, y)
843
+ if h:
844
+ x, y = (x / h), (y / h)
845
+ else:
846
+ x = _copysign_0_0(x) # pass?
847
+ y = _copysign_0_0(y)
848
+ except Exception as e:
849
+ raise _xError(e, x=x, y=y, h=h)
851
850
  return x, y
852
851
 
853
852
 
@@ -861,16 +860,13 @@ def norm_(*xs):
861
860
  @raise ValueError: Invalid or insufficent B{C{xs}}
862
861
  or zero norm.
863
862
  '''
864
- h = hypot_(*xs)
865
- if h:
866
- try:
867
- for i, x in enumerate(xs):
868
- yield x / h
869
- except Exception as e:
870
- raise _xError(e, Fmt.SQUARE(xs=i), x, _h_, h)
871
- else:
872
- for _ in xs:
873
- yield _0_0
863
+ try:
864
+ h = hypot_(*xs)
865
+ _h = (_1_0 / h) if h else _0_0
866
+ for i, x in enumerate(xs):
867
+ yield x * _h
868
+ except Exception as e:
869
+ raise _xError(e, Fmt.SQUARE(xs=i), x, _h_, h)
874
870
 
875
871
 
876
872
  def _powers(x, n):
pygeodesy/frechet.py CHANGED
@@ -89,7 +89,7 @@ import pygeodesy.formy as _formy
89
89
  from pygeodesy.interns import NN, _DOT_, _n_, _units_
90
90
  # from pygeodesy.iters import points2 as _points2 # from .points
91
91
  from pygeodesy.lazily import _ALL_LAZY, _FOR_DOCS
92
- from pygeodesy.named import _Named, _NamedTuple, notOverloaded, _Pass
92
+ from pygeodesy.named import _Named, _NamedTuple, _Pass
93
93
  # from pygeodesy.namedTuples import PhiLam2Tuple # from .points
94
94
  from pygeodesy.points import _distanceTo, _fractional, isscalar, \
95
95
  PhiLam2Tuple, points2 as _points2, radians
@@ -102,7 +102,7 @@ from collections import defaultdict as _defaultdict
102
102
  # from math import radians # from .points
103
103
 
104
104
  __all__ = _ALL_LAZY.frechet
105
- __version__ = '24.03.24'
105
+ __version__ = '24.04.07'
106
106
 
107
107
 
108
108
  def _fraction(fraction, n):
@@ -248,7 +248,7 @@ class Frechet(_Named):
248
248
 
249
249
  def _func(self, *args, **kwds): # PYCHOK no cover
250
250
  '''(INTERNAL) I{Must be overloaded}.'''
251
- notOverloaded(self, *args, **kwds)
251
+ self._notOverloaded(*args, **kwds)
252
252
 
253
253
  @property_RO
254
254
  def kwds(self):
@@ -325,7 +325,7 @@ class FrechetDegrees(Frechet):
325
325
 
326
326
  def distance(self, point1, point2, *args, **kwds): # PYCHOK no cover
327
327
  '''I{Must be overloaded}.'''
328
- notOverloaded(self, point1, point2, *args, **kwds)
328
+ self._notOverloaded(point1, point2, *args, **kwds)
329
329
 
330
330
 
331
331
  class FrechetRadians(Frechet):
@@ -339,7 +339,7 @@ class FrechetRadians(Frechet):
339
339
 
340
340
  def distance(self, point1, point2, *args, **kwds): # PYCHOK no cover
341
341
  '''I{Must be overloaded}.'''
342
- notOverloaded(self, point1, point2, *args, **kwds)
342
+ self._notOverloaded(point1, point2, *args, **kwds)
343
343
 
344
344
  def point(self, point):
345
345
  '''Return B{C{point}} as L{PhiLam2Tuple} to maintain
@@ -373,7 +373,7 @@ class _FrechetMeterRadians(Frechet):
373
373
 
374
374
  def _func_(self, *args, **kwds): # PYCHOK no cover
375
375
  '''(INTERNAL) I{Must be overloaded}.'''
376
- notOverloaded(self, *args, **kwds)
376
+ self._notOverloaded(*args, **kwds)
377
377
 
378
378
 
379
379
  class FrechetCosineAndoyerLambert(_FrechetMeterRadians):
pygeodesy/fstats.py CHANGED
@@ -15,15 +15,14 @@ from pygeodesy.fmath import hypot2, sqrt
15
15
  from pygeodesy.fsums import _2float, Fsum, Fmt
16
16
  from pygeodesy.interns import NN, _iadd_op_, _invalid_, _other_, _SPACE_
17
17
  from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
18
- from pygeodesy.named import _Named, _NotImplemented, notOverloaded, \
19
- property_RO
18
+ from pygeodesy.named import _Named, _NotImplemented, property_RO
20
19
  # from pygeodesy.props import property_RO # from .named
21
20
  # from pygeodesy.streprs import Fmt # from .fsums
22
21
 
23
22
  # from math import sqrt # from .fmath
24
23
 
25
24
  __all__ = _ALL_LAZY.fstats
26
- __version__ = '23.09.22'
25
+ __version__ = '24.04.07'
27
26
 
28
27
  _Floats = Fsum, float
29
28
  _Scalar = _Floats + (int,) # XXX basics._Ints is ABCMeta in Python 2
@@ -114,7 +113,7 @@ class _FstatsBase(_FstatsNamed):
114
113
 
115
114
  def fadd(self, xs, sample=False): # PYCHOK no cover
116
115
  '''I{Must be overloaded}.'''
117
- notOverloaded(self, xs, sample=sample)
116
+ self._notOverloaded(xs, sample=sample)
118
117
 
119
118
  def fadd_(self, *xs, **sample):
120
119
  '''Accumulate and return the current count.