richvalues 4.2.24__tar.gz → 4.2.25__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.24/richvalues.egg-info → richvalues-4.2.25}/PKG-INFO +1 -1
- {richvalues-4.2.24 → richvalues-4.2.25}/pyproject.toml +1 -1
- {richvalues-4.2.24 → richvalues-4.2.25}/richvalues/__init__.py +39 -37
- {richvalues-4.2.24 → richvalues-4.2.25/richvalues.egg-info}/PKG-INFO +1 -1
- {richvalues-4.2.24 → richvalues-4.2.25}/setup.py +1 -1
- {richvalues-4.2.24 → richvalues-4.2.25}/LICENSE +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/README.md +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/richvalues.egg-info/SOURCES.txt +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/richvalues.egg-info/dependency_links.txt +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/richvalues.egg-info/requires.txt +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/richvalues.egg-info/top_level.txt +0 -0
- {richvalues-4.2.24 → richvalues-4.2.25}/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.25"
|
|
8
8
|
description = "Python package for working with uncertainties and upper/lower limits"
|
|
9
9
|
license = {file="LICENSE"}
|
|
10
10
|
authors = [{name="Andrés Megías Toledano"}]
|
|
@@ -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.25'
|
|
41
41
|
__author__ = 'Andrés Megías Toledano'
|
|
42
42
|
|
|
43
43
|
import copy
|
|
@@ -633,7 +633,7 @@ class RichValue():
|
|
|
633
633
|
is_uplim = True
|
|
634
634
|
else:
|
|
635
635
|
main = np.nan
|
|
636
|
-
unc = [np.nan]*2
|
|
636
|
+
unc = [np.nan]*2
|
|
637
637
|
|
|
638
638
|
if np.isnan(main):
|
|
639
639
|
is_uplim, is_lolim, is_range = False, False, False
|
|
@@ -876,7 +876,7 @@ class RichValue():
|
|
|
876
876
|
"""Constant value."""
|
|
877
877
|
isconst = self.is_exact and self.domain[0] == self.domain[1]
|
|
878
878
|
return isconst
|
|
879
|
-
@property
|
|
879
|
+
@property
|
|
880
880
|
def center(self):
|
|
881
881
|
"""Central value."""
|
|
882
882
|
if self.is_centered or self.is_exact:
|
|
@@ -885,7 +885,7 @@ class RichValue():
|
|
|
885
885
|
cent = round(cent)
|
|
886
886
|
else:
|
|
887
887
|
cent = np.nan
|
|
888
|
-
return cent
|
|
888
|
+
return cent
|
|
889
889
|
@property
|
|
890
890
|
def unc_T(self):
|
|
891
891
|
"""Uncertainties with shape (2,1)."""
|
|
@@ -915,7 +915,7 @@ class RichValue():
|
|
|
915
915
|
else:
|
|
916
916
|
s_n = [np.nan]*2
|
|
917
917
|
return s_n
|
|
918
|
-
@property
|
|
918
|
+
@property
|
|
919
919
|
def ampl(self):
|
|
920
920
|
"""Amplitudes."""
|
|
921
921
|
m, b = self.main, self.domain
|
|
@@ -1063,7 +1063,7 @@ class RichValue():
|
|
|
1063
1063
|
m = float(np.median(sample))
|
|
1064
1064
|
else:
|
|
1065
1065
|
m = np.nan
|
|
1066
|
-
return m
|
|
1066
|
+
return m
|
|
1067
1067
|
|
|
1068
1068
|
def mean(self, num_points=int(1e4), sigmas=8.):
|
|
1069
1069
|
"""Mean of the PDF of the rich value."""
|
|
@@ -1445,7 +1445,7 @@ class RichValue():
|
|
|
1445
1445
|
if 'e' in y:
|
|
1446
1446
|
y, a = y.split('e')
|
|
1447
1447
|
if 'e' in dy:
|
|
1448
|
-
dy, a = dy.split('e')
|
|
1448
|
+
dy, a = dy.split('e')
|
|
1449
1449
|
else:
|
|
1450
1450
|
a = 0
|
|
1451
1451
|
else:
|
|
@@ -1479,10 +1479,10 @@ class RichValue():
|
|
|
1479
1479
|
else:
|
|
1480
1480
|
if is_lolim:
|
|
1481
1481
|
symbol = '>'
|
|
1482
|
-
y = int(np.floor(x)) if is_int and a > num_sf else x
|
|
1482
|
+
y = int(np.floor(x)) if is_int and a > num_sf else x
|
|
1483
1483
|
elif is_uplim:
|
|
1484
1484
|
symbol = '<'
|
|
1485
|
-
y = int(np.ceil(x)) if is_int and a > num_sf else x
|
|
1485
|
+
y = int(np.ceil(x)) if is_int and a > num_sf else x
|
|
1486
1486
|
y = round_sf(y, num_sf, min_exp, extra_sf_lim)
|
|
1487
1487
|
if 'e' in y:
|
|
1488
1488
|
y, a = y.split('e')
|
|
@@ -1790,7 +1790,7 @@ class RichValue():
|
|
|
1790
1790
|
if domain[0] > 0. and other_.sign() != -1:
|
|
1791
1791
|
domain[0] = 0.
|
|
1792
1792
|
if domain[1] < 0. and other_.sign() != 1:
|
|
1793
|
-
domain[1] = 0.
|
|
1793
|
+
domain[1] = 0.
|
|
1794
1794
|
rvalue = function_with_rich_values('{}%{}', [self, other_],
|
|
1795
1795
|
domain=domain, is_domain_cyclic=True)
|
|
1796
1796
|
return rvalue
|
|
@@ -1839,11 +1839,13 @@ class RichValue():
|
|
|
1839
1839
|
domain=domain, is_int=is_int)
|
|
1840
1840
|
else:
|
|
1841
1841
|
other_ = other if type(other) is RichValue else RichValue(other)
|
|
1842
|
+
domain = None
|
|
1842
1843
|
if self.main != 0.:
|
|
1843
1844
|
if type(other) is not RichValue and other%2 == 0.:
|
|
1844
1845
|
domain = [0., np.inf]
|
|
1845
|
-
|
|
1846
|
-
|
|
1846
|
+
with np.errstate(over='ignore', invalid='ignore'):
|
|
1847
|
+
rvalue = function_with_rich_values(lambda a,b: a**b,
|
|
1848
|
+
[self, other_], domain=domain)
|
|
1847
1849
|
else:
|
|
1848
1850
|
rvalue = RichValue(0., domain=domain, is_int=self.is_int)
|
|
1849
1851
|
rvalue.num_sf = self.num_sf
|
|
@@ -2202,17 +2204,17 @@ class RichArray(np.ndarray):
|
|
|
2202
2204
|
return np.array([x.main for x in self.flat]).reshape(self.shape)
|
|
2203
2205
|
@property
|
|
2204
2206
|
def uncs(self):
|
|
2205
|
-
return np.array([x.unc for x in self.flat]).reshape([*self.shape,2])
|
|
2207
|
+
return np.array([x.unc for x in self.flat]).reshape([*self.shape,2])
|
|
2206
2208
|
@property
|
|
2207
2209
|
def are_lolims(self):
|
|
2208
2210
|
return np.array([x.is_lolim for x in self.flat]).reshape(self.shape)
|
|
2209
2211
|
@property
|
|
2210
2212
|
def are_uplims(self):
|
|
2211
|
-
return np.array([x.is_uplim for x in self.flat]).reshape(self.shape)
|
|
2213
|
+
return np.array([x.is_uplim for x in self.flat]).reshape(self.shape)
|
|
2212
2214
|
@property
|
|
2213
2215
|
def are_ranges(self):
|
|
2214
2216
|
return np.array([x.is_range for x in self.flat]).reshape(self.shape)
|
|
2215
|
-
@property
|
|
2217
|
+
@property
|
|
2216
2218
|
def domains(self):
|
|
2217
2219
|
return np.array([x.domain for x in self.flat]).reshape([*self.shape,2])
|
|
2218
2220
|
@property
|
|
@@ -2253,7 +2255,7 @@ class RichArray(np.ndarray):
|
|
|
2253
2255
|
return np.array([x.is_inf for x in self.flat]).reshape(self.shape)
|
|
2254
2256
|
@property
|
|
2255
2257
|
def centers(self):
|
|
2256
|
-
return np.array([x.center for x in self.flat]).reshape(self.shape)
|
|
2258
|
+
return np.array([x.center for x in self.flat]).reshape(self.shape)
|
|
2257
2259
|
@property
|
|
2258
2260
|
def rel_uncs(self):
|
|
2259
2261
|
return (np.array([x.rel_unc for x in self.flat])
|
|
@@ -2321,27 +2323,27 @@ class RichArray(np.ndarray):
|
|
|
2321
2323
|
|
|
2322
2324
|
def medians(self, num_points=None):
|
|
2323
2325
|
return np.array([x.median(num_points)
|
|
2324
|
-
for x in self.flat]).reshape(self.shape)
|
|
2326
|
+
for x in self.flat]).reshape(self.shape)
|
|
2325
2327
|
|
|
2326
2328
|
def means(self, num_points=int(1e4), sigmas=8.):
|
|
2327
2329
|
return np.array([x.mean(num_points, sigmas)
|
|
2328
|
-
for x in self.flat]).reshape(self.shape)
|
|
2330
|
+
for x in self.flat]).reshape(self.shape)
|
|
2329
2331
|
|
|
2330
2332
|
def modes(self, num_points=int(1e4), sigmas=8.):
|
|
2331
2333
|
return np.array([x.mode(num_points, sigmas)
|
|
2332
|
-
for x in self.flat]).reshape(self.shape)
|
|
2334
|
+
for x in self.flat]).reshape(self.shape)
|
|
2333
2335
|
|
|
2334
2336
|
def variances(self, num_points=int(1e4), sigmas=8.):
|
|
2335
2337
|
return np.array([x.var(num_points, sigmas)
|
|
2336
|
-
for x in self.flat]).reshape(self.shape)
|
|
2338
|
+
for x in self.flat]).reshape(self.shape)
|
|
2337
2339
|
|
|
2338
2340
|
def stds(self, num_points=int(1e4), sigmas=8.):
|
|
2339
2341
|
return np.array([x.std(num_points, sigmas)
|
|
2340
|
-
for x in self.flat]).reshape(self.shape)
|
|
2342
|
+
for x in self.flat]).reshape(self.shape)
|
|
2341
2343
|
|
|
2342
2344
|
def moments(self, n, central=True, standarized=False):
|
|
2343
2345
|
return np.array([x.moments(n, central, standarized)
|
|
2344
|
-
for x in self.flat]).reshape(self.shape)
|
|
2346
|
+
for x in self.flat]).reshape(self.shape)
|
|
2345
2347
|
|
|
2346
2348
|
def set_params(self, params):
|
|
2347
2349
|
"""Set the rich value parameters of each entry of the rich array."""
|
|
@@ -2350,7 +2352,7 @@ class RichArray(np.ndarray):
|
|
|
2350
2352
|
'minimum exponent for scientific notation': 'min_exp',
|
|
2351
2353
|
'maximum number of decimals to use parenthesis': 'max_dec',
|
|
2352
2354
|
'limit for extra significant figure': 'extra_sf_lim'}
|
|
2353
|
-
attributes = ['domain'] + list(abbreviations.values())
|
|
2355
|
+
attributes = ['domain'] + list(abbreviations.values())
|
|
2354
2356
|
for entry in abbreviations:
|
|
2355
2357
|
name = abbreviations[entry]
|
|
2356
2358
|
if entry in params:
|
|
@@ -2480,7 +2482,7 @@ class RichDataFrame(pd.DataFrame):
|
|
|
2480
2482
|
df = pd.DataFrame(data, self.index, self.columns)
|
|
2481
2483
|
return df
|
|
2482
2484
|
|
|
2483
|
-
@property
|
|
2485
|
+
@property
|
|
2484
2486
|
def mains(self): return self._property('mains')
|
|
2485
2487
|
@property
|
|
2486
2488
|
def uncs(self): return self._property2('uncs')
|
|
@@ -2982,14 +2984,14 @@ class ComplexRichValue():
|
|
|
2982
2984
|
self.imag.num_sf = x
|
|
2983
2985
|
|
|
2984
2986
|
@property
|
|
2985
|
-
def min_exp(self): return round(np.mean([self.real.min_exp, self.imag.min_exp]))
|
|
2987
|
+
def min_exp(self): return round(np.mean([self.real.min_exp, self.imag.min_exp]))
|
|
2986
2988
|
@min_exp.setter
|
|
2987
2989
|
def min_exp(self, x):
|
|
2988
2990
|
self.real.min_exp = x
|
|
2989
2991
|
self.imag.min_exp = x
|
|
2990
2992
|
|
|
2991
2993
|
@property
|
|
2992
|
-
def max_dec(self): return min(self.real.max_dec, self.imag.max_dec)
|
|
2994
|
+
def max_dec(self): return min(self.real.max_dec, self.imag.max_dec)
|
|
2993
2995
|
@max_dec.setter
|
|
2994
2996
|
def max_dec(self, x):
|
|
2995
2997
|
self.real.max_dec = x
|
|
@@ -3029,7 +3031,7 @@ class ComplexRichValue():
|
|
|
3029
3031
|
def main(self):
|
|
3030
3032
|
"""Main value."""
|
|
3031
3033
|
x = self.real.main + 1j*self.imag.main
|
|
3032
|
-
return x
|
|
3034
|
+
return x
|
|
3033
3035
|
|
|
3034
3036
|
@property
|
|
3035
3037
|
def unc(self):
|
|
@@ -3247,7 +3249,7 @@ class ComplexRichValue():
|
|
|
3247
3249
|
"""Apply a function to the rich value."""
|
|
3248
3250
|
return function_with_rich_values(function, self, **kwargs)
|
|
3249
3251
|
|
|
3250
|
-
# Instance variable acronyms.
|
|
3252
|
+
# Instance variable acronyms.
|
|
3251
3253
|
|
|
3252
3254
|
@property
|
|
3253
3255
|
def real_part(self): return self.real
|
|
@@ -3556,7 +3558,7 @@ def parse_as_rich_value(text, abbreviations={}, use_default_extra_sf_lim=False):
|
|
|
3556
3558
|
domain = read_domain(text, abbreviations)
|
|
3557
3559
|
if domain is not None:
|
|
3558
3560
|
text = text.split('[')[0][:-1]
|
|
3559
|
-
if not '--' in text:
|
|
3561
|
+
if not '--' in text:
|
|
3560
3562
|
if text.startswith('+'):
|
|
3561
3563
|
text = text[1:]
|
|
3562
3564
|
if ' e' in text:
|
|
@@ -3674,11 +3676,11 @@ def parse_as_rich_value(text, abbreviations={}, use_default_extra_sf_lim=False):
|
|
|
3674
3676
|
if mantissa <= default_extra_sf_lim:
|
|
3675
3677
|
default_num_sf = defaultparams['number of significant figures']
|
|
3676
3678
|
if num_sf < default_num_sf + 1:
|
|
3677
|
-
extra_sf_lim = mantissa
|
|
3679
|
+
extra_sf_lim = mantissa
|
|
3678
3680
|
x = x.replace('e0','')
|
|
3679
3681
|
main = _eval(x)
|
|
3680
3682
|
unc = [_eval(dx1), _eval(dx2)]
|
|
3681
|
-
is_range = False
|
|
3683
|
+
is_range = False
|
|
3682
3684
|
else:
|
|
3683
3685
|
text = text.replace(' --','--').replace('-- ','--')
|
|
3684
3686
|
text1, text2 = text.split('--')
|
|
@@ -3789,7 +3791,7 @@ def rich_value(text=None, domain=None, is_int=None, pdf=None, support=None,
|
|
|
3789
3791
|
imag = rich_value(text_imag, *args)
|
|
3790
3792
|
else:
|
|
3791
3793
|
text = text.replace(' + ', '+').replace(' - ', '-')
|
|
3792
|
-
val = complex(text)
|
|
3794
|
+
val = complex(text)
|
|
3793
3795
|
real = val.real
|
|
3794
3796
|
imag = val.imag
|
|
3795
3797
|
rvalue = ComplexRichValue(real, imag, domain, is_int)
|
|
@@ -4683,7 +4685,7 @@ def add_zero_infs(interval, zero_log, inf_log):
|
|
|
4683
4685
|
elif x2 > 0 and x2 > 10**inf_log:
|
|
4684
4686
|
x2 = np.inf
|
|
4685
4687
|
new_interval = [x1, x2]
|
|
4686
|
-
return new_interval
|
|
4688
|
+
return new_interval
|
|
4687
4689
|
|
|
4688
4690
|
def remove_zero_infs(interval, zero_log, inf_log):
|
|
4689
4691
|
"""Replace 0 and infinity for the given values in the input interval."""
|
|
@@ -5761,7 +5763,7 @@ def curve_fit(x, y, function, guess, num_samples=3000,
|
|
|
5761
5763
|
lim1, lim2 = 0.2, 1.2
|
|
5762
5764
|
if disp_coef <= lim1:
|
|
5763
5765
|
frac1 = 1.
|
|
5764
|
-
elif disp_coef < lim2:
|
|
5766
|
+
elif disp_coef < lim2:
|
|
5765
5767
|
frac1 = 1. - disp_coef / (lim2 - lim1)
|
|
5766
5768
|
else:
|
|
5767
5769
|
frac1 = 0.
|
|
@@ -5774,7 +5776,7 @@ def curve_fit(x, y, function, guess, num_samples=3000,
|
|
|
5774
5776
|
result = {'parameters': params_fit, 'dispersion': dispersion, 'loss': loss,
|
|
5775
5777
|
'parameters samples': samples, 'dispersion sample': dispersions,
|
|
5776
5778
|
'loss sample': losses, 'number of fails': num_fails}
|
|
5777
|
-
return result
|
|
5779
|
+
return result
|
|
5778
5780
|
|
|
5779
5781
|
def point_fit(y, function, guess, num_samples=3000,
|
|
5780
5782
|
loss=lambda a,b: (a-b)**2, lim_loss_factor=4.,
|
|
@@ -5850,7 +5852,7 @@ def point_fit(y, function, guess, num_samples=3000,
|
|
|
5850
5852
|
lim1, lim2 = 0.2, 1.2
|
|
5851
5853
|
if disp_coef <= lim1:
|
|
5852
5854
|
frac1 = 1.
|
|
5853
|
-
elif disp_coef < lim2:
|
|
5855
|
+
elif disp_coef < lim2:
|
|
5854
5856
|
frac1 = 1. - disp_coef / (lim2 - lim1)
|
|
5855
5857
|
else:
|
|
5856
5858
|
frac1 = 0.
|
|
@@ -6068,4 +6070,4 @@ array_distr_sample = array_distribution_sample = distr_sample_with_rich_arrays
|
|
|
6068
6070
|
center_and_uncertainties = center_and_uncs
|
|
6069
6071
|
is_not_a_number = is_nan = isnan
|
|
6070
6072
|
is_infinite = is_inf = isinf
|
|
6071
|
-
is_finite = is_finite = isfinite
|
|
6073
|
+
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.25',
|
|
9
9
|
license = 'BSD-3-Clause',
|
|
10
10
|
author = 'Andrés Megías Toledano',
|
|
11
11
|
description = 'Python package 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
|