metrolopy 1.0.0__tar.gz → 1.0.1__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.
Files changed (49) hide show
  1. {metrolopy-1.0.0 → metrolopy-1.0.1}/PKG-INFO +6 -6
  2. {metrolopy-1.0.0 → metrolopy-1.0.1}/README.md +5 -5
  3. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/gummy.py +19 -18
  4. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/nummy.py +16 -22
  5. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_complex.py +22 -0
  6. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_create.py +3 -0
  7. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_gummy.py +88 -0
  8. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_misc.py +3 -1
  9. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_operations.py +55 -0
  10. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/test_ubreakdown.py +3 -0
  11. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/ummy.py +1 -1
  12. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/version.py +1 -1
  13. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/PKG-INFO +6 -6
  14. {metrolopy-1.0.0 → metrolopy-1.0.1}/LICENSE +0 -0
  15. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/__init__.py +0 -0
  16. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/budget.py +0 -0
  17. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/builtin_constants.py +0 -0
  18. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/constant.py +0 -0
  19. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/constcom.py +0 -0
  20. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/dfunc.py +0 -0
  21. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/distributions.py +0 -0
  22. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/exceptions.py +0 -0
  23. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/fit.py +0 -0
  24. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/functions.py +0 -0
  25. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/indexed.py +0 -0
  26. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/license.txt +0 -0
  27. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/logunit.py +0 -0
  28. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/mean.py +0 -0
  29. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/miscunits.py +0 -0
  30. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/nonlinearunit.py +0 -0
  31. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/offsetunit.py +0 -0
  32. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/pmethod.py +0 -0
  33. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/prefixedunit.py +0 -0
  34. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/printing.py +0 -0
  35. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/relunits.py +0 -0
  36. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/siunits.py +0 -0
  37. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/__init__.py +0 -0
  38. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/tests/common.py +0 -0
  39. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/unit.py +0 -0
  40. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/unitparser.py +0 -0
  41. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/unitutils.py +0 -0
  42. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy/usunits.py +0 -0
  43. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/SOURCES.txt +0 -0
  44. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/dependency_links.txt +0 -0
  45. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/requires.txt +0 -0
  46. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/top_level.txt +0 -0
  47. {metrolopy-1.0.0 → metrolopy-1.0.1}/metrolopy.egg-info/zip-safe +0 -0
  48. {metrolopy-1.0.0 → metrolopy-1.0.1}/setup.cfg +0 -0
  49. {metrolopy-1.0.0 → metrolopy-1.0.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metrolopy
3
- Version: 1.0.0
3
+ Version: 1.0.1
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
@@ -41,7 +41,7 @@ tools for dealing with physical quantities: uncertainty propagation and unit co
41
41
 
42
42
  ---
43
43
 
44
- MetroloPy is a pure python package and requires Python 3.5 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
44
+ MetroloPy is a pure python package and requires Python 3.6 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
45
45
 
46
46
  Install MetroloPy with `pip install metrolopy` or
47
47
  `conda install -c conda-forge metrolopy`.
@@ -67,8 +67,8 @@ Physical quantities can then be represented in Python as `gummy` objects with an
67
67
 
68
68
  MetroloPy can do much more including Monte-Carlo uncertainty propagation, generating uncertainty budget tables, and curve fitting. It can also handle expanded uncertainties, degrees of freedom, correlated quantities, and complex valued quantities. See:
69
69
 
70
- * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" download> download the tutorial as Jupyter notebook</a>)
71
- * [the documentation](https://nrc-cnrc.github.io/MetroloPy/)
70
+ * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" target="_blank"> download the tutorial as Jupyter notebook</a>)
71
+ * [the documentation](https://nrc-cnrc.github.io/MetroloPy/_build/html/index.html)
72
72
  * [the issues page on GitHub](https://github.com/nrc-cnrc/Metrolopy/issues)
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)
@@ -79,14 +79,14 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera
79
79
  previous versions, in a multi-step calculation, the effective degree of freedom
80
80
  were calculated at each step based on the degrees of freedom calculated for the
81
81
  previous step (using a modified Welch-Satterthwaite approximation). Now
82
- effective degrees of freedom are alway calculated directly from the independent
82
+ effective degrees of freedom are always calculated directly from the independent
83
83
  variables using the Welch-Satterthwaite equation.
84
84
 
85
85
  * CODATA 2022 values instead of 2018 values are used in the Constants module.
86
86
 
87
87
  * The significance value in budget table has been redefined from
88
88
  (sensitivity coefficient * standard uncertainty/combined uncertainty) to the
89
- square of that value so that the significance value sum to one.
89
+ square of that value so that the significance values in a budget sum to one.
90
90
 
91
91
  * Units can now be raised to a fractional power and many other bug fixes.
92
92
 
@@ -4,7 +4,7 @@ tools for dealing with physical quantities: uncertainty propagation and unit co
4
4
 
5
5
  ---
6
6
 
7
- MetroloPy is a pure python package and requires Python 3.5 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
7
+ MetroloPy is a pure python package and requires Python 3.6 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
8
8
 
9
9
  Install MetroloPy with `pip install metrolopy` or
10
10
  `conda install -c conda-forge metrolopy`.
@@ -30,8 +30,8 @@ Physical quantities can then be represented in Python as `gummy` objects with an
30
30
 
31
31
  MetroloPy can do much more including Monte-Carlo uncertainty propagation, generating uncertainty budget tables, and curve fitting. It can also handle expanded uncertainties, degrees of freedom, correlated quantities, and complex valued quantities. See:
32
32
 
33
- * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" download> download the tutorial as Jupyter notebook</a>)
34
- * [the documentation](https://nrc-cnrc.github.io/MetroloPy/)
33
+ * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" target="_blank"> download the tutorial as Jupyter notebook</a>)
34
+ * [the documentation](https://nrc-cnrc.github.io/MetroloPy/_build/html/index.html)
35
35
  * [the issues page on GitHub](https://github.com/nrc-cnrc/Metrolopy/issues)
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)
@@ -42,14 +42,14 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera
42
42
  previous versions, in a multi-step calculation, the effective degree of freedom
43
43
  were calculated at each step based on the degrees of freedom calculated for the
44
44
  previous step (using a modified Welch-Satterthwaite approximation). Now
45
- effective degrees of freedom are alway calculated directly from the independent
45
+ effective degrees of freedom are always calculated directly from the independent
46
46
  variables using the Welch-Satterthwaite equation.
47
47
 
48
48
  * CODATA 2022 values instead of 2018 values are used in the Constants module.
49
49
 
50
50
  * The significance value in budget table has been redefined from
51
51
  (sensitivity coefficient * standard uncertainty/combined uncertainty) to the
52
- square of that value so that the significance value sum to one.
52
+ square of that value so that the significance values in a budget sum to one.
53
53
 
54
54
  * Units can now be raised to a fractional power and many other bug fixes.
55
55
 
@@ -561,7 +561,6 @@ class gummy(Quantity,metaclass=MetaGummy):
561
561
 
562
562
  if isinstance(x,gummy):
563
563
  self._value = nummy(x.value)
564
- self._value._fp = self._get_p
565
564
  self._unit = x._unit
566
565
  self._U = self._value.u
567
566
  self._value._name = x._value._name
@@ -580,7 +579,6 @@ class gummy(Quantity,metaclass=MetaGummy):
580
579
 
581
580
  if isinstance(x,ummy):
582
581
  self._value = nummy(x)
583
- self._value._fp = self._get_p
584
582
  self._U = self._value.u
585
583
  self._k = 1
586
584
  self._pm = None
@@ -659,7 +657,6 @@ class gummy(Quantity,metaclass=MetaGummy):
659
657
  u = u/type(u)(self._k)
660
658
 
661
659
  self._value = nummy(x,u=u,dof=dof,utype=utype,name=name)
662
- self._value._fp = self._get_p
663
660
 
664
661
  self._U = None
665
662
  self._set_U(self._k,uunit)
@@ -704,10 +701,23 @@ class gummy(Quantity,metaclass=MetaGummy):
704
701
  Returns `True` if the gummy is an independent variable. That is the
705
702
  ummy has u > 0 and was not correlated with any other gummy's when it was
706
703
  created or is perfectly correlated or anti-correlated (correlation
707
- coefficeint 1 or -1) with such an ummy.'
704
+ coefficeint 1 or -1) with such an ummy.
708
705
  """
709
706
 
710
707
  return self.value.isindependent
708
+
709
+ @property
710
+ def independent(self):
711
+ """
712
+ `bool`, read-only
713
+
714
+ Returns `True` if the gummy is an independent variable. That is the
715
+ ummy has u > 0 and was not correlated with any other gummy's when it was
716
+ created or is perfectly correlated or anti-correlated (correlation
717
+ coefficeint 1 or -1) with such an ummy. Identical to the
718
+ isindependent property.
719
+ """
720
+ return self.value.isindependent
711
721
 
712
722
  @property
713
723
  def U(self):
@@ -839,7 +849,7 @@ class gummy(Quantity,metaclass=MetaGummy):
839
849
  `k` properties will affect `Usym`.
840
850
  """
841
851
  if not isinstance(self._U,Quantity):
842
- return self._value.Usim
852
+ return self._value.Usim(self.p)
843
853
 
844
854
  if self.uunit_is_rel:
845
855
  x = self.xsim
@@ -892,7 +902,7 @@ class gummy(Quantity,metaclass=MetaGummy):
892
902
  but changing the `p`, `k`, or `cimethod` properties will affect the return
893
903
  value.
894
904
  """
895
- return self._value.cisim
905
+ return self._value.cisim(self.p)
896
906
 
897
907
  @property
898
908
  def cimethod(self):
@@ -925,7 +935,7 @@ class gummy(Quantity,metaclass=MetaGummy):
925
935
  value = value.lower().strip()
926
936
  if value not in ['shortest','symmetric']:
927
937
  raise ValueError('cimethod ' + str(value) + ' is not recognized')
928
- self.value._cimethod = value
938
+ self.value.cimethod = value
929
939
 
930
940
  @property
931
941
  def simdata(self):
@@ -963,17 +973,7 @@ class gummy(Quantity,metaclass=MetaGummy):
963
973
 
964
974
  Returns ``0.5*(gummy.Usim[0] + gummy.Usim[1])/gummy.usim``
965
975
  """
966
- return self.value.ksim
967
-
968
- @property
969
- def independent(self):
970
- """
971
- `bool`, read-only
972
-
973
- Returns `False` if the owning gummy was created from a operation involving
974
- other gummys or has zero uncertainty and `True` otherwise.
975
- """
976
- return self.value.isindependent
976
+ return self.value.ksim(self.p)
977
977
 
978
978
  @property
979
979
  def name(self):
@@ -1039,6 +1039,7 @@ class gummy(Quantity,metaclass=MetaGummy):
1039
1039
  Quantity.unit.fset(self,u)
1040
1040
  self._U = None
1041
1041
  self._set_U()
1042
+ self._value.clear()
1042
1043
 
1043
1044
  @property
1044
1045
  def uunit(self):
@@ -111,7 +111,6 @@ class nummy(ummy):
111
111
 
112
112
  _cimethod = 'shortest'
113
113
  _bayesian = False # see the gummy bayesian property
114
- _fp = None
115
114
  _nsim = None
116
115
 
117
116
  def __init__(self,x,u=0,dof=float('inf'),utype=None,name=None):
@@ -299,38 +298,35 @@ class nummy(ummy):
299
298
  def xsim(self):
300
299
  if not isinstance(self._dist,Distribution):
301
300
  return self._dist
302
- return self.distribution.mean
301
+ return float(self.distribution.mean)
303
302
 
304
303
  @property
305
304
  def usim(self):
306
305
  if not isinstance(self._dist,Distribution):
307
306
  return 0
308
- return self.distribution.stdev
307
+ return float(self.distribution.stdev)
309
308
 
310
- @property
311
- def cisim(self):
309
+ def cisim(self,p):
312
310
  if not isinstance(self._dist,Distribution):
313
311
  return [self._dist,self._dist]
314
312
  if self._cimethod == 'shortest':
315
- return self.distribution.ci(self.p)
313
+ return [float(i) for i in self.distribution.ci(p)]
316
314
  else:
317
- return self.distribution.cisym(self.p)
315
+ return [float(i) for i in self.distribution.cisym(p)]
318
316
 
319
- @property
320
- def Usim(self):
317
+ def Usim(self,p):
321
318
  if not isinstance(self._dist,Distribution):
322
319
  return 0
323
320
  x = self.distribution.mean
324
321
 
325
322
  if self._cimethod == 'shortest':
326
- ci = self.distribution.ci(self.p)
323
+ ci = self.distribution.ci(p)
327
324
  else:
328
- ci = self.distribution.cisym(self.p)
325
+ ci = self.distribution.cisym(p)
329
326
 
330
- return (ci[1]-x,x-ci[0])
327
+ return (float(ci[1]-x),float(x-ci[0]))
331
328
 
332
- @property
333
- def ksim(self):
329
+ def ksim(self,p):
334
330
  """
335
331
  read-only
336
332
 
@@ -338,7 +334,8 @@ class nummy(ummy):
338
334
  """
339
335
  if self.usim == 0 or not isinstance(self._dist,Distribution):
340
336
  return float('inf')
341
- return 0.5*(self.Usim[0] + self.Usim[1])/self.usim
337
+ usm = self.Usim(p)
338
+ return 0.5*(usm[0] + usm[1])/self.usim
342
339
 
343
340
  @property
344
341
  def isindependent(self):
@@ -385,12 +382,9 @@ class nummy(ummy):
385
382
  if value not in ['shortest','symmetric']:
386
383
  raise ValueError('cimethod ' + str(value) + ' is not recognized')
387
384
  self._cimethod = value
388
-
389
- @property
390
- def p(self):
391
- if self._fp is None:
392
- return 0.68268949213708585
393
- return self._fp()
385
+ if isinstance(self.distribution,Distribution):
386
+ self.distribution._ci = {}
387
+ self.distribution._cisym = {}
394
388
 
395
389
  @staticmethod
396
390
  def set_seed(seed):
@@ -564,7 +558,7 @@ class nummy(ummy):
564
558
  See the method `gummy.covariance(g)` for the corresponding result based
565
559
  on first order error propagation.
566
560
  """
567
- return self._dist.covsim(g._dist)
561
+ return float(self._dist.covsim(g._dist))
568
562
 
569
563
  def correlation_sim(self,g):
570
564
  """
@@ -78,6 +78,10 @@ def make_immy(prnt=False):
78
78
 
79
79
 
80
80
  class TestComplex(unittest.TestCase):
81
+ """
82
+ Tests for the `immy` and `jummy` classes. Basic operations and
83
+ instance creation are tested using random values.
84
+ """
81
85
  def assert_ummy_close(self,u1,u2):
82
86
  self.assertTrue(abs(u1.correlation(u2)) > 1 - 1e-4)
83
87
  u1x = max(u1.x,u1.u,u2.x,u2.u)
@@ -94,6 +98,9 @@ class TestComplex(unittest.TestCase):
94
98
  self.assert_ummy_close(i1.imag,i2.imag)
95
99
 
96
100
  def test_immy_init(self,n=1000,prnt=False):
101
+ """
102
+ Test immy creation using the real,imag,r and phi keywords.
103
+ """
97
104
  for m in range(n):
98
105
  x,xr,xi = make_immy(prnt=prnt)
99
106
 
@@ -175,6 +182,9 @@ class TestComplex(unittest.TestCase):
175
182
  self.assert_immy_close(c,cn)
176
183
 
177
184
  def test_immy_add(self,n=1000,prnt=False):
185
+ """
186
+ Test immy addition.
187
+ """
178
188
  self._test_immy_bop(lambda a,b: a + b,np.add,n,prnt)
179
189
 
180
190
  for m in range(10):
@@ -183,6 +193,9 @@ class TestComplex(unittest.TestCase):
183
193
  self.assertTrue(0 + i == i)
184
194
 
185
195
  def test_immy_sub(self,n=1000,prnt=False):
196
+ """
197
+ Test immy subtraction.
198
+ """
186
199
  self._test_immy_bop(lambda a,b: a - b,np.subtract,n,prnt)
187
200
 
188
201
  for m in range(10):
@@ -191,6 +204,9 @@ class TestComplex(unittest.TestCase):
191
204
  self.assertTrue(0 - i == -i)
192
205
 
193
206
  def test_immy_mul(self,n=1000,prnt=False):
207
+ """
208
+ Test immy multiplication.
209
+ """
194
210
  self._test_immy_bop(lambda a,b: a*b,np.multiply,n,prnt)
195
211
 
196
212
  for m in range(10):
@@ -203,6 +219,9 @@ class TestComplex(unittest.TestCase):
203
219
  self.assertTrue(immy(1)*i == i)
204
220
 
205
221
  def test_immy_div(self,n=1000,prnt=False):
222
+ """
223
+ Test immy division.
224
+ """
206
225
  self._test_immy_bop(lambda a,b: a/b,np.divide,n,prnt,allow_small=False)
207
226
 
208
227
  for m in range(10):
@@ -210,6 +229,9 @@ class TestComplex(unittest.TestCase):
210
229
  self.assertTrue(i/1 == i)
211
230
 
212
231
  def test_immy_pow(self,n=1000,prnt=False):
232
+ """
233
+ Test immy exponentiation.
234
+ """
213
235
  #_test_immy_bop(lambda a,b: a**b,np.power,n,prnt,allow_small=False)
214
236
 
215
237
  for m in range(10):
@@ -9,6 +9,9 @@ from metrolopy.tests.common import rand,display
9
9
 
10
10
  class TestCreate(unittest.TestCase):
11
11
  def test_gummy_init(self,n=None,exception_on_warning=True,prnt=False,plot=False):
12
+ """
13
+ Test gummy creation.
14
+ """
12
15
  try:
13
16
  from scipy.stats import norm, t
14
17
 
@@ -28,6 +28,9 @@ import numpy as np
28
28
  import unittest
29
29
 
30
30
  class TestGummy(unittest.TestCase):
31
+ """
32
+ Various unit tests of gummy properties and methods.
33
+ """
31
34
  def test_ku(self):
32
35
  from metrolopy.gummy import _ku
33
36
  from decimal import Decimal
@@ -36,6 +39,10 @@ class TestGummy(unittest.TestCase):
36
39
  self.assertTrue(_ku(2.1,Decimal(3.3)) == Decimal(float(2.1))*Decimal(3.3))
37
40
 
38
41
  def test_meta_properties(self):
42
+ """
43
+ Test class properties.
44
+
45
+ """
39
46
  a = uc.gummy.cimethod
40
47
  self.assertTrue(isinstance(a,str))
41
48
  uc.gummy.cimethod = 'symmetric'
@@ -123,6 +130,9 @@ class TestGummy(unittest.TestCase):
123
130
  uc.gummy.thousand_spaces = ts
124
131
 
125
132
  def test_init(self):
133
+ """
134
+ Test gummy creation
135
+ """
126
136
  g = uc.gummy(1.2,3.4)
127
137
  self.assertTrue(g.x == 1.2)
128
138
  self.assertTrue(g.u == 3.4)
@@ -223,6 +233,9 @@ class TestGummy(unittest.TestCase):
223
233
  self.assertTrue(gg.name == 'def')
224
234
 
225
235
  def test_U(self):
236
+ """
237
+ Test expanded uncertainty.
238
+ """
226
239
  a = uc.gummy(1.1,2.2)
227
240
  self.assertTrue(a.U == 2.2)
228
241
  b = uc.gummy(3,4.4)
@@ -240,6 +253,9 @@ class TestGummy(unittest.TestCase):
240
253
  self.assertTrue(abs(c.U[1] - 4.4*1.1/3**2) < 1e-12)
241
254
 
242
255
  def test_set_U(self):
256
+ """
257
+ Additional tests for expanded uncertainty.
258
+ """
243
259
  g = uc.gummy(1.0,1.0,k=2,unit='cm',uunit='mm')
244
260
  self.assertTrue(g.U == 1)
245
261
  self.assertTrue(g.uunit is uc.unit('mm'))
@@ -254,6 +270,9 @@ class TestGummy(unittest.TestCase):
254
270
  self.assertTrue(c.U[1] == 4.4)
255
271
 
256
272
  def test_iset_U(self):
273
+ """
274
+ Additional tests for expanded uncertainty.
275
+ """
257
276
  g = uc.gummy(1)
258
277
  self.assertTrue(g._iset_U() == 0)
259
278
  self.assertTrue(g._iset_U(unit='m').unit is uc.unit('m'))
@@ -284,6 +303,9 @@ class TestGummy(unittest.TestCase):
284
303
  self.assertTrue(g._iset_U(k=2) == 2)
285
304
 
286
305
  def test_Usim(self):
306
+ """
307
+ Test the gummy.Usim property
308
+ """
287
309
  g = uc.gummy(-8.5,1,unit='m')
288
310
  g.sim()
289
311
  self.assertTrue(abs(g.Usim[0] - 1) < 0.5)
@@ -352,16 +374,25 @@ class TestGummy(unittest.TestCase):
352
374
  self.assertTrue(g.simsorted[i+1] >= g.simsorted[i])
353
375
 
354
376
  def test_distribution(self):
377
+ """
378
+ Test gummy.distribution
379
+ """
355
380
  g = uc.gummy(1,1)
356
381
  self.assertTrue(isinstance(g.distribution,uc.Distribution))
357
382
 
358
383
  def test_ksim(self):
384
+ """
385
+ Test gummy.ksim
386
+ """
359
387
  g = uc.gummy(1,1)
360
388
  g.p = 0.9545
361
389
  g.sim()
362
390
  self.assertTrue(abs(g.ksim - 2) < 0.1)
363
391
 
364
392
  def test_independent(self):
393
+ """
394
+ Test gummy.independant
395
+ """
365
396
  a = uc.gummy(1,1)
366
397
  b = uc.gummy(-2,2)
367
398
  c = a + b
@@ -371,6 +402,9 @@ class TestGummy(unittest.TestCase):
371
402
  self.assertTrue(not d.independent)
372
403
 
373
404
  def test_name(self):
405
+ """
406
+ Test setting and getting gummy.name
407
+ """
374
408
  g = uc.gummy(1,1)
375
409
  self.assertTrue(g.name is None)
376
410
  g.name = 'abc'
@@ -415,6 +449,9 @@ class TestGummy(unittest.TestCase):
415
449
  pass
416
450
 
417
451
  def test_unit(self):
452
+ """
453
+ Test setting and getting gummy.unit
454
+ """
418
455
  g = uc.gummy(1,1,unit='m')
419
456
  self.assertTrue(g.unit is uc.unit('m'))
420
457
  self.assertTrue(str(g.unit) == 'm')
@@ -428,6 +465,9 @@ class TestGummy(unittest.TestCase):
428
465
  self.assertTrue(g.u == 1000)
429
466
 
430
467
  def test_uunit(self):
468
+ """
469
+ Test setting and getting gummy.uunit
470
+ """
431
471
  g = uc.gummy(1,1)
432
472
  self.assertTrue(g.uunit is None)
433
473
  g = uc.gummy(1,1,unit='m',uunit='cm')
@@ -446,6 +486,9 @@ class TestGummy(unittest.TestCase):
446
486
  self.assertTrue(g.uunit is None)
447
487
 
448
488
  def test_uunit_is_rel(self):
489
+ """
490
+ Test gummy.uunit_is_rel
491
+ """
449
492
  g = uc.gummy(1,1)
450
493
  self.assertTrue(not g.uunit_is_rel)
451
494
  g.uunit='%'
@@ -459,6 +502,9 @@ class TestGummy(unittest.TestCase):
459
502
  self.assertTrue(g.uunit_is_rel)
460
503
 
461
504
  def test_k(self):
505
+ """
506
+ Test setting and getting gummy.k
507
+ """
462
508
  g = uc.gummy(1)
463
509
  self.assertTrue(g.k is None)
464
510
 
@@ -479,6 +525,9 @@ class TestGummy(unittest.TestCase):
479
525
  self.assertTrue(abs(g.k - 1.96) < 0.01)
480
526
 
481
527
  def test_p(self):
528
+ """
529
+ Test setting and getting gummy.p
530
+ """
482
531
  uc.gummy.p_method = None
483
532
  g = uc.gummy(1,1)
484
533
  g.p = 0.95
@@ -498,6 +547,9 @@ class TestGummy(unittest.TestCase):
498
547
  pass
499
548
 
500
549
  def test_correlation(self):
550
+ """
551
+ Test gummy.correlation
552
+ """
501
553
  a = uc.gummy(1,1)
502
554
  b = uc.gummy(1,2)
503
555
  c = a + b
@@ -510,6 +562,9 @@ class TestGummy(unittest.TestCase):
510
562
  self.assertTrue(a.correlation(a) == 1)
511
563
 
512
564
  def test_covariance(self):
565
+ """
566
+ Test gummy.covariance
567
+ """
513
568
  a = uc.gummy(1,1)
514
569
  b = uc.gummy(1,2)
515
570
  c = a + b
@@ -523,6 +578,9 @@ class TestGummy(unittest.TestCase):
523
578
  self.assertTrue(b.covariance(b) == 4)
524
579
 
525
580
  def test_correlation_sim(self):
581
+ """
582
+ Test gummy.correlation_sim
583
+ """
526
584
  a = uc.gummy(1,1)
527
585
  b = uc.gummy(1,2)
528
586
  c = a + b
@@ -535,6 +593,9 @@ class TestGummy(unittest.TestCase):
535
593
  self.assertTrue(abs(a.correlation_sim(a) - 1) < 1e-6)
536
594
 
537
595
  def test_covariance_sim(self):
596
+ """
597
+ Test gummy.covariance_sim
598
+ """
538
599
  a = uc.gummy(1,1)
539
600
  b = uc.gummy(1,2)
540
601
  c = a + b
@@ -548,6 +609,9 @@ class TestGummy(unittest.TestCase):
548
609
  self.assertTrue(abs(b.covariance_sim(b) - 4) < 1e-1)
549
610
 
550
611
  def test_correlation_matrix(self):
612
+ """
613
+ Test gummy.correlation_matrix
614
+ """
551
615
  a = uc.gummy(1,1)
552
616
  b = uc.gummy(1,2)
553
617
  c = a + b
@@ -564,6 +628,9 @@ class TestGummy(unittest.TestCase):
564
628
  self.assertTrue((m[1][2] - 2/c.u) < 1e-1)
565
629
 
566
630
  def test_covariance_matrix(self):
631
+ """
632
+ Test gummy.covariance_matrix
633
+ """
567
634
  a = uc.gummy(1,1)
568
635
  b = uc.gummy(1,2)
569
636
  c = a + b
@@ -580,10 +647,16 @@ class TestGummy(unittest.TestCase):
580
647
  self.assertTrue((m[1][2] - 4) < 1e-1)
581
648
 
582
649
  def test_finfo(self):
650
+ """
651
+ Test gummy.finfo
652
+ """
583
653
  a = uc.gummy(1,1)
584
654
  self.assertTrue(a.finfo.rel_u == 0)
585
655
 
586
656
  def test_real(self):
657
+ """
658
+ Test gummy.real
659
+ """
587
660
  a = uc.gummy(1.1,0.3)
588
661
  b = a.real
589
662
  self.assertTrue(not a is b)
@@ -592,6 +665,9 @@ class TestGummy(unittest.TestCase):
592
665
  self.assertTrue(a.correlation(b) == 1)
593
666
 
594
667
  def test_conjugate(self):
668
+ """
669
+ Test gummy.conjugate
670
+ """
595
671
  a = uc.gummy(1.1,0.3)
596
672
  b = a.conjugate()
597
673
  self.assertTrue(not a is b)
@@ -600,16 +676,25 @@ class TestGummy(unittest.TestCase):
600
676
  self.assertTrue(a.correlation(b) == 1)
601
677
 
602
678
  def test_angle(self):
679
+ """
680
+ Test gummy.angle
681
+ """
603
682
  self.assertTrue(uc.gummy(1.1,0.3).angle() == 0)
604
683
  self.assertTrue(abs(abs(uc.gummy(-1.1,0.3).angle()) - np.pi) < 1e-10)
605
684
 
606
685
  def test_utype(self):
686
+ """
687
+ Test gummy.utype
688
+ """
607
689
  a = uc.gummy(1.2,1,1,utype='A')
608
690
  self.assertTrue(a.utype == 'A')
609
691
  b = uc.gummy(1.2,1,1,utype='xyz')
610
692
  self.assertTrue(b.utype == 'xyz')
611
693
 
612
694
  def test_ufrom(self):
695
+ """
696
+ Test gummy.ufrom
697
+ """
613
698
  a = uc.gummy(1.2,0.2,utype='A')
614
699
  b = uc.gummy(3.2,0.5,utype='A')
615
700
  c = uc.gummy(0.9,0.2,utype='B')
@@ -620,6 +705,9 @@ class TestGummy(unittest.TestCase):
620
705
  self.assertTrue(d.ufrom(c) == 0.2)
621
706
 
622
707
  def test_dof_from(self):
708
+ """
709
+ Test gummy.doffrom
710
+ """
623
711
  a = uc.gummy(1.2,0.2,dof=5,utype='A')
624
712
  b = uc.gummy(3.2,0.5,dof=7,utype='A')
625
713
  c = uc.gummy(0.9,0.2,utype='B')
@@ -29,7 +29,9 @@ import unittest
29
29
 
30
30
 
31
31
  class TestMisc(unittest.TestCase):
32
-
32
+ """
33
+ Miscellaneaus tests.
34
+ """
33
35
  def test_reduce(self):
34
36
  a = uc.gummy(12.367,0.22,unit='mm/m')
35
37
  a.reduce_unit()
@@ -28,6 +28,10 @@ from metrolopy.tests.common import rand,make_gummy,make_number
28
28
 
29
29
 
30
30
  class TestOperations(unittest.TestCase):
31
+ """
32
+ Tests checking basic operations with `gummy` instances using random
33
+ values.
34
+ """
31
35
  def binary_func(self,f,df,sim=False,exp=None,fionly=False,uexp=-6,allowazero=True,
32
36
  allowbzero=True,allowlargeu=True):
33
37
  if sim:
@@ -104,6 +108,9 @@ class TestOperations(unittest.TestCase):
104
108
  self.assertTrue(abs((g.correlation_sim(b)-g.correlation(b))/g.correlation(b)) < 0.1)
105
109
 
106
110
  def test_add(self,n=1000,sim=False):
111
+ """
112
+ Test gummy addition.
113
+ """
107
114
  def f(a,b):
108
115
  return a + b
109
116
  def df(ax,bx):
@@ -112,6 +119,9 @@ class TestOperations(unittest.TestCase):
112
119
  self.binary_func(f,df,sim=sim)
113
120
 
114
121
  def test_sub(self,n=1000,sim=False):
122
+ """
123
+ Test gummy subtraction.
124
+ """
115
125
  def f(a,b):
116
126
  return a - b
117
127
  def df(ax,bx):
@@ -120,6 +130,9 @@ class TestOperations(unittest.TestCase):
120
130
  self.binary_func(f,df,sim=sim)
121
131
 
122
132
  def test_mul(self,n=1000,sim=False):
133
+ """
134
+ Test gummy multiplication.
135
+ """
123
136
  def f(a,b):
124
137
  return a*b
125
138
  def df(ax,bx):
@@ -128,6 +141,9 @@ class TestOperations(unittest.TestCase):
128
141
  self.binary_func(f,df,sim=sim)
129
142
 
130
143
  def test_div(self,n=1000,sim=False):
144
+ """
145
+ Test gummy division.
146
+ """
131
147
  def f(a,b):
132
148
  return a/b
133
149
  def df(ax,bx):
@@ -140,6 +156,9 @@ class TestOperations(unittest.TestCase):
140
156
  self.binary_func(f,df,sim=sim,allowbzero=False,allowlargeu=lu)
141
157
 
142
158
  def test_pow(self,n=1000,sim=False):
159
+ """
160
+ Test gummy exponentiation.
161
+ """
143
162
  def f(a,b):
144
163
  return abs(a)**b
145
164
  def df(ax,bx):
@@ -153,6 +172,9 @@ class TestOperations(unittest.TestCase):
153
172
  self.binary_func(f,df,sim=sim,exp=0,allowazero=False,allowlargeu=lu)
154
173
 
155
174
  def test_mod(self,n=1000,sim=False):
175
+ """
176
+ Test gummy mod.
177
+ """
156
178
  def f(a,b):
157
179
  return a%b
158
180
  def df(ax,bx):
@@ -161,6 +183,9 @@ class TestOperations(unittest.TestCase):
161
183
  self.binary_func(f,df,sim=sim,fionly=True,allowazero=False)
162
184
 
163
185
  def test_abs(self,n=1000,sim=False):
186
+ """
187
+ Test gummy abs.
188
+ """
164
189
  def f(a,b):
165
190
  return abs(a)*abs(b)
166
191
  def df(ax,bx):
@@ -174,6 +199,9 @@ class TestOperations(unittest.TestCase):
174
199
  allowbzero=lu)
175
200
 
176
201
  def test_neg(self,n=1000,sim=False):
202
+ """
203
+ Test gummy neg.
204
+ """
177
205
  def f(a,b):
178
206
  return (-a)*b
179
207
  def df(ax,bx):
@@ -182,6 +210,9 @@ class TestOperations(unittest.TestCase):
182
210
  self.binary_func(f,df,sim=sim)
183
211
 
184
212
  def test_pos(self,n=1000,sim=False):
213
+ """
214
+ Test gummy pos.
215
+ """
185
216
  def f(a,b):
186
217
  return (+a)*b
187
218
  def df(ax,bx):
@@ -190,6 +221,9 @@ class TestOperations(unittest.TestCase):
190
221
  self.binary_func(f,df,sim=sim)
191
222
 
192
223
  def test_sincos(self,n=1000,sim=False):
224
+ """
225
+ Test gummy metrolopy.sin + metrolopy.cos.
226
+ """
193
227
  def f(a,b):
194
228
  return uc.sin(a) + uc.cos(b)
195
229
  def df(ax,bx):
@@ -198,6 +232,9 @@ class TestOperations(unittest.TestCase):
198
232
  self.binary_func(f,df,sim=sim)
199
233
 
200
234
  def test_npsincos(self,n=1000,sim=False):
235
+ """
236
+ Test gummy numpy.sin + numpy.cos.
237
+ """
201
238
  def f(a,b):
202
239
  return np.sin(a) + np.cos(b)
203
240
  def df(ax,bx):
@@ -206,6 +243,9 @@ class TestOperations(unittest.TestCase):
206
243
  self.binary_func(f,df,sim=sim,fionly=True)
207
244
 
208
245
  def test_ap1sincos(self,n=1000,sim=False):
246
+ """
247
+ Test gummy.apply(numpy.sin) + gummy.apply(numpy.cos).
248
+ """
209
249
  def f(a,b):
210
250
  return uc.gummy.apply(np.sin,np.cos,a) + uc.gummy.napply(np.cos,b)
211
251
  def df(ax,bx):
@@ -214,6 +254,9 @@ class TestOperations(unittest.TestCase):
214
254
  self.binary_func(f,df,sim=sim,fionly=True,exp=0,allowlargeu=False)
215
255
 
216
256
  def test_ap2sincos(self,n=1000,sim=False):
257
+ """
258
+ Test gummy.apply(numpy.sin + numpy.cos).
259
+ """
217
260
  def ff(a,b):
218
261
  return np.sin(a) + np.cos(b)
219
262
  def df(ax,bx):
@@ -225,6 +268,9 @@ class TestOperations(unittest.TestCase):
225
268
  self.binary_func(f,df,sim=sim,fionly=True)
226
269
 
227
270
  def test_apnsincos(self,n=1000,sim=False):
271
+ """
272
+ Test gummy.napply(numpy.sin + numpy.cos).
273
+ """
228
274
  def ff(a,b):
229
275
  return np.sin(a) + np.cos(b)
230
276
  def df(ax,bx):
@@ -236,6 +282,9 @@ class TestOperations(unittest.TestCase):
236
282
  self.binary_func(f,df,sim=sim,fionly=True,exp=0,allowlargeu=False)
237
283
 
238
284
  def test_addxmul(self,n=1000):
285
+ """
286
+ Check that x+x+x+...+x == n*x for gummy values.
287
+ """
239
288
  def f(*x):
240
289
  r = x[0]
241
290
  for i in range(len(x)-1):
@@ -283,6 +332,9 @@ class TestOperations(unittest.TestCase):
283
332
  self.assertTrue(abs(d.correlation(b) - 1) < 1e-14)
284
333
 
285
334
  def test_mulxpow(self,n=1000):
335
+ """
336
+ Check that x*x*x*...*x == x**n for gummy values.
337
+ """
286
338
  def f(*x):
287
339
  r = x[0]
288
340
  for i in range(len(x)-1):
@@ -336,6 +388,9 @@ class TestOperations(unittest.TestCase):
336
388
 
337
389
 
338
390
  def test_mulxnpow(self,n=1000):
391
+ """
392
+ Check that (1/x)*(1/x)*(1/x)*...*(1/x) == x**-n for gummy values.
393
+ """
339
394
  def f(*x):
340
395
  r = 1/x[0]
341
396
  for i in range(len(x)-1):
@@ -28,6 +28,9 @@ from metrolopy.tests.common import rand,make_gummy
28
28
 
29
29
  class TestUbreakdown(unittest.TestCase):
30
30
  def test_ubreakdown(self,n=None,prnt=False,budget=False):
31
+ """
32
+ Test gummy.ubreakdown and the budget class.
33
+ """
31
34
  uc.gummy.p_method = None
32
35
 
33
36
  if n is None:
@@ -627,7 +627,7 @@ class ummy(Dfunc,PrettyPrinter,Number,metaclass=MetaUmmy):
627
627
  """
628
628
  Returns the variance-covariance matrix of a list or array of ummys.
629
629
  """
630
- return [[b.covariance(a) if isinstance(b,ummy) else 0 for b in gummys]
630
+ return [[float(b.covariance(a)) if isinstance(b,ummy) else 0 for b in gummys]
631
631
  for a in gummys]
632
632
 
633
633
  @classmethod
@@ -20,4 +20,4 @@
20
20
  # You should have received a copy of the GNU General Public License along with
21
21
  # MetroloPy. If not, see <http://www.gnu.org/licenses/>.
22
22
 
23
- __version__ = '1.0.0'
23
+ __version__ = '1.0.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: metrolopy
3
- Version: 1.0.0
3
+ Version: 1.0.1
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
@@ -41,7 +41,7 @@ tools for dealing with physical quantities: uncertainty propagation and unit co
41
41
 
42
42
  ---
43
43
 
44
- MetroloPy is a pure python package and requires Python 3.5 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
44
+ MetroloPy is a pure python package and requires Python 3.6 or later and the SciPy stack (NumPy, SciPy and Pandas). It looks best in a Jupyter Notebook.
45
45
 
46
46
  Install MetroloPy with `pip install metrolopy` or
47
47
  `conda install -c conda-forge metrolopy`.
@@ -67,8 +67,8 @@ Physical quantities can then be represented in Python as `gummy` objects with an
67
67
 
68
68
  MetroloPy can do much more including Monte-Carlo uncertainty propagation, generating uncertainty budget tables, and curve fitting. It can also handle expanded uncertainties, degrees of freedom, correlated quantities, and complex valued quantities. See:
69
69
 
70
- * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" download> download the tutorial as Jupyter notebook</a>)
71
- * [the documentation](https://nrc-cnrc.github.io/MetroloPy/)
70
+ * [a tutorial](https://nrc-cnrc.github.io/MetroloPy/_build/html/_static/tutorial.html) (or <a href="https://nrc-cnrc.github.io/MetroloPy/_build/html/_downloads/tutorial.ipynb" target="_blank"> download the tutorial as Jupyter notebook</a>)
71
+ * [the documentation](https://nrc-cnrc.github.io/MetroloPy/_build/html/index.html)
72
72
  * [the issues page on GitHub](https://github.com/nrc-cnrc/Metrolopy/issues)
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)
@@ -79,14 +79,14 @@ MetroloPy can do much more including Monte-Carlo uncertainty propagation, genera
79
79
  previous versions, in a multi-step calculation, the effective degree of freedom
80
80
  were calculated at each step based on the degrees of freedom calculated for the
81
81
  previous step (using a modified Welch-Satterthwaite approximation). Now
82
- effective degrees of freedom are alway calculated directly from the independent
82
+ effective degrees of freedom are always calculated directly from the independent
83
83
  variables using the Welch-Satterthwaite equation.
84
84
 
85
85
  * CODATA 2022 values instead of 2018 values are used in the Constants module.
86
86
 
87
87
  * The significance value in budget table has been redefined from
88
88
  (sensitivity coefficient * standard uncertainty/combined uncertainty) to the
89
- square of that value so that the significance value sum to one.
89
+ square of that value so that the significance values in a budget sum to one.
90
90
 
91
91
  * Units can now be raised to a fractional power and many other bug fixes.
92
92
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes