metrolopy 0.6.5__py3-none-any.whl → 1.0.1__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.
@@ -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:
@@ -85,8 +89,9 @@ class TestOperations(unittest.TestCase):
85
89
  else:
86
90
  self.assertTrue(abs((g.u - u)/u) < 1e-3)
87
91
 
88
- if dof is not None and not np.isinf(dof):
89
- self.assertTrue(abs((g.dof - dof)/dof) < 0.01)
92
+ if not uc.gummy.bayesian:
93
+ if dof is not None and not np.isinf(dof):
94
+ self.assertTrue(abs((g.dof - dof)/dof) < 0.01)
90
95
 
91
96
  self.assertTrue(a.correlation(b) == 0)
92
97
 
@@ -103,6 +108,9 @@ class TestOperations(unittest.TestCase):
103
108
  self.assertTrue(abs((g.correlation_sim(b)-g.correlation(b))/g.correlation(b)) < 0.1)
104
109
 
105
110
  def test_add(self,n=1000,sim=False):
111
+ """
112
+ Test gummy addition.
113
+ """
106
114
  def f(a,b):
107
115
  return a + b
108
116
  def df(ax,bx):
@@ -111,6 +119,9 @@ class TestOperations(unittest.TestCase):
111
119
  self.binary_func(f,df,sim=sim)
112
120
 
113
121
  def test_sub(self,n=1000,sim=False):
122
+ """
123
+ Test gummy subtraction.
124
+ """
114
125
  def f(a,b):
115
126
  return a - b
116
127
  def df(ax,bx):
@@ -119,6 +130,9 @@ class TestOperations(unittest.TestCase):
119
130
  self.binary_func(f,df,sim=sim)
120
131
 
121
132
  def test_mul(self,n=1000,sim=False):
133
+ """
134
+ Test gummy multiplication.
135
+ """
122
136
  def f(a,b):
123
137
  return a*b
124
138
  def df(ax,bx):
@@ -127,6 +141,9 @@ class TestOperations(unittest.TestCase):
127
141
  self.binary_func(f,df,sim=sim)
128
142
 
129
143
  def test_div(self,n=1000,sim=False):
144
+ """
145
+ Test gummy division.
146
+ """
130
147
  def f(a,b):
131
148
  return a/b
132
149
  def df(ax,bx):
@@ -139,6 +156,9 @@ class TestOperations(unittest.TestCase):
139
156
  self.binary_func(f,df,sim=sim,allowbzero=False,allowlargeu=lu)
140
157
 
141
158
  def test_pow(self,n=1000,sim=False):
159
+ """
160
+ Test gummy exponentiation.
161
+ """
142
162
  def f(a,b):
143
163
  return abs(a)**b
144
164
  def df(ax,bx):
@@ -152,6 +172,9 @@ class TestOperations(unittest.TestCase):
152
172
  self.binary_func(f,df,sim=sim,exp=0,allowazero=False,allowlargeu=lu)
153
173
 
154
174
  def test_mod(self,n=1000,sim=False):
175
+ """
176
+ Test gummy mod.
177
+ """
155
178
  def f(a,b):
156
179
  return a%b
157
180
  def df(ax,bx):
@@ -160,6 +183,9 @@ class TestOperations(unittest.TestCase):
160
183
  self.binary_func(f,df,sim=sim,fionly=True,allowazero=False)
161
184
 
162
185
  def test_abs(self,n=1000,sim=False):
186
+ """
187
+ Test gummy abs.
188
+ """
163
189
  def f(a,b):
164
190
  return abs(a)*abs(b)
165
191
  def df(ax,bx):
@@ -173,6 +199,9 @@ class TestOperations(unittest.TestCase):
173
199
  allowbzero=lu)
174
200
 
175
201
  def test_neg(self,n=1000,sim=False):
202
+ """
203
+ Test gummy neg.
204
+ """
176
205
  def f(a,b):
177
206
  return (-a)*b
178
207
  def df(ax,bx):
@@ -181,6 +210,9 @@ class TestOperations(unittest.TestCase):
181
210
  self.binary_func(f,df,sim=sim)
182
211
 
183
212
  def test_pos(self,n=1000,sim=False):
