metrolopy 0.6.5__py3-none-any.whl → 1.0.0__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.
- metrolopy/__init__.py +5 -4
- metrolopy/budget.py +61 -50
- metrolopy/builtin_constants.py +903 -0
- metrolopy/constant.py +108 -104
- metrolopy/constcom.py +84 -83
- metrolopy/distributions.py +120 -39
- metrolopy/exceptions.py +7 -9
- metrolopy/fit.py +3 -3
- metrolopy/functions.py +4 -4
- metrolopy/gummy.py +554 -514
- metrolopy/indexed.py +69 -20
- metrolopy/logunit.py +1 -1
- metrolopy/mean.py +8 -9
- metrolopy/miscunits.py +21 -6
- metrolopy/nummy.py +208 -158
- metrolopy/offsetunit.py +2 -3
- metrolopy/prefixedunit.py +24 -23
- metrolopy/relunits.py +1 -2
- metrolopy/siunits.py +7 -5
- metrolopy/tests/__init__.py +6 -6
- metrolopy/tests/test_create.py +7 -6
- metrolopy/tests/test_gummy.py +5 -43
- metrolopy/tests/test_misc.py +1 -0
- metrolopy/tests/test_operations.py +3 -2
- metrolopy/tests/test_ubreakdown.py +3 -2
- metrolopy/ummy.py +889 -897
- metrolopy/unit.py +287 -182
- metrolopy/unitparser.py +40 -42
- metrolopy/unitutils.py +183 -159
- metrolopy/usunits.py +14 -13
- metrolopy/version.py +1 -1
- {metrolopy-0.6.5.dist-info → metrolopy-1.0.0.dist-info}/METADATA +20 -2
- metrolopy-1.0.0.dist-info/RECORD +45 -0
- metrolopy-0.6.5.dist-info/RECORD +0 -44
- {metrolopy-0.6.5.dist-info → metrolopy-1.0.0.dist-info}/WHEEL +0 -0
- {metrolopy-0.6.5.dist-info → metrolopy-1.0.0.dist-info}/licenses/LICENSE +0 -0
- {metrolopy-0.6.5.dist-info → metrolopy-1.0.0.dist-info}/top_level.txt +0 -0
- {metrolopy-0.6.5.dist-info → metrolopy-1.0.0.dist-info}/zip-safe +0 -0
metrolopy/tests/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
|
-
from .test_create import
|
|
4
|
-
from .test_operations import
|
|
5
|
-
from .test_ubreakdown import
|
|
6
|
-
from .test_complex import
|
|
7
|
-
from .test_misc import
|
|
8
|
-
from .test_gummy import
|
|
3
|
+
from .test_create import TestCreate
|
|
4
|
+
from .test_operations import TestOperations
|
|
5
|
+
from .test_ubreakdown import TestUbreakdown
|
|
6
|
+
from .test_complex import TestComplex
|
|
7
|
+
from .test_misc import TestMisc
|
|
8
|
+
from .test_gummy import TestGummy
|
metrolopy/tests/test_create.py
CHANGED
|
@@ -161,8 +161,8 @@ class TestCreate(unittest.TestCase):
|
|
|
161
161
|
|
|
162
162
|
if rand.randint(10) == 0:
|
|
163
163
|
n = rand.randint(12)
|
|
164
|
-
if bayesian and n > 0:
|
|
165
|
-
|
|
164
|
+
#if bayesian and n > 0:
|
|
165
|
+
# dof = float('inf')
|
|
166
166
|
if n == 0:
|
|
167
167
|
nm = g.name
|
|
168
168
|
g = uc.gummy(g)
|
|
@@ -292,10 +292,11 @@ class TestCreate(unittest.TestCase):
|
|
|
292
292
|
|
|
293
293
|
self.assertTrue((g.x - x)/u < 1e-6)
|
|
294
294
|
|
|
295
|
-
if
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
if not uc.gummy.bayesian:
|
|
296
|
+
if dof == float('inf'):
|
|
297
|
+
self.assertTrue(g.dof == float('inf'))
|
|
298
|
+
else:
|
|
299
|
+
self.assertTrue((g.dof - dof)/dof < 1e-6)
|
|
299
300
|
|
|
300
301
|
if uunit is not None and uunit != unit:
|
|
301
302
|
self.assertTrue(g.uunit is uc.Unit.unit(uunit))
|
metrolopy/tests/test_gummy.py
CHANGED
|
@@ -35,18 +35,6 @@ class TestGummy(unittest.TestCase):
|
|
|
35
35
|
self.assertTrue(_ku(2.1,3.3) == 2.1*3.3)
|
|
36
36
|
self.assertTrue(_ku(2.1,Decimal(3.3)) == Decimal(float(2.1))*Decimal(3.3))
|
|
37
37
|
|
|
38
|
-
def test_lg10(self):
|
|
39
|
-
from metrolopy.gummy import _lg10
|
|
40
|
-
from mpmath import mpf,log10
|
|
41
|
-
from decimal import Decimal
|
|
42
|
-
from fractions import Fraction
|
|
43
|
-
import math
|
|
44
|
-
|
|
45
|
-
self.assertTrue(_lg10(mpf(2.2)) == log10(mpf(2.2)))
|
|
46
|
-
self.assertTrue(_lg10(Decimal(2.2)) == Decimal(2.2).log10())
|
|
47
|
-
self.assertTrue(_lg10(2.2) == np.log10(2.2))
|
|
48
|
-
self.assertTrue(_lg10(Fraction(2,3)) == math.log10(float(Fraction(2,3))))
|
|
49
|
-
|
|
50
38
|
def test_meta_properties(self):
|
|
51
39
|
a = uc.gummy.cimethod
|
|
52
40
|
self.assertTrue(isinstance(a,str))
|
|
@@ -217,7 +205,7 @@ class TestGummy(unittest.TestCase):
|
|
|
217
205
|
try:
|
|
218
206
|
uc.gummy(3.3,1.3,unit='%',uunit='m')
|
|
219
207
|
self.assertTrue(False)
|
|
220
|
-
except uc.
|
|
208
|
+
except uc.IncompatibleUnitsError:
|
|
221
209
|
pass
|
|
222
210
|
|
|
223
211
|
gg = uc.gummy(3.3,1.4,unit='%',uunit=uc.one)
|
|
@@ -252,7 +240,7 @@ class TestGummy(unittest.TestCase):
|
|
|
252
240
|
self.assertTrue(abs(c.U[1] - 4.4*1.1/3**2) < 1e-12)
|
|
253
241
|
|
|
254
242
|
def test_set_U(self):
|
|
255
|
-
g = uc.gummy(1,1,k=2,unit='cm',uunit='mm')
|
|
243
|
+
g = uc.gummy(1.0,1.0,k=2,unit='cm',uunit='mm')
|
|
256
244
|
self.assertTrue(g.U == 1)
|
|
257
245
|
self.assertTrue(g.uunit is uc.unit('mm'))
|
|
258
246
|
g.unit = 'm'
|
|
@@ -285,7 +273,7 @@ class TestGummy(unittest.TestCase):
|
|
|
285
273
|
try:
|
|
286
274
|
self.assertTrue(g._iset_U(unit='kg'))
|
|
287
275
|
self.assertTrue(False)
|
|
288
|
-
except uc.
|
|
276
|
+
except uc.IncompatibleUnitsError:
|
|
289
277
|
pass
|
|
290
278
|
|
|
291
279
|
g = uc.gummy(0,1,unit='m')
|
|
@@ -534,32 +522,6 @@ class TestGummy(unittest.TestCase):
|
|
|
534
522
|
self.assertTrue(a.covariance(a) == 1)
|
|
535
523
|
self.assertTrue(b.covariance(b) == 4)
|
|
536
524
|
|
|
537
|
-
def test_correlation_matrix(self):
|
|
538
|
-
a = uc.gummy(1,1)
|
|
539
|
-
b = uc.gummy(1,2)
|
|
540
|
-
c = a + b
|
|
541
|
-
m = uc.gummy.correlation_matrix([a,b,c])
|
|
542
|
-
self.assertTrue(m[0][0] == m[1][1] == m[2,2] == 1)
|
|
543
|
-
self.assertTrue(m[0][1] == m[1][0] == 0)
|
|
544
|
-
self.assertTrue(abs(m[2][0] - 1/c.u) < 1e-4)
|
|
545
|
-
self.assertTrue(abs(m[0][2] - 1/c.u) < 1e-4)
|
|
546
|
-
self.assertTrue(abs(m[2][1] - 2/c.u) < 1e-4)
|
|
547
|
-
self.assertTrue(abs(m[1][2] - 2/c.u) < 1e-4)
|
|
548
|
-
|
|
549
|
-
def test_covariance_matrix(self):
|
|
550
|
-
a = uc.gummy(1,1)
|
|
551
|
-
b = uc.gummy(1,2)
|
|
552
|
-
c = a + b
|
|
553
|
-
m = uc.gummy.covariance_matrix([a,b,c])
|
|
554
|
-
self.assertTrue(m[0][0] == 1)
|
|
555
|
-
self.assertTrue(m[1][1] == 4)
|
|
556
|
-
self.assertTrue(abs(m[2][2] - 5) < 1e-4)
|
|
557
|
-
self.assertTrue(m[0][1] == m[1][0] == 0)
|
|
558
|
-
self.assertTrue(abs(m[2][0] - 1) < 1e-4)
|
|
559
|
-
self.assertTrue(abs(m[0][2] - 1) < 1e-4)
|
|
560
|
-
self.assertTrue(abs(m[2][1] - 4) < 1e-4)
|
|
561
|
-
self.assertTrue(abs(m[1][2] - 4) < 1e-4)
|
|
562
|
-
|
|
563
525
|
def test_correlation_sim(self):
|
|
564
526
|
a = uc.gummy(1,1)
|
|
565
527
|
b = uc.gummy(1,2)
|
|
@@ -653,8 +615,8 @@ class TestGummy(unittest.TestCase):
|
|
|
653
615
|
c = uc.gummy(0.9,0.2,utype='B')
|
|
654
616
|
d = a + b + c
|
|
655
617
|
self.assertTrue(abs(d.ufrom('A') - np.sqrt(0.2**2+0.5**2)) < 1e-8)
|
|
656
|
-
uc.gummy.simulate([d,
|
|
657
|
-
self.assertTrue(abs(d.
|
|
618
|
+
uc.gummy.simulate([d,b])
|
|
619
|
+
self.assertTrue(abs(d.ufromsim('A') - np.sqrt(0.2**2+0.5**2)) < 1e-2)
|
|
658
620
|
self.assertTrue(d.ufrom(c) == 0.2)
|
|
659
621
|
|
|
660
622
|
def test_dof_from(self):
|
metrolopy/tests/test_misc.py
CHANGED
|
@@ -85,8 +85,9 @@ class TestOperations(unittest.TestCase):
|
|
|
85
85
|
else:
|
|
86
86
|
self.assertTrue(abs((g.u - u)/u) < 1e-3)
|
|
87
87
|
|
|
88
|
-
if
|
|
89
|
-
|
|
88
|
+
if not uc.gummy.bayesian:
|
|
89
|
+
if dof is not None and not np.isinf(dof):
|
|
90
|
+
self.assertTrue(abs((g.dof - dof)/dof) < 0.01)
|
|
90
91
|
|
|
91
92
|
self.assertTrue(a.correlation(b) == 0)
|
|
92
93
|
|
|
@@ -70,9 +70,10 @@ class TestUbreakdown(unittest.TestCase):
|
|
|
70
70
|
|
|
71
71
|
ut = None
|
|
72
72
|
for q in g:
|
|
73
|
-
if gr.
|
|
73
|
+
if abs(gr.correlation(q)) == 1:
|
|
74
74
|
ut = q.utype
|
|
75
|
-
|
|
75
|
+
if ut is not None:
|
|
76
|
+
self.assertTrue(gr.utype is ut)
|
|
76
77
|
|
|
77
78
|
x = list(x)
|
|
78
79
|
u = list(u)
|