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.
@@ -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
@@ -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
- dof = float('inf')
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 dof == float('inf'):
296
- self.assertTrue(g.dof == float('inf'))
297
- else:
298
- self.assertTrue((g.dof - dof)/dof < 1e-6)
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))
@@ -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.NoUnitConversionFoundError:
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.NoUnitConversionFoundError:
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,'A'])
657
- self.assertTrue(abs(d.ufrom('A',sim=True) - np.sqrt(0.2**2+0.5**2)) < 1e-2)
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):
@@ -103,6 +103,7 @@ class TestMisc(unittest.TestCase):
103
103
  return t.ppf(1-(1-con)/2, len(x)-1)*x.std(ddof=1)/np.sqrt(len(x))
104
104
 
105
105
  x = np.random.rand(5)
106
+ uc.gummy.bayesian = False
106
107
  g = uc.mean(x)
107
108
  g.p = 'ssd'
108
109
  self.assertTrue(abs(con-g.p) < 1e-6)
@@ -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 dof is not None and not np.isinf(dof):
89
- self.assertTrue(abs((g.dof - dof)/dof) < 0.01)
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.value._ref is q.value._ref:
73
+ if abs(gr.correlation(q)) == 1:
74
74
  ut = q.utype
75
- self.assertTrue(gr.utype is ut)
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)