213
+ """
214
+ Test gummy pos.
215
+ """
184
216
  def f(a,b):
185
217
  return (+a)*b
186
218
  def df(ax,bx):
@@ -189,6 +221,9 @@ class TestOperations(unittest.TestCase):
189
221
  self.binary_func(f,df,sim=sim)
190
222
 
191
223
  def test_sincos(self,n=1000,sim=False):
224
+ """
225
+ Test gummy metrolopy.sin + metrolopy.cos.
226
+ """
192
227
  def f(a,b):
193
228
  return uc.sin(a) + uc.cos(b)
194
229
  def df(ax,bx):
@@ -197,6 +232,9 @@ class TestOperations(unittest.TestCase):
197
232
  self.binary_func(f,df,sim=sim)
198
233
 
199
234
  def test_npsincos(self,n=1000,sim=False):
235
+ """
236
+ Test gummy numpy.sin + numpy.cos.
237
+ """
200
238
  def f(a,b):
201
239
  return np.sin(a) + np.cos(b)
202
240
  def df(ax,bx):
@@ -205,6 +243,9 @@ class TestOperations(unittest.TestCase):
205
243
  self.binary_func(f,df,sim=sim,fionly=True)
206
244
 
207
245
  def test_ap1sincos(self,n=1000,sim=False):
246
+ """
247
+ Test gummy.apply(numpy.sin) + gummy.apply(numpy.cos).
248
+ """
208
249
  def f(a,b):
209
250
  return uc.gummy.apply(np.sin,np.cos,a) + uc.gummy.napply(np.cos,b)
210
251
  def df(ax,bx):
@@ -213,6 +254,9 @@ class TestOperations(unittest.TestCase):
213
254
  self.binary_func(f,df,sim=sim,fionly=True,exp=0,allowlargeu=False)
214
255
 
215
256
  def test_ap2sincos(self,n=1000,sim=False):
257
+ """
258
+ Test gummy.apply(numpy.sin + numpy.cos).
259
+ """
216
260
  def ff(a,b):
217
261
  return np.sin(a) + np.cos(b)
218
262
  def df(ax,bx):
@@ -224,6 +268,9 @@ class TestOperations(unittest.TestCase):
224
268
  self.binary_func(f,df,sim=sim,fionly=True)
225
269
 
226
270
  def test_apnsincos(self,n=1000,sim=False):
271
+ """
272
+ Test gummy.napply(numpy.sin + numpy.cos).
273
+ """
227
274
  def ff(a,b):
228
275
  return np.sin(a) + np.cos(b)
229
276
  def df(ax,bx):
@@ -235,6 +282,9 @@ class TestOperations(unittest.TestCase):
235
282
  self.binary_func(f,df,sim=sim,fionly=True,exp=0,allowlargeu=False)
236
283
 
237
284
  def test_addxmul(self,n=1000):
285
+ """
286
+ Check that x+x+x+...+x == n*x for gummy values.
287
+ """
238
288
  def f(*x):
239
289
  r = x[0]
240
290
  for i in range(len(x)-1):
@@ -282,6 +332,9 @@ class TestOperations(unittest.TestCase):
282
332
  self.assertTrue(abs(d.correlation(b) - 1) < 1e-14)
283
333
 
284
334
  def test_mulxpow(self,n=1000):
335
+ """
336
+ Check that x*x*x*...*x == x**n for gummy values.
337
+ """
285
338
  def f(*x):
286
339
  r = x[0]
287
340
  for i in range(len(x)-1):
@@ -335,6 +388,9 @@ class TestOperations(unittest.TestCase):
335
388
 
336
389
 
337
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
+ """
338
394
  def f(*x):
339
395
  r = 1/x[0]
340
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:
@@ -70,9 +73,10 @@ class TestUbreakdown(unittest.TestCase):
70
73
 
71
74
  ut = None
72
75
  for q in g:
73
- if gr.value._ref is q.value._ref:
76
+ if abs(gr.correlation(q)) == 1:
74
77
  ut = q.utype
75
- self.assertTrue(gr.utype is ut)
78
+ if ut is not None:
79
+ self.assertTrue(gr.utype is ut)
76
80
 
77
81
  x = list(x)
78
82
  u = list(u)