richvalues 4.2.1__tar.gz → 4.2.2__tar.gz
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.
- {richvalues-4.2.1 → richvalues-4.2.2}/PKG-INFO +1 -1
- {richvalues-4.2.1 → richvalues-4.2.2}/pyproject.toml +1 -1
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues/__init__.py +91 -84
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues.egg-info/PKG-INFO +1 -1
- {richvalues-4.2.1 → richvalues-4.2.2}/setup.py +1 -1
- {richvalues-4.2.1 → richvalues-4.2.2}/LICENSE +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/README.md +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues.egg-info/SOURCES.txt +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues.egg-info/dependency_links.txt +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues.egg-info/requires.txt +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/richvalues.egg-info/top_level.txt +0 -0
- {richvalues-4.2.1 → richvalues-4.2.2}/setup.cfg +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "richvalues"
|
7
|
-
version = "4.2.
|
7
|
+
version = "4.2.2"
|
8
8
|
description = "Python library for working with uncertainties and upper/lower limits"
|
9
9
|
license = {file="LICENSE"}
|
10
10
|
authors = [{name="Andrés Megías Toledano"}]
|
@@ -13,12 +13,12 @@ modification, are permitted provided that the following conditions are
|
|
13
13
|
met:
|
14
14
|
|
15
15
|
(1) Redistributions of source code must retain the above copyright
|
16
|
-
notice, this list of conditions and the following disclaimer.
|
16
|
+
notice, this list of conditions and the following disclaimer.
|
17
17
|
|
18
18
|
(2) Redistributions in binary form must reproduce the above copyright
|
19
19
|
notice, this list of conditions and the following disclaimer in
|
20
20
|
the documentation and/or other materials provided with the
|
21
|
-
distribution.
|
21
|
+
distribution.
|
22
22
|
|
23
23
|
(3) The name of the author may not be used to endorse or promote
|
24
24
|
products derived from this software without specific prior written
|
@@ -37,7 +37,7 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
37
37
|
POSSIBILITY OF SUCH DAMAGE.
|
38
38
|
"""
|
39
39
|
|
40
|
-
__version__ = '4.2.
|
40
|
+
__version__ = '4.2.2'
|
41
41
|
__author__ = 'Andrés Megías Toledano'
|
42
42
|
|
43
43
|
import copy
|
@@ -275,7 +275,8 @@ def round_sf_unc(x, dx, n=None, min_exp=None, max_dec=None, extra_sf_lim=None):
|
|
275
275
|
y = '{}e{}'.format(base_y, exp_dy)
|
276
276
|
else:
|
277
277
|
f = 10**(-int(exp_y))
|
278
|
-
base_y, base_dy = round_sf_unc(x*f, dx*f, n,
|
278
|
+
base_y, base_dy = round_sf_unc(x*f, dx*f, n,
|
279
|
+
np.inf, max_dec, extra_sf_lim)
|
279
280
|
y = '{}e{}'.format(base_y, exp_y)
|
280
281
|
dy = '{}e{}'.format(base_dy, exp_y)
|
281
282
|
if len(dy) > len(y)+1:
|
@@ -311,7 +312,8 @@ def round_sf_unc(x, dx, n=None, min_exp=None, max_dec=None, extra_sf_lim=None):
|
|
311
312
|
else:
|
312
313
|
exp = None
|
313
314
|
d = len(y.split('.')[-1])
|
314
|
-
|
315
|
+
d_ = len(dy.split('.')[-1])
|
316
|
+
dy_ = round_sf(float(dy)*10**(d-d_), n, 0, extra_sf_lim)
|
315
317
|
dy = '(' + dy_.split('e')[0] + ')'
|
316
318
|
if exp is not None:
|
317
319
|
y = '{}e{}'.format(y, exp)
|
@@ -354,45 +356,48 @@ def round_sf_uncs(x, dx, n=None, min_exp=None, max_dec=None, extra_sf_lim=None):
|
|
354
356
|
dx1, dx2 = dx
|
355
357
|
y1, dy1 = round_sf_unc(x, dx1, n, min_exp, max_dec, extra_sf_lim)
|
356
358
|
y2, dy2 = round_sf_unc(x, dx2, n, min_exp, max_dec, extra_sf_lim)
|
357
|
-
if
|
358
|
-
|
359
|
-
y1, dy1 = round_sf_unc(x, dx1, n, min_exp, max_dec, extra_sf_lim)
|
360
|
-
y2, dy2 = round_sf_unc(x, dx2, n, min_exp, max_dec, extra_sf_lim)
|
361
|
-
num_dec_1 = len(y1.split('e')[0].split('.')[1]) if '.' in y1 else 0
|
362
|
-
num_dec_2 = len(y2.split('e')[0].split('.')[1]) if '.' in y2 else 0
|
363
|
-
if num_dec_2 > num_dec_1:
|
364
|
-
diff = num_dec_2 - num_dec_1
|
365
|
-
y1, dy1 = round_sf_unc(x, dx1, n+diff, min_exp, max_dec, extra_sf_lim)
|
366
|
-
y2, dy2 = round_sf_unc(x, dx2, n, min_exp, max_dec, extra_sf_lim)
|
359
|
+
if y1 == y2 and dy1 == dy2:
|
360
|
+
y = y1
|
367
361
|
else:
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
if
|
393
|
-
|
394
|
-
|
395
|
-
dy2 = '(
|
362
|
+
if 'e' in y1 and 'e' not in y2 or 'e' in y2 and 'e' not in y1:
|
363
|
+
min_exp = 0
|
364
|
+
y1, dy1 = round_sf_unc(x, dx1, n, min_exp, max_dec, extra_sf_lim)
|
365
|
+
y2, dy2 = round_sf_unc(x, dx2, n, min_exp, max_dec, extra_sf_lim)
|
366
|
+
num_dec_1 = len(y1.split('e')[0].split('.')[1]) if '.' in y1 else 0
|
367
|
+
num_dec_2 = len(y2.split('e')[0].split('.')[1]) if '.' in y2 else 0
|
368
|
+
if num_dec_2 > num_dec_1:
|
369
|
+
diff = num_dec_2 - num_dec_1
|
370
|
+
y1, dy1 = round_sf_unc(x, dx1, n+diff, min_exp, max_dec, extra_sf_lim)
|
371
|
+
y2, dy2 = round_sf_unc(x, dx2, n, min_exp, max_dec, extra_sf_lim)
|
372
|
+
else:
|
373
|
+
diff = num_dec_1 - num_dec_2
|
374
|
+
off1, off2 = 0, 0
|
375
|
+
if num_dec_1 == 0 == num_dec_2:
|
376
|
+
base_dy1 = '{:e}'.format(dx1).split('e')[0]
|
377
|
+
base_dy2 = '{:e}'.format(dx2).split('e')[0]
|
378
|
+
b1 = float(base_dy1) if np.isfinite(dx1) else 10.
|
379
|
+
b2 = float(base_dy2) if np.isfinite(dx2) else 10.
|
380
|
+
if dx2 > dx1 and b1 <= extra_sf_lim and b2 > extra_sf_lim:
|
381
|
+
off2 = 1
|
382
|
+
if dx1 > dx2 and b2 <= extra_sf_lim and b1 > extra_sf_lim:
|
383
|
+
off1 = 1
|
384
|
+
y1, dy1 = round_sf_unc(x, dx1, n+off1, min_exp, max_dec, extra_sf_lim)
|
385
|
+
y2, dy2 = round_sf_unc(x, dx2, n+diff+off2, min_exp, max_dec, extra_sf_lim)
|
386
|
+
y = y1 if dx2 > dx1 else y2
|
387
|
+
if dy1 != dy2 and (')' in dy1 or ')' in dy2):
|
388
|
+
dy1 = dy1.replace('(', '(-')
|
389
|
+
dy2 = dy2.replace('(', '(+')
|
390
|
+
if ')' in dy1 and ')' not in dy2 or ')' in dy2 and '.' in dy2:
|
391
|
+
_, dy2 = round_sf_unc(x, dx[1], n, min_exp, max_dec-1, extra_sf_lim)
|
392
|
+
dy2 = '(' + dy2[1:-1] + '0' + ')'
|
393
|
+
elif ')' in dy2 and ')' not in dy1 or ')' in dy1 and '.' in dy1:
|
394
|
+
_, dy1 = round_sf_unc(x, dx[0], n, min_exp, max_dec-1, extra_sf_lim)
|
395
|
+
dy1 = '(' + dy1[1:-1] + '0' + ')'
|
396
|
+
if ')' in dy1 or ')' in dy2:
|
397
|
+
if not dy1.startswith('(-'):
|
398
|
+
dy1 = '(-' + dy1[1:]
|
399
|
+
if not dy2.startswith('(+'):
|
400
|
+
dy2 = '(+' + dy2[1:]
|
396
401
|
dy = [dy1, dy2]
|
397
402
|
return y, dy
|
398
403
|
|
@@ -627,11 +632,11 @@ class RichValue():
|
|
627
632
|
"""Constant value."""
|
628
633
|
isconst = self.is_exact and self.domain[0] == self.domain[1]
|
629
634
|
return isconst
|
630
|
-
@property
|
635
|
+
@property
|
631
636
|
def center(self):
|
632
637
|
"""Central value."""
|
633
638
|
cent = self.main if self.is_centr else np.nan
|
634
|
-
return cent
|
639
|
+
return cent
|
635
640
|
@property
|
636
641
|
def unc_eb(self):
|
637
642
|
"""Uncertainties with shape (2,1)."""
|
@@ -658,7 +663,7 @@ class RichValue():
|
|
658
663
|
else:
|
659
664
|
s_n = [np.nan]*2
|
660
665
|
return s_n
|
661
|
-
@property
|
666
|
+
@property
|
662
667
|
def ampl(self):
|
663
668
|
"""Amplitudes."""
|
664
669
|
m, b = self.main, self.domain
|
@@ -779,7 +784,7 @@ class RichValue():
|
|
779
784
|
m = np.nanmedian(distr)
|
780
785
|
else:
|
781
786
|
m = np.nan
|
782
|
-
return m
|
787
|
+
return m
|
783
788
|
|
784
789
|
def mean(self, num_points=int(1e4), sigmas=8.):
|
785
790
|
"""Mean of the PDF of the rich value."""
|
@@ -835,7 +840,7 @@ class RichValue():
|
|
835
840
|
y = self.pdf(x)
|
836
841
|
c = np.trapz(y*x, x) if central or standarized else 0.
|
837
842
|
s = np.sqrt(np.trapz(y*(x-c)**2)) if standarized else 1.
|
838
|
-
moment = np.trapz((y*(x-c)**n)) / s**n
|
843
|
+
moment = np.trapz((y*(x-c)**n)) / s**n
|
839
844
|
else:
|
840
845
|
moment = np.nan
|
841
846
|
return moment
|
@@ -1089,7 +1094,7 @@ class RichValue():
|
|
1089
1094
|
else:
|
1090
1095
|
if is_lolim:
|
1091
1096
|
symbol = '>'
|
1092
|
-
y = int(np.floor(x)) if is_int else x
|
1097
|
+
y = int(np.floor(x)) if is_int else x
|
1093
1098
|
elif is_uplim:
|
1094
1099
|
symbol = '<'
|
1095
1100
|
y = int(np.ceil(x)) if is_int else x
|
@@ -1139,10 +1144,10 @@ class RichValue():
|
|
1139
1144
|
else:
|
1140
1145
|
if is_lolim:
|
1141
1146
|
symbol = '>'
|
1142
|
-
y = int(np.floor(x)) if is_int else x
|
1147
|
+
y = int(np.floor(x)) if is_int else x
|
1143
1148
|
elif is_uplim:
|
1144
1149
|
symbol = '<'
|
1145
|
-
y = int(np.ceil(x)) if is_int else x
|
1150
|
+
y = int(np.ceil(x)) if is_int else x
|
1146
1151
|
y = round_sf(y, n, min_exp, extra_sf_lim)
|
1147
1152
|
if 'e' in y:
|
1148
1153
|
y, a = y.split('e')
|
@@ -1426,7 +1431,7 @@ class RichValue():
|
|
1426
1431
|
if domain[0] > 0 and other_.sign() != -1:
|
1427
1432
|
domain[0] = 0
|
1428
1433
|
if domain[1] < 0 and other_.sign() != 1:
|
1429
|
-
domain[1] = 0
|
1434
|
+
domain[1] = 0
|
1430
1435
|
rvalue = function_with_rich_values('{}%{}', [self, other_],
|
1431
1436
|
domain=domain, is_domain_cyclic=True)
|
1432
1437
|
return rvalue
|
@@ -1541,7 +1546,7 @@ class RichValue():
|
|
1541
1546
|
x = [x]
|
1542
1547
|
x = np.array(x)
|
1543
1548
|
y = np.zeros(len(x))
|
1544
|
-
if self.is_exact:
|
1549
|
+
if self.is_exact:
|
1545
1550
|
ind = np.argmin(abs(x - main))
|
1546
1551
|
if hasattr(ind, '__iter__'):
|
1547
1552
|
ind = ind[0]
|
@@ -1602,7 +1607,7 @@ class RichValue():
|
|
1602
1607
|
if not self.is_lim:
|
1603
1608
|
distr = general_distribution(main, unc, domain, N)
|
1604
1609
|
else:
|
1605
|
-
x1, x2 = self.interval()
|
1610
|
+
x1, x2 = self.interval()
|
1606
1611
|
distr = loguniform_distribution(x1, x2, N)
|
1607
1612
|
elif not is_finite_interv and all(np.isinf(unc)):
|
1608
1613
|
distr = loguniform_distribution(-np.inf, np.inf, N)
|
@@ -1852,17 +1857,17 @@ class RichArray(np.ndarray):
|
|
1852
1857
|
return np.array([x.main for x in self.flat]).reshape(self.shape)
|
1853
1858
|
@property
|
1854
1859
|
def uncs(self):
|
1855
|
-
return np.array([x.unc for x in self.flat]).reshape([*self.shape,2])
|
1860
|
+
return np.array([x.unc for x in self.flat]).reshape([*self.shape,2])
|
1856
1861
|
@property
|
1857
1862
|
def are_lolims(self):
|
1858
1863
|
return np.array([x.is_lolim for x in self.flat]).reshape(self.shape)
|
1859
1864
|
@property
|
1860
1865
|
def are_uplims(self):
|
1861
|
-
return np.array([x.is_uplim for x in self.flat]).reshape(self.shape)
|
1866
|
+
return np.array([x.is_uplim for x in self.flat]).reshape(self.shape)
|
1862
1867
|
@property
|
1863
1868
|
def are_ranges(self):
|
1864
1869
|
return np.array([x.is_range for x in self.flat]).reshape(self.shape)
|
1865
|
-
@property
|
1870
|
+
@property
|
1866
1871
|
def domains(self):
|
1867
1872
|
return np.array([x.domain for x in self.flat]).reshape([*self.shape,2])
|
1868
1873
|
@property
|
@@ -1903,7 +1908,7 @@ class RichArray(np.ndarray):
|
|
1903
1908
|
return np.array([x.is_inf for x in self.flat]).reshape(self.shape)
|
1904
1909
|
@property
|
1905
1910
|
def centers(self):
|
1906
|
-
return np.array([x.center for x in self.flat]).reshape(self.shape)
|
1911
|
+
return np.array([x.center for x in self.flat]).reshape(self.shape)
|
1907
1912
|
@property
|
1908
1913
|
def rel_uncs(self):
|
1909
1914
|
return (np.array([x.rel_unc for x in self.flat])
|
@@ -1977,27 +1982,27 @@ class RichArray(np.ndarray):
|
|
1977
1982
|
|
1978
1983
|
def medians(self, num_points=None):
|
1979
1984
|
return np.array([x.median(num_points)
|
1980
|
-
for x in self.flat]).reshape(self.shape)
|
1985
|
+
for x in self.flat]).reshape(self.shape)
|
1981
1986
|
|
1982
1987
|
def means(self, num_points=int(1e4), sigmas=8.):
|
1983
1988
|
return np.array([x.mean(num_points, sigmas)
|
1984
|
-
for x in self.flat]).reshape(self.shape)
|
1989
|
+
for x in self.flat]).reshape(self.shape)
|
1985
1990
|
|
1986
1991
|
def modes(self, num_points=int(1e4), sigmas=8.):
|
1987
1992
|
return np.array([x.mode(num_points, sigmas)
|
1988
|
-
for x in self.flat]).reshape(self.shape)
|
1993
|
+
for x in self.flat]).reshape(self.shape)
|
1989
1994
|
|
1990
1995
|
def variances(self, num_points=int(1e4), sigmas=8.):
|
1991
1996
|
return np.array([x.var(num_points, sigmas)
|
1992
|
-
for x in self.flat]).reshape(self.shape)
|
1997
|
+
for x in self.flat]).reshape(self.shape)
|
1993
1998
|
|
1994
1999
|
def stds(self, num_points=int(1e4), sigmas=8.):
|
1995
2000
|
return np.array([x.std(num_points, sigmas)
|
1996
|
-
for x in self.flat]).reshape(self.shape)
|
2001
|
+
for x in self.flat]).reshape(self.shape)
|
1997
2002
|
|
1998
2003
|
def moments(self, n, central=True, standarized=False):
|
1999
2004
|
return np.array([x.moments(n, central, standarized)
|
2000
|
-
for x in self.flat]).reshape(self.shape)
|
2005
|
+
for x in self.flat]).reshape(self.shape)
|
2001
2006
|
|
2002
2007
|
def set_params(self, params):
|
2003
2008
|
"""Set the rich value parameters of each entry of the rich array."""
|
@@ -2006,7 +2011,7 @@ class RichArray(np.ndarray):
|
|
2006
2011
|
'minimum exponent for scientific notation': 'min_exp',
|
2007
2012
|
'maximum number of decimals': 'max_dec',
|
2008
2013
|
'limit for extra significant figure': 'extra_sf_lim'}
|
2009
|
-
attributes = ['domain'] + list(abbreviations.values())
|
2014
|
+
attributes = ['domain'] + list(abbreviations.values())
|
2010
2015
|
for entry in abbreviations:
|
2011
2016
|
name = abbreviations[entry]
|
2012
2017
|
if entry in params:
|
@@ -2158,7 +2163,7 @@ class RichDataFrame(pd.DataFrame):
|
|
2158
2163
|
exec(code, {**{'self': self}, **globals()}, output)
|
2159
2164
|
return output['df']
|
2160
2165
|
|
2161
|
-
@property
|
2166
|
+
@property
|
2162
2167
|
def mains(self): return self._property('mains')
|
2163
2168
|
@property
|
2164
2169
|
def uncs(self): return self._property2('uncs')
|
@@ -2590,7 +2595,7 @@ class ComplexRichValue():
|
|
2590
2595
|
Parameters
|
2591
2596
|
----------
|
2592
2597
|
real : rich value
|
2593
|
-
Real part of the complex rich value.
|
2598
|
+
Real part of the complex rich value.
|
2594
2599
|
imag : rich value
|
2595
2600
|
Imaginary part of the complex rich value
|
2596
2601
|
"""
|
@@ -2671,14 +2676,14 @@ class ComplexRichValue():
|
|
2671
2676
|
self.imag.num_sf = x
|
2672
2677
|
|
2673
2678
|
@property
|
2674
|
-
def min_exp(self): return round(np.mean([self.real.min_exp, self.imag.min_exp]))
|
2679
|
+
def min_exp(self): return round(np.mean([self.real.min_exp, self.imag.min_exp]))
|
2675
2680
|
@min_exp.setter
|
2676
2681
|
def min_exp(self, x):
|
2677
2682
|
self.real.min_exp = x
|
2678
2683
|
self.imag.min_exp = x
|
2679
2684
|
|
2680
2685
|
@property
|
2681
|
-
def max_dec(self): return min(self.real.max_dec, self.imag.max_dec)
|
2686
|
+
def max_dec(self): return min(self.real.max_dec, self.imag.max_dec)
|
2682
2687
|
@max_dec.setter
|
2683
2688
|
def max_dec(self, x):
|
2684
2689
|
self.real.max_dec = x
|
@@ -2718,7 +2723,7 @@ class ComplexRichValue():
|
|
2718
2723
|
def main(self):
|
2719
2724
|
"""Main value."""
|
2720
2725
|
x = self.real.main + 1j*self.imag.main
|
2721
|
-
return x
|
2726
|
+
return x
|
2722
2727
|
|
2723
2728
|
@property
|
2724
2729
|
def unc(self):
|
@@ -2938,7 +2943,7 @@ class ComplexRichValue():
|
|
2938
2943
|
"""Apply a function to the rich value"""
|
2939
2944
|
return function_with_rich_values(function, self, **kwargs)
|
2940
2945
|
|
2941
|
-
# Instance variable acronyms.
|
2946
|
+
# Instance variable acronyms.
|
2942
2947
|
|
2943
2948
|
@property
|
2944
2949
|
def real_part(self): return self.real
|
@@ -3282,7 +3287,7 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None,
|
|
3282
3287
|
domain = read_domain(text)
|
3283
3288
|
if domain is not None:
|
3284
3289
|
text = text.split('[')[0][:-1]
|
3285
|
-
if not '--' in text:
|
3290
|
+
if not '--' in text:
|
3286
3291
|
if text.startswith('+'):
|
3287
3292
|
text = text[1:]
|
3288
3293
|
if 'e' in text:
|
@@ -3334,8 +3339,10 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None,
|
|
3334
3339
|
dx1 = dx1[1:]
|
3335
3340
|
dx2 = dx2[1:]
|
3336
3341
|
d = len(x.split('.')[1]) if '.' in x else 0
|
3337
|
-
|
3338
|
-
|
3342
|
+
d1 = len(dx1.split('.')[1]) if '.' in dx1 else 0
|
3343
|
+
d2 = len(dx1.split('.')[1]) if '.' in dx2 else 0
|
3344
|
+
dx1 = '{:f}'.format(float(dx1)*10**(-(d-d1)))
|
3345
|
+
dx2 = '{:f}'.format(float(dx2)*10**(-(d-d2)))
|
3339
3346
|
elif '+/-' in text:
|
3340
3347
|
x, dx = x_dx.split('+/-')
|
3341
3348
|
text = '{}-{}+{} {}'.format(x, dx, dx, e)
|
@@ -3390,11 +3397,11 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None,
|
|
3390
3397
|
if eval(dx1) == eval(dx2) == 0:
|
3391
3398
|
extra_sf_lim = 1 - 1e-8
|
3392
3399
|
else:
|
3393
|
-
extra_sf_lim = default_extra_sf_lim
|
3400
|
+
extra_sf_lim = default_extra_sf_lim
|
3394
3401
|
base = float('{:e}'.format(eval(val)).split('e')[0])
|
3395
3402
|
if base <= default_extra_sf_lim:
|
3396
3403
|
if num_sf < default_num_sf + 1:
|
3397
|
-
extra_sf_lim = base - 1e-8
|
3404
|
+
extra_sf_lim = base - 1e-8
|
3398
3405
|
else:
|
3399
3406
|
extra_sf_lim = default_extra_sf_lim
|
3400
3407
|
x = x.replace('e0','')
|
@@ -3402,7 +3409,7 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None,
|
|
3402
3409
|
unc = [eval(dx1), eval(dx2)]
|
3403
3410
|
is_range = False
|
3404
3411
|
if domain is None and np.isfinite(main) and unc[0] == 0. == unc[1]:
|
3405
|
-
domain = [main]*2
|
3412
|
+
domain = [main]*2
|
3406
3413
|
else:
|
3407
3414
|
text = text.replace(' --','--').replace('-- ','--')
|
3408
3415
|
text1, text2 = text.split('--')
|
@@ -3449,7 +3456,7 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None,
|
|
3449
3456
|
imag = rich_value(text_imag, *args)
|
3450
3457
|
else:
|
3451
3458
|
text = text.replace(' + ', '+').replace(' - ', '-')
|
3452
|
-
val = complex(text)
|
3459
|
+
val = complex(text)
|
3453
3460
|
real = val.real
|
3454
3461
|
imag = val.imag
|
3455
3462
|
rvalue = ComplexRichValue(real, imag, domain, is_int)
|
@@ -4166,7 +4173,7 @@ def loguniform_distribution(low=-1, high=1, size=1,
|
|
4166
4173
|
log_x2 = _log10(abs(x2))
|
4167
4174
|
if log_x1 < zero_log:
|
4168
4175
|
log_x1 = zero_log
|
4169
|
-
if log_x2 > inf_log:
|
4176
|
+
if log_x2 > inf_log:
|
4170
4177
|
log_x2 = inf_log
|
4171
4178
|
if x1 < 0:
|
4172
4179
|
if x2 <= 0:
|
@@ -4308,7 +4315,7 @@ def add_zero_infs(interval, zero_log, inf_log):
|
|
4308
4315
|
elif x2 > 0 and x2 > 10**inf_log:
|
4309
4316
|
x2 = np.inf
|
4310
4317
|
new_interval = [x1, x2]
|
4311
|
-
return new_interval
|
4318
|
+
return new_interval
|
4312
4319
|
def remove_zero_infs(interval, zero_log, inf_log):
|
4313
4320
|
"""Replace 0 and infinity for the given values in the input interval."""
|
4314
4321
|
x1, x2 = interval
|
@@ -5420,7 +5427,7 @@ def curve_fit(x, y, function, guess, num_samples=3000,
|
|
5420
5427
|
lim1, lim2 = 0.2, 1.2
|
5421
5428
|
if disp_coef <= lim1:
|
5422
5429
|
frac1 = 1.
|
5423
|
-
elif disp_coef < lim2:
|
5430
|
+
elif disp_coef < lim2:
|
5424
5431
|
frac1 = 1. - disp_coef / (lim2 - lim1)
|
5425
5432
|
else:
|
5426
5433
|
frac1 = 0.
|
@@ -5433,7 +5440,7 @@ def curve_fit(x, y, function, guess, num_samples=3000,
|
|
5433
5440
|
result = {'parameters': params_fit, 'dispersion': dispersion, 'loss': loss,
|
5434
5441
|
'parameters samples': samples, 'dispersion sample': dispersions,
|
5435
5442
|
'loss sample': losses, 'number of fails': num_fails}
|
5436
|
-
return result
|
5443
|
+
return result
|
5437
5444
|
|
5438
5445
|
def point_fit(y, function, guess, num_samples=3000,
|
5439
5446
|
loss=lambda a,b: (a-b)**2, lim_loss_factor=4.,
|
@@ -5510,7 +5517,7 @@ def point_fit(y, function, guess, num_samples=3000,
|
|
5510
5517
|
lim1, lim2 = 0.2, 1.2
|
5511
5518
|
if disp_coef <= lim1:
|
5512
5519
|
frac1 = 1.
|
5513
|
-
elif disp_coef < lim2:
|
5520
|
+
elif disp_coef < lim2:
|
5514
5521
|
frac1 = 1. - disp_coef / (lim2 - lim1)
|
5515
5522
|
else:
|
5516
5523
|
frac1 = 0.
|
@@ -5753,4 +5760,4 @@ evaluate_distribution = evaluate_distr
|
|
5753
5760
|
center_and_uncertainties = center_and_uncs
|
5754
5761
|
is_not_a_number = is_nan = isnan
|
5755
5762
|
is_infinite = is_inf = isinf
|
5756
|
-
is_finite = is_finite = isfinite
|
5763
|
+
is_finite = is_finite = isfinite
|
@@ -5,7 +5,7 @@ with open('README.md', 'r') as file:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name = 'richvalues',
|
8
|
-
version = '4.2.
|
8
|
+
version = '4.2.2',
|
9
9
|
license = 'BSD-3-Clause',
|
10
10
|
author = 'Andrés Megías Toledano',
|
11
11
|
description = 'Python library for working with uncertainties and upper/lower limits',
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|