metrolopy 0.6.5__tar.gz → 1.0.0__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.
- {metrolopy-0.6.5 → metrolopy-1.0.0}/PKG-INFO +20 -2
- {metrolopy-0.6.5 → metrolopy-1.0.0}/README.md +18 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/__init__.py +5 -4
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/budget.py +61 -50
- metrolopy-0.6.5/metrolopy/codata2018.py → metrolopy-1.0.0/metrolopy/builtin_constants.py +120 -85
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/constant.py +108 -104
- metrolopy-1.0.0/metrolopy/constcom.py +167 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/distributions.py +120 -39
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/exceptions.py +7 -9
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/fit.py +3 -3
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/functions.py +4 -4
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/gummy.py +554 -514
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/indexed.py +69 -20
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/logunit.py +1 -1
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/mean.py +8 -9
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/miscunits.py +21 -6
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/nummy.py +208 -158
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/offsetunit.py +2 -3
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/prefixedunit.py +24 -23
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/relunits.py +1 -2
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/siunits.py +7 -5
- metrolopy-1.0.0/metrolopy/tests/__init__.py +8 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_create.py +7 -6
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_gummy.py +5 -43
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_misc.py +1 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_operations.py +3 -2
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_ubreakdown.py +3 -2
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/ummy.py +889 -897
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/unit.py +287 -182
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/unitparser.py +40 -42
- metrolopy-1.0.0/metrolopy/unitutils.py +355 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/usunits.py +14 -13
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/version.py +1 -1
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/PKG-INFO +20 -2
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/SOURCES.txt +1 -1
- {metrolopy-0.6.5 → metrolopy-1.0.0}/setup.py +1 -1
- metrolopy-0.6.5/metrolopy/constcom.py +0 -166
- metrolopy-0.6.5/metrolopy/tests/__init__.py +0 -8
- metrolopy-0.6.5/metrolopy/unitutils.py +0 -331
- {metrolopy-0.6.5 → metrolopy-1.0.0}/LICENSE +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/dfunc.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/license.txt +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/nonlinearunit.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/pmethod.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/printing.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/common.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy/tests/test_complex.py +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/dependency_links.txt +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/requires.txt +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/top_level.txt +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/metrolopy.egg-info/zip-safe +0 -0
- {metrolopy-0.6.5 → metrolopy-1.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: metrolopy
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: tools for dealing with measured quantities: uncertainty propagation and unit conversion
|
|
5
5
|
Home-page: http://nrc-cnrc.github.io/MetroloPy/
|
|
6
6
|
Author: Harold Parks, National Research Council Canada
|
|
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
|
14
14
|
Classifier: Intended Audience :: Science/Research
|
|
15
15
|
Classifier: Intended Audience :: Education
|
|
16
16
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
-
Requires-Python: >=3.
|
|
17
|
+
Requires-Python: >=3.6
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: numpy>=1.13
|
|
@@ -73,6 +73,24 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera
|
|
|
73
73
|
* [a list of the units built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/units.html)
|
|
74
74
|
* [a list of the physical constants built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/constants.html)
|
|
75
75
|
|
|
76
|
+
## new in version 1.0.0
|
|
77
|
+
|
|
78
|
+
* The calculation of effective degrees of freedom has been improved. In
|
|
79
|
+
previous versions, in a multi-step calculation, the effective degree of freedom
|
|
80
|
+
were calculated at each step based on the degrees of freedom calculated for the
|
|
81
|
+
previous step (using a modified Welch-Satterthwaite approximation). Now
|
|
82
|
+
effective degrees of freedom are alway calculated directly from the independent
|
|
83
|
+
variables using the Welch-Satterthwaite equation.
|
|
84
|
+
|
|
85
|
+
* CODATA 2022 values instead of 2018 values are used in the Constants module.
|
|
86
|
+
|
|
87
|
+
* The significance value in budget table has been redefined from
|
|
88
|
+
(sensitivity coefficient * standard uncertainty/combined uncertainty) to the
|
|
89
|
+
square of that value so that the significance value sum to one.
|
|
90
|
+
|
|
91
|
+
* Units can now be raised to a fractional power and many other bug fixes.
|
|
92
|
+
|
|
93
|
+
|
|
76
94
|
## new in version 0.6.0
|
|
77
95
|
|
|
78
96
|
* A constant library has been added with physical constants that can be accessed
|
|
@@ -36,6 +36,24 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera
|
|
|
36
36
|
* [a list of the units built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/units.html)
|
|
37
37
|
* [a list of the physical constants built into MetroloPy](https://nrc-cnrc.github.io/MetroloPy/_static/constants.html)
|
|
38
38
|
|
|
39
|
+
## new in version 1.0.0
|
|
40
|
+
|
|
41
|
+
* The calculation of effective degrees of freedom has been improved. In
|
|
42
|
+
previous versions, in a multi-step calculation, the effective degree of freedom
|
|
43
|
+
were calculated at each step based on the degrees of freedom calculated for the
|
|
44
|
+
previous step (using a modified Welch-Satterthwaite approximation). Now
|
|
45
|
+
effective degrees of freedom are alway calculated directly from the independent
|
|
46
|
+
variables using the Welch-Satterthwaite equation.
|
|
47
|
+
|
|
48
|
+
* CODATA 2022 values instead of 2018 values are used in the Constants module.
|
|
49
|
+
|
|
50
|
+
* The significance value in budget table has been redefined from
|
|
51
|
+
(sensitivity coefficient * standard uncertainty/combined uncertainty) to the
|
|
52
|
+
square of that value so that the significance value sum to one.
|
|
53
|
+
|
|
54
|
+
* Units can now be raised to a fractional power and many other bug fixes.
|
|
55
|
+
|
|
56
|
+
|
|
39
57
|
## new in version 0.6.0
|
|
40
58
|
|
|
41
59
|
* A constant library has been added with physical constants that can be accessed
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
from .version import __version__
|
|
24
24
|
|
|
25
25
|
from .gummy import gummy,jummy
|
|
26
|
-
from .unit import Unit,Conversion,one,Quantity,QuantityArray,unit
|
|
27
|
-
from .ummy import ummy,immy
|
|
26
|
+
from .unit import Unit,Conversion,one,Quantity,QuantityArray,unit,MFraction
|
|
27
|
+
from .ummy import ummy,immy
|
|
28
|
+
from .nummy import nummy
|
|
28
29
|
from .budget import Budget
|
|
29
30
|
from .prefixedunit import PrefixedUnit,BinaryPrefixedUnit
|
|
30
31
|
from .nonlinearunit import NonlinearUnit,NonlinearConversion
|
|
@@ -36,6 +37,6 @@ from .fit import *
|
|
|
36
37
|
from .distributions import *
|
|
37
38
|
from .exceptions import *
|
|
38
39
|
from .printing import set_printer
|
|
39
|
-
from .unitutils import search_units,shadowed_units,convert
|
|
40
|
+
from .unitutils import search_units,shadowed_units,convert,search_units_result
|
|
40
41
|
from .constant import (GummyConstant,JummyConstant,constant,search_constants,
|
|
41
|
-
shadowed_constants)
|
|
42
|
+
shadowed_constants,search_constants_result)
|
|
@@ -26,7 +26,7 @@ uncertainty contributions to a gummy.
|
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
import numpy as np
|
|
29
|
-
from .gummy import gummy
|
|
29
|
+
from .gummy import gummy,_dof_to_str,_k_to_str
|
|
30
30
|
from .unit import one
|
|
31
31
|
from .exceptions import BudgetWarning
|
|
32
32
|
from .printing import PrettyPrinter
|
|
@@ -35,6 +35,14 @@ from .printing import PrettyPrinter
|
|
|
35
35
|
import warnings
|
|
36
36
|
from collections import OrderedDict
|
|
37
37
|
|
|
38
|
+
def append_utype(a,utype):
|
|
39
|
+
if isinstance(utype,list):
|
|
40
|
+
for i in utype:
|
|
41
|
+
append_utype(a,i)
|
|
42
|
+
return
|
|
43
|
+
if utype is not None and utype not in a:
|
|
44
|
+
a.append(utype)
|
|
45
|
+
|
|
38
46
|
class Budget(PrettyPrinter):
|
|
39
47
|
"""
|
|
40
48
|
A class that facilitates the creation of uncertainty budget tables.
|
|
@@ -100,8 +108,9 @@ class Budget(PrettyPrinter):
|
|
|
100
108
|
"type": the uncertainty type, displayed by default if any gummy has
|
|
101
109
|
a type defined
|
|
102
110
|
|
|
103
|
-
"s" or "significance": the sensitivity coefficient (below)
|
|
104
|
-
by the standard uncertainty
|
|
111
|
+
"s" or "significance": the sensitivity coefficient ("c" below)
|
|
112
|
+
multiplied by the standard uncertainty for the component and divided
|
|
113
|
+
by the combined standard uncertainty all squared, displayed by default
|
|
105
114
|
|
|
106
115
|
"d", "derivative" or "partial": the partial derivative of the y gummy
|
|
107
116
|
with resect to the gummy in that row
|
|
@@ -337,33 +346,34 @@ class Budget(PrettyPrinter):
|
|
|
337
346
|
hxnames.append('<span><i>x</i><sub>' + str(i+1) + '</sub></span>')
|
|
338
347
|
lxnames.append('x_{' + str(i+1) + '}')
|
|
339
348
|
else:
|
|
340
|
-
xnames.append(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
else:
|
|
345
|
-
hxnames.append('<span><i>' + str(g.name).strip() + '</i></span>')
|
|
346
|
-
lxnames.append(str(g.name).strip())
|
|
347
|
-
|
|
348
|
-
|
|
349
|
+
xnames.append(g.get_name())
|
|
350
|
+
hxnames.append(g.get_name('html'))
|
|
351
|
+
lxnames.append(g.get_name('latex'))
|
|
352
|
+
|
|
349
353
|
if yname is None:
|
|
350
354
|
if y.name is None:
|
|
351
|
-
|
|
355
|
+
self._yname = self._hyname = self._lyname = 'y'
|
|
352
356
|
else:
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
self._hyname = '<span><i>' + str(yname).strip() + '</i></span>'
|
|
357
|
-
self._lyname = str(yname).strip()
|
|
357
|
+
self._yname = y.get_name()
|
|
358
|
+
self._hyname = y.get_name('html')
|
|
359
|
+
self._lyname = y.get_name('latex')
|
|
358
360
|
else:
|
|
359
|
-
self.
|
|
360
|
-
|
|
361
|
+
self._yname = str(yname).strip()
|
|
362
|
+
if len(yname) <= 1:
|
|
363
|
+
self._hyname = '<span><i>' + str(yname).strip() + '</i></span>'
|
|
364
|
+
self._lyname = str(yname).strip()
|
|
365
|
+
else:
|
|
366
|
+
self._hyname = str(yname).strip()
|
|
367
|
+
self._lyname = type(self).latex_norm(str(yname).strip())
|
|
361
368
|
|
|
362
369
|
|
|
363
370
|
if units_on_values is not None:
|
|
364
371
|
self.units_on_values = units_on_values
|
|
365
372
|
|
|
366
|
-
|
|
373
|
+
if sim:
|
|
374
|
+
self.show_subtotals = False
|
|
375
|
+
else:
|
|
376
|
+
self.show_subtotals = show_subtotals
|
|
367
377
|
self.show_expanded_u = show_expanded_u
|
|
368
378
|
self.css = css
|
|
369
379
|
|
|
@@ -457,9 +467,9 @@ class Budget(PrettyPrinter):
|
|
|
457
467
|
warnings.warn('a source of uncertainty seems to be missing from the x variables',BudgetWarning,stacklevel=2)
|
|
458
468
|
|
|
459
469
|
if sim:
|
|
460
|
-
fsigs = [
|
|
470
|
+
fsigs = [(i*j.usim/yu)**2 for i,j in zip(d,x)]
|
|
461
471
|
else:
|
|
462
|
-
fsigs = [
|
|
472
|
+
fsigs = [(i*j.u/yu)**2 for i,j in zip(d,x)]
|
|
463
473
|
fsc = list(np.abs(d))
|
|
464
474
|
|
|
465
475
|
sigs = []
|
|
@@ -487,9 +497,9 @@ class Budget(PrettyPrinter):
|
|
|
487
497
|
html_sc.append(Budget._format_float(fsc[i],fmt='html'))
|
|
488
498
|
latex_sc.append(Budget._format_float(fsc[i],fmt='latex'))
|
|
489
499
|
fdof.append(x[i].dof)
|
|
490
|
-
dof.append(
|
|
491
|
-
html_dof.append(
|
|
492
|
-
latex_dof.append(
|
|
500
|
+
dof.append(_dof_to_str(x[i].dof))
|
|
501
|
+
html_dof.append(_dof_to_str(x[i].dof,fmt='html'))
|
|
502
|
+
latex_dof.append(_dof_to_str(x[i].dof,fmt='latex'))
|
|
493
503
|
|
|
494
504
|
a = np.array([x,ind,xnames,hxnames,lxnames,dof,html_dof,latex_dof,fdof,
|
|
495
505
|
sigs,html_sigs,latex_sigs,fsigs,str_d,html_d,latex_d,d,sc,
|
|
@@ -503,16 +513,17 @@ class Budget(PrettyPrinter):
|
|
|
503
513
|
if sort:
|
|
504
514
|
self._dfx.sort_values(by=['fs'],inplace=True,ascending=False)
|
|
505
515
|
|
|
506
|
-
stags =
|
|
516
|
+
stags = []
|
|
507
517
|
for r in x:
|
|
508
|
-
|
|
509
|
-
stags.add(r.utype)
|
|
518
|
+
append_utype(stags,r.utype)
|
|
510
519
|
self.type = OrderedDict()
|
|
511
520
|
if stags:
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
521
|
+
stags.sort()
|
|
522
|
+
for t in stags:
|
|
523
|
+
if self.sim:
|
|
524
|
+
u = self._y.ufromsim(t)
|
|
525
|
+
else:
|
|
526
|
+
u = self._y.ufrom(t)
|
|
516
527
|
g = gummy(self._y.x,u=u,unit=self._y.unit)
|
|
517
528
|
if self._y.uunit is not None:
|
|
518
529
|
g.uunit = self._y.uunit
|
|
@@ -661,9 +672,9 @@ class Budget(PrettyPrinter):
|
|
|
661
672
|
elif c == 'c' or c == 'sensitivity coefficient' or c == 'sensitivity coefficients':
|
|
662
673
|
self._column_names['c'] = v
|
|
663
674
|
elif c == 'description':
|
|
664
|
-
self.
|
|
675
|
+
self._column_names['description'] = v
|
|
665
676
|
elif c == 'custom':
|
|
666
|
-
self.
|
|
677
|
+
self._column_names['custom'] = v
|
|
667
678
|
else:
|
|
668
679
|
raise ValueError('original column name ' + str(c) + ' is unrecognized')
|
|
669
680
|
|
|
@@ -756,9 +767,9 @@ class Budget(PrettyPrinter):
|
|
|
756
767
|
k = self._y.ksim
|
|
757
768
|
else:
|
|
758
769
|
k = self._y.k
|
|
759
|
-
nms.append('Uc at k = ' +
|
|
760
|
-
hnms.append('<span><i>U<sub>c<sub></i> at <i>k</i> = ' +
|
|
761
|
-
lnms.append('U_c ' + type(self).latex_norm(' at ') + ' k = ' +
|
|
770
|
+
nms.append('Uc at k = ' + _k_to_str(k))
|
|
771
|
+
hnms.append('<span><i>U<sub>c<sub></i> at <i>k</i> = ' + _k_to_str(k) + '</span>')
|
|
772
|
+
lnms.append('U_c ' + type(self).latex_norm(' at ') + ' k = ' + _k_to_str(k))
|
|
762
773
|
|
|
763
774
|
cnm = cnml = self.column_names.get(c)
|
|
764
775
|
if cnm is None:
|
|
@@ -902,7 +913,7 @@ class Budget(PrettyPrinter):
|
|
|
902
913
|
hu.append(g.tostring(fmt='html',style=ust_g,solidus=self.solidus,mulsep=self.mulsep,show_name=False))
|
|
903
914
|
lu.append(g.tostring(fmt='latex',style=ust_g,solidus=self.solidus,mulsep=self.mulsep,show_name=False))
|
|
904
915
|
|
|
905
|
-
cnm = cnmh = self.column_names.get(c)
|
|
916
|
+
cnm = cnmh = cnml = self.column_names.get(c)
|
|
906
917
|
if cnm is None:
|
|
907
918
|
if self.uunit is None or self.units_on_values:
|
|
908
919
|
cnm = cnml = 'u'
|
|
@@ -929,13 +940,13 @@ class Budget(PrettyPrinter):
|
|
|
929
940
|
if self.show_subtotals:
|
|
930
941
|
for t in self.type.values():
|
|
931
942
|
fdof.append(t[1])
|
|
932
|
-
dof.append(
|
|
933
|
-
hdof.append(
|
|
934
|
-
ldof.append(
|
|
943
|
+
dof.append(_dof_to_str(t[1]))
|
|
944
|
+
hdof.append(_dof_to_str(t[1],'html'))
|
|
945
|
+
ldof.append(_dof_to_str(t[1],'latex'))
|
|
935
946
|
fdof.append(self._y.dof)
|
|
936
|
-
dof.append(
|
|
937
|
-
hdof.append(
|
|
938
|
-
ldof.append(
|
|
947
|
+
dof.append(_dof_to_str(self._y.dof))
|
|
948
|
+
hdof.append(_dof_to_str(self._y.dof,fmt='html'))
|
|
949
|
+
ldof.append(_dof_to_str(self._y.dof,fmt='latex'))
|
|
939
950
|
if show_exu:
|
|
940
951
|
fdof.append(None)
|
|
941
952
|
dof.append('')
|
|
@@ -957,7 +968,7 @@ class Budget(PrettyPrinter):
|
|
|
957
968
|
if c == 'type':
|
|
958
969
|
tags = []
|
|
959
970
|
for r in self._dfx['x']:
|
|
960
|
-
if r.utype is not None:
|
|
971
|
+
if r.utype is not None and not isinstance(r.utype,list):
|
|
961
972
|
tags.append(str(r.utype))
|
|
962
973
|
else:
|
|
963
974
|
tags.append('')
|
|
@@ -990,10 +1001,10 @@ class Budget(PrettyPrinter):
|
|
|
990
1001
|
yu = self._y.usim
|
|
991
1002
|
else:
|
|
992
1003
|
yu = self._y.u
|
|
993
|
-
fs.append(v[0]/yu)
|
|
994
|
-
s.append(Budget._formatsig(v[0]/yu))
|
|
995
|
-
hs.append(Budget._formatsig(v[0]/yu,'html'))
|
|
996
|
-
ls.append(Budget._formatsig(v[0]/yu,'latex'))
|
|
1004
|
+
fs.append((v[0]/yu)**2)
|
|
1005
|
+
s.append(Budget._formatsig((v[0]/yu)**2))
|
|
1006
|
+
hs.append(Budget._formatsig((v[0]/yu)**2,'html'))
|
|
1007
|
+
ls.append(Budget._formatsig((v[0]/yu)**2,'latex'))
|
|
997
1008
|
fs.append(None)
|
|
998
1009
|
s.append('')
|
|
999
1010
|
hs.append('')
|