metrolopy 0.6.2__py3-none-any.whl → 0.6.4__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.
@@ -3,380 +3,388 @@
3
3
  import metrolopy as uc
4
4
  import numpy as np
5
5
  import warnings
6
+ import unittest
6
7
 
7
8
  from metrolopy.tests.common import rand,display
8
9
 
9
-
10
- def test_gummy_init(n=None,exception_on_warning=True,prnt=False,plot=False):
11
- print('uc.gummy.p_method may be modified\nset uc.gummy.p_method = \'loc\' to recover the default value')
12
- from scipy.stats import norm, t
13
-
14
- uc.gummy.p_method = None
15
-
16
- if n is None:
17
- if prnt or plot:
18
- n = 100
19
- else:
20
- n = 10000
21
-
22
- units=['m','lb','m**2 s**3/kg**4','degF','cm','%','kg']
23
- uunits = {'%':100, 'ppm':1e6, 'ppb':1e9, 'ms/s':1000}
24
-
25
- with warnings.catch_warnings():
26
- if exception_on_warning:
27
- warnings.simplefilter('error')
28
- else:
29
- warnings.simplefilter('ignore')
30
-
31
- for i in range(n):
10
+ class TestCreate(unittest.TestCase):
11
+ def test_gummy_init(self,n=None,exception_on_warning=True,prnt=False,plot=False):
12
+ try:
13
+ from scipy.stats import norm, t
32
14
 
33
- if rand.randint(2):
34
- unit = units[rand.randint(len(units))]
35
- else:
36
- unit = uc.one
37
-
38
- if rand.randint(2):
39
- if unit == 'm':
40
- if rand.randint(2):
41
- uunit = 'mm'
42
- elif rand.randint(2):
43
- uunit = 'm'
44
- else:
45
- uunit = 'in'
46
- else:
47
- if unit in ['degF','dB(SPL)','Np']:
48
- uunit = None
49
- else:
50
- uunit = list(uunits.keys())[rand.randint(len(uunits))]
51
- else:
52
- uunit = None
15
+ uc.gummy.p_method = None
53
16
 
54
- bayesian = bool(rand.randint(2))
55
-
56
- if rand.randint(2):
57
- dof = rand.randint(3,20)
58
- else:
59
- dof = float('inf')
60
-
61
- if rand.randint(2):
62
- if rand.randint(2):
63
- k = 4*rand.rand() + 0.1
64
- p = None
17
+ if n is None:
18
+ if prnt or plot:
19
+ n = 100
65
20
  else:
66
- p = rand.rand()/2 + 0.49
67
- k = 1
68
- else:
69
- k = 1
70
- p = None
21
+ n = 10000
71
22
 
72
- if rand.randint(2):
73
- pmethods = ['loc','level of confidence','cp','coverage probability','gauss','ccp','ccp','conservative coverage probability','chebyshev']
74
- uc.gummy.p_method = pmethods[rand.randint(len(pmethods))]
75
- else:
76
- uc.gummy.p_method = None
23
+ units=['m','lb','m**2 s**3/kg**4','degF','cm','%','kg']
24
+ uunits = {'%':100, 'ppm':1e6, 'ppb':1e9, 'ms/s':1000}
77
25
 
78
- if unit == 'dB(SPL)':
79
- if rand.randint(10) == 0:
80
- x = rand.randint(-10,10)
81
- else:
82
- x = 100.0*(2*rand.rand() - 1)
83
- elif unit == 'Np':
84
- if rand.randint(10) == 0:
85
- x = rand.randint(-10,10)
86
- else:
87
- x = 20.0*(2*rand.rand() - 1)
88
- else:
89
- if rand.randint(10) == 0:
90
- x = rand.randint(-60000,60000)
91
- else:
92
- x = (2*rand.rand() - 1)*10.0**rand.randint(-10,10)
93
- if rand.randint(20) == 0:
94
- x = 0
95
-
96
- if uunit in ['%','ppm','ppb','ms/s'] and not (unit == '%' and uunit == '%'):
97
- U = 1.0e3*rand.rand()
98
- u = abs(x)*U/uunits[uunit]
99
- elif unit == 'm' and uunit == 'mm':
100
- if x == 0:
101
- U = 1.0e3*rand.rand()
26
+ with warnings.catch_warnings():
27
+ if exception_on_warning:
28
+ warnings.simplefilter('error')
102
29
  else:
103
- U = abs(x)*1.0e3*rand.rand()
104
- u = U/1000
105
- elif unit == 'm' and uunit == 'in':
106
- if x == 0:
107
- U = 100*rand.rand()
108
- else:
109
- U = abs(x)*100*rand.rand()
110
- u = U*0.0254
111
- else:
112
- if x == 0:
113
- U = 1.0e12*rand.rand()
114
- else:
115
- if rand.randint(20) == 0:
116
- U = 1e6*abs(x)*rand.rand()
117
- elif rand.randint(20) == 0:
118
- U = rand.randint(20)+1
119
- else:
120
- U = 1.1*abs(x)*rand.rand()
121
- u = U
122
-
123
- if rand.randint(2):
124
- name = chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65)
125
- else:
126
- name = None
127
-
128
- if rand.randint(2):
129
- utype = chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65)
130
- else:
131
- utype = None
132
-
133
- if rand.randint(20) == 0:
134
- assert uc.gummy(x) == x
135
- continue
30
+ warnings.simplefilter('ignore')
136
31
 
137
- if rand.randint(20) == 0:
138
- const = True
139
- U = 0
140
- u = 0
141
- else:
142
- if u == 0:
143
- const = True
144
- else:
145
- const = False
146
-
147
- uc.gummy.bayesian = bayesian
148
- if uunit is not None and rand.randint(2):
149
- uu = uc.gummy(U,unit=uunit)
150
- g = uc.gummy(x,u=uu,unit=unit,dof=dof,k=k,p=p,name=name,
151
- utype=utype)
152
- else:
153
- g = uc.gummy(x,u=U,unit=unit,dof=dof,k=k,p=p,uunit=uunit,
154
- name=name,utype=utype)
155
-
156
- if not const:
157
- u = u/g.k
158
-
159
- orig_g = g
160
-
161
- if rand.randint(10) == 0:
162
- n = rand.randint(12)
163
- if bayesian and n > 0:
164
- dof = float('inf')
165
- if n == 0:
166
- g = uc.gummy(g)
167
- assert g.name is None
168
- elif n == 1:
169
- if unit == 'degF':
170
- g = g + uc.gummy(0,unit='degF-i')
32
+ for i in range(n):
33
+
34
+ if rand.randint(2):
35
+ unit = units[rand.randint(len(units))]
171
36
  else:
172
- g = 1*g
173
- elif n == 2:
174
- if unit == 'degF':
175
- g = g + uc.gummy(0,unit='degF-i')
37
+ unit = uc.one
38
+
39
+ if rand.randint(2):
40
+ if unit == 'm':
41
+ if rand.randint(2):
42
+ uunit = 'mm'
43
+ elif rand.randint(2):
44
+ uunit = 'm'
45
+ else:
46
+ uunit = 'in'
47
+ else:
48
+ if unit in ['degF','dB(SPL)','Np']:
49
+ uunit = None
50
+ else:
51
+ uunit = list(uunits.keys())[rand.randint(len(uunits))]
176
52
  else:
177
- g = g*1
178
- elif n == 3:
179
- if unit == 'degF':
180
- g = g + uc.gummy(0,unit='degF-i')
53
+ uunit = None
54
+
55
+ bayesian = bool(rand.randint(2))
56
+
57
+ if rand.randint(2):
58
+ dof = rand.randint(3,20)
181
59
  else:
182
- g = g/1
183
- elif n == 4:
184
- if unit == 'degF':
185
- v = uc.gummy(0,unit='degF-i')
186
- elif unit is not uc.one or rand.randint(2):
187
- v = uc.gummy(0,unit=unit)
60
+ dof = float('inf')
61
+
62
+ if rand.randint(2):
63
+ if rand.randint(2):
64
+ k = 4*rand.rand() + 0.1
65
+ p = None
66
+ else:
67
+ p = rand.rand()/2 + 0.49
68
+ k = 1
188
69
  else:
189
- v = 0
190
- g = g + v
191
- elif n == 5:
192
- if unit == 'degF':
193
- v = uc.gummy(0,unit='degF-i')
194
- elif unit is not uc.one or rand.randint(2):
195
- v = uc.gummy(0,unit=unit)
70
+ k = 1
71
+ p = None
72
+
73
+ if rand.randint(2):
74
+ pmethods = ['loc','level of confidence','cp','coverage probability','gauss','ccp','ccp','conservative coverage probability','chebyshev']
75
+ uc.gummy.p_method = pmethods[rand.randint(len(pmethods))]
196
76
  else:
197
- v = 0
198
- g = v + g
199
- elif n == 6:
200
- if unit == 'degF':
201
- v = uc.gummy(0,unit='degF-i')
202
- elif unit is not uc.one or rand.randint(2):
203
- v = uc.gummy(0,unit=unit)
77
+ uc.gummy.p_method = None
78
+
79
+ if unit == 'dB(SPL)':
80
+ if rand.randint(10) == 0:
81
+ x = rand.randint(-10,10)
82
+ else:
83
+ x = 100.0*(2*rand.rand() - 1)
84
+ elif unit == 'Np':
85
+ if rand.randint(10) == 0:
86
+ x = rand.randint(-10,10)
87
+ else:
88
+ x = 20.0*(2*rand.rand() - 1)
204
89
  else:
205
- v = 0
206
- g = g - v
207
- elif n == 7:
208
- if unit == 'degF':
209
- g = g + uc.gummy(0,unit='degF-i')
210
- elif unit in ['dB(SPL)','Np']:
211
- g = g + uc.gummy(0,unit=unit)
90
+ if rand.randint(10) == 0:
91
+ x = rand.randint(-60000,60000)
92
+ else:
93
+ x = (2*rand.rand() - 1)*10.0**rand.randint(-10,10)
94
+ if rand.randint(20) == 0:
95
+ x = 0
96
+
97
+ if uunit in ['%','ppm','ppb','ms/s'] and not (unit == '%' and uunit == '%'):
98
+ U = 1.0e3*rand.rand()
99
+ u = abs(x)*U/uunits[uunit]
100
+ elif unit == 'm' and uunit == 'mm':
101
+ if x == 0:
102
+ U = 1.0e3*rand.rand()
103
+ else:
104
+ U = abs(x)*1.0e3*rand.rand()
105
+ u = U/1000
106
+ elif unit == 'm' and uunit == 'in':
107
+ if x == 0:
108
+ U = 100*rand.rand()
109
+ else:
110
+ U = abs(x)*100*rand.rand()
111
+ u = U*0.0254
212
112
  else:
213
- g = g**1
214
- elif n == 8:
215
- if unit == 'degF':
216
- g = g + uc.gummy(0,unit='degF-i')
113
+ if x == 0:
114
+ U = 1.0e12*rand.rand()
115
+ else:
116
+ if rand.randint(20) == 0:
117
+ U = 1e6*abs(x)*rand.rand()
118
+ elif rand.randint(20) == 0:
119
+ U = rand.randint(20)+1
120
+ else:
121
+ U = 1.1*abs(x)*rand.rand()
122
+ u = U
123
+
124
+ if rand.randint(2):
125
+ name = chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65)
217
126
  else:
218
- g = +g
219
- elif n == 9:
220
- if unit == 'degF':
221
- g = g + uc.gummy(0,unit='degF-i')
127
+ name = None
128
+
129
+ if rand.randint(2):
130
+ utype = chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65) + chr(rand.randint(20) + 65)
222
131
  else:
223
- g = 2.1*g
224
- g = g/2.1
225
- elif n == 10:
226
- if unit == 'degF':
227
- g = g + uc.gummy(0,unit='degF-i')
132
+ utype = None
133
+
134
+ if rand.randint(20) == 0:
135
+ self.assertTrue(uc.gummy(x) == x)
136
+ continue
137
+
138
+ if rand.randint(20) == 0:
139
+ const = True
140
+ U = 0
141
+ u = 0
228
142
  else:
229
- if unit is not uc.one or rand.randint(2):
230
- v = uc.gummy(3.5*x,u=0.45*u,unit=unit)
143
+ if u == 0:
144
+ const = True
231
145
  else:
232
- v = 3.3*x
233
- g = v - g
234
- g = g - v
235
- g = -g
236
- else:
237
- if unit == 'degF':
238
- g = g + uc.gummy(0,unit='degF-i')
146
+ const = False
147
+
148
+ uc.gummy.bayesian = bayesian
149
+ if uunit is not None and rand.randint(2):
150
+ uu = uc.gummy(U,unit=uunit)
151
+ g = uc.gummy(x,u=uu,unit=unit,dof=dof,k=k,p=p,name=name,
152
+ utype=utype)
239
153
  else:
240
- if x >= 0:
241
- g = abs(g)
154
+ g = uc.gummy(x,u=U,unit=unit,dof=dof,k=k,p=p,uunit=uunit,
155
+ name=name,utype=utype)
156
+
157
+ if not const:
158
+ u = u/g.k
159
+
160
+ orig_g = g
161
+
162
+ if rand.randint(10) == 0:
163
+ n = rand.randint(12)
164
+ if bayesian and n > 0:
165
+ dof = float('inf')
166
+ if n == 0:
167
+ nm = g.name
168
+ g = uc.gummy(g)
169
+ self.assertTrue(g.name is nm)
170
+ g.name = None
171
+ elif n == 1:
172
+ if unit == 'degF':
173
+ g = g + uc.gummy(0,unit='degF-i')
174
+ else:
175
+ g = 1*g
176
+ elif n == 2:
177
+ if unit == 'degF':
178
+ g = g + uc.gummy(0,unit='degF-i')
179
+ else:
180
+ g = g*1
181
+ elif n == 3:
182
+ if unit == 'degF':
183
+ g = g + uc.gummy(0,unit='degF-i')
184
+ else:
185
+ g = g/1
186
+ elif n == 4:
187
+ if unit == 'degF':
188
+ v = uc.gummy(0,unit='degF-i')
189
+ elif unit is not uc.one or rand.randint(2):
190
+ v = uc.gummy(0,unit=unit)
191
+ else:
192
+ v = 0
193
+ g = g + v
194
+ elif n == 5:
195
+ if unit == 'degF':
196
+ v = uc.gummy(0,unit='degF-i')
197
+ elif unit is not uc.one or rand.randint(2):
198
+ v = uc.gummy(0,unit=unit)
199
+ else:
200
+ v = 0
201
+ g = v + g
202
+ elif n == 6:
203
+ if unit == 'degF':
204
+ v = uc.gummy(0,unit='degF-i')
205
+ elif unit is not uc.one or rand.randint(2):
206
+ v = uc.gummy(0,unit=unit)
207
+ else:
208
+ v = 0
209
+ g = g - v
210
+ elif n == 7:
211
+ if unit == 'degF':
212
+ g = g + uc.gummy(0,unit='degF-i')
213
+ elif unit in ['dB(SPL)','Np']:
214
+ g = g + uc.gummy(0,unit=unit)
215
+ else:
216
+ g = g**1
217
+ elif n == 8:
218
+ if unit == 'degF':
219
+ g = g + uc.gummy(0,unit='degF-i')
220
+ else:
221
+ g = +g
222
+ elif n == 9:
223
+ if unit == 'degF':
224
+ g = g + uc.gummy(0,unit='degF-i')
225
+ else:
226
+ g = 2.1*g
227
+ g = g/2.1
228
+ elif n == 10:
229
+ if unit == 'degF':
230
+ g = g + uc.gummy(0,unit='degF-i')
231
+ else:
232
+ if unit is not uc.one or rand.randint(2):
233
+ v = uc.gummy(3.5*x,u=0.45*u,unit=unit)
234
+ else:
235
+ v = 3.3*x
236
+ g = v - g
237
+ g = g - v
238
+ g = -g
242
239
  else:
243
- g = -abs(g)
244
-
245
- k = 1
246
- p = None
247
- reinit = True
248
- uunit = None
249
- name = None
250
- else:
251
- reinit = False
252
-
253
- if x != 0 and g.x != 0:
254
- assert abs(g.x - x)/abs(x) < 1e-10
255
- else:
256
- assert abs(g.x - x) < 1e-10
257
-
258
- if x != 0 and g.x != 0:
259
- assert abs(g.x - x)/abs(x) < 1e-10
260
- else:
261
- assert abs(g.x - x) < 1e-10
262
-
263
- if unit == 'degF':
264
- assert g.unit in [uc.Unit.unit('degF'),uc.Unit.unit('degF-i')]
265
- else:
266
- assert g.unit is uc.Unit.unit(unit)
267
- assert g.name == name
240
+ if unit == 'degF':
241
+ g = g + uc.gummy(0,unit='degF-i')
242
+ else:
243
+ if x >= 0:
244
+ g = abs(g)
245
+ else:
246
+ g = -abs(g)
268
247
 
269
- if const:
270
- assert g.u == 0
271
- if unit is uc.one:
272
- if x == 0:
273
- assert abs(g - x) < 1e-10
274
- else:
275
- assert abs(g - x)/x < 1e-10
276
- elif unit == '%':
277
- if x == 0:
278
- assert abs(g - x/100) < 1e-10
248
+ k = 1
249
+ p = None
250
+ reinit = True
251
+ uunit = None
252
+ name = None
279
253
  else:
280
- assert abs((g - x/100)/(x/100)) < 1e-10
281
- elif unit == 'Np':
282
- assert abs(g.convert(1) - np.exp(x))/np.exp(x) < 1e-10
283
- continue
284
-
285
- if uunit in ['%','ppm','ppb','dB','ms/s'] and unit != uunit:
286
- assert g.uunit_is_rel
287
- else:
288
- assert not g.uunit_is_rel
289
-
290
- assert (g.x - x)/u < 1e-6
291
-
292
- if dof == float('inf'):
293
- assert g.dof == float('inf')
294
- else:
295
- assert (g.dof - dof)/dof < 1e-6
254
+ reinit = False
296
255
 
297
- if uunit is not None and uunit != unit:
298
- assert g.uunit is uc.Unit.unit(uunit)
299
-
300
- if g.p == 0:
301
- assert p is None
302
- assert k <= 3
303
- else:
304
- if p is None:
305
- assert g.k == k
306
- else:
307
- assert g.p == p
308
-
309
- if uc.gummy.p_method in ['loc','level of confidence',None]:
256
+ if x != 0 and g.x != 0:
257
+ self.assertTrue(abs(g.x - x)/abs(x) < 1e-10)
258
+ else:
259
+ self.assertTrue(abs(g.x - x) < 1e-10)
260
+
261
+ if x != 0 and g.x != 0:
262
+ self.assertTrue(abs(g.x - x)/abs(x) < 1e-10)
263
+ else:
264
+ self.assertTrue(abs(g.x - x) < 1e-10)
265
+
266
+ if unit == 'degF':
267
+ self.assertTrue(g.unit in [uc.Unit.unit('degF'),uc.Unit.unit('degF-i')])
268
+ else:
269
+ self.assertTrue(g.unit is uc.Unit.unit(unit))
270
+ self.assertTrue(g.name == name)
271
+
272
+ if const:
273
+ self.assertTrue(g.u == 0)
274
+ if unit is uc.one:
275
+ if x == 0:
276
+ self.assertTrue(abs(g - x) < 1e-10)
277
+ else:
278
+ self.assertTrue(abs(g - x)/x < 1e-10)
279
+ elif unit == '%':
280
+ if x == 0:
281
+ self.assertTrue(abs(g - x/100) < 1e-10)
282
+ else:
283
+ self.assertTrue(abs((g - x/100)/(x/100)) < 1e-10)
284
+ elif unit == 'Np':
285
+ self.assertTrue(abs(g.convert(1) - np.exp(x))/np.exp(x) < 1e-10)
286
+ continue
287
+
288
+ if uunit in ['%','ppm','ppb','dB','ms/s'] and unit != uunit:
289
+ self.assertTrue(g.uunit_is_rel)
290
+ else:
291
+ self.assertTrue(not g.uunit_is_rel)
292
+
293
+ self.assertTrue((g.x - x)/u < 1e-6)
294
+
310
295
  if dof == float('inf'):
311
- assert abs(g.k - norm.ppf(0.5 + g.p/2)) < 1e-6
296
+ self.assertTrue(g.dof == float('inf'))
297
+ else:
298
+ self.assertTrue((g.dof - dof)/dof < 1e-6)
299
+
300
+ if uunit is not None and uunit != unit:
301
+ self.assertTrue(g.uunit is uc.Unit.unit(uunit))
302
+
303
+ if g.p == 0:
304
+ self.assertTrue(p is None)
305
+ self.assertTrue(k <= 3)
312
306
  else:
313
- if bayesian:
314
- if g.p is not None:
315
- assert abs(g.k - np.sqrt((dof-2)/dof)*t.ppf(0.5 + g.p/2,dof)) < 1e-6
307
+ if p is None:
308
+ self.assertTrue(g.k == k)
316
309
  else:
317
- assert abs(g.k - t.ppf(0.5 + g.p/2,dof)) < 1e-6
310
+ self.assertTrue(g.p == p)
311
+
312
+ if uc.gummy.p_method in ['loc','level of confidence',None]:
313
+ if dof == float('inf'):
314
+ self.assertTrue(abs(g.k - norm.ppf(0.5 + g.p/2)) < 1e-6)
315
+ else:
316
+ if bayesian:
317
+ if g.p is not None:
318
+ self.assertTrue(abs(g.k - np.sqrt((dof-2)/dof)*t.ppf(0.5 + g.p/2,dof)) < 1e-6)
319
+ else:
320
+ self.assertTrue(abs(g.k - t.ppf(0.5 + g.p/2,dof)) < 1e-6)
321
+
322
+ elif uc.gummy.p_method in ['cp','coverage probability','gauss']:
323
+ if dof == float('inf') or bayesian:
324
+ if g.p is not None:
325
+ self.assertTrue(abs(g.k - 2/(3*(np.sqrt(1 - g.p)))) < 1e-6)
326
+ else:
327
+ if g.p is not None:
328
+ self.assertTrue(abs(g.k - np.sqrt(dof/(dof-2))*(2/(3*(np.sqrt(1 - g.p))))) < 1e-6)
329
+ else:
330
+ if dof == float('inf') or bayesian:
331
+ if g.p is not None:
332
+ self.assertTrue(abs(g.k - 1/np.sqrt(1 - g.p)) < 10.0**-6)
333
+ else:
334
+ if g.p is not None:
335
+ self.assertTrue(abs(g.k - np.sqrt(dof/(dof-2))*(1/np.sqrt(1 - g.p))) < 1e-6)
318
336
 
319
- elif uc.gummy.p_method in ['cp','coverage probability','gauss']:
320
- if dof == float('inf') or bayesian:
321
- if g.p is not None:
322
- assert abs(g.k - 2/(3*(np.sqrt(1 - g.p)))) < 1e-6
323
- else:
324
- if g.p is not None:
325
- assert abs(g.k - np.sqrt(dof/(dof-2))*(2/(3*(np.sqrt(1 - g.p))))) < 1e-6
326
- else:
327
- if dof == float('inf') or bayesian:
328
- if g.p is not None:
329
- assert abs(g.k - 1/np.sqrt(1 - g.p)) < 10.0**-6
330
- else:
331
- if g.p is not None:
332
- assert abs(g.k - np.sqrt(dof/(dof-2))*(1/np.sqrt(1 - g.p))) < 1e-6
337
+ self.assertTrue(abs((g.u - u)/u) < 1e-10)
333
338
 
334
- assert abs((g.u - u)/u) < 1e-10
335
-
336
- if not reinit:
337
- assert abs(g.U - U)/U < 1e-10
338
-
339
- assert abs((g.u - u)/u) < 1e-10
340
-
341
- assert '?' not in g.tostring()
342
-
343
- if prnt:
344
- print('------')
345
- print()
346
- if rand.randint(2):
347
- styles = ['pm','pmi','concise','ueq','x','xf','u','uf','xunit','uunit']
348
- g.style = styles[rand.randint(10)]
339
+ if not reinit:
340
+ self.assertTrue(abs(g.U - U)/U < 1e-10)
349
341
 
350
- g.show_k = bool(rand.randint(2))
351
- g.show_dof = bool(rand.randint(2))
352
- g.show_p = bool(rand.randint(2))
353
- g.show_name = bool(rand.randint(2))
354
- g.solidus = bool(rand.randint(2))
355
- g.mulsep = bool(rand.randint(2))
356
- if not rand.randint(5):
357
- g.nsig = rand.randint(5) + 1
342
+ self.assertTrue(abs((g.u - u)/u) < 1e-10)
358
343
 
359
- assert '?' not in g.tostring()
360
- print(g.style,', show_k=',g.show_k,', show_dof=',g.show_dof,', show_p=',g.show_p,', show_name=',g.show_name,', solidus=',g.solidus,', mulsep=',g.mulsep,', nsig=',g.nsig,':')
361
- print()
362
- display(g)
363
- print()
344
+ self.assertTrue('?' not in g.tostring())
364
345
 
365
- if plot:
366
- print('------')
367
- print()
368
- print(g)
369
- g.sim()
370
- if rand.randint(2):
371
- styles = ['pmsim','pmsimi','mcisim','cisim','usim','ufsim']
372
- g.style = styles[rand.randint(6)]
373
- g.slashaxis = bool(rand.randint(2))
374
- print(g.style,', slashaxis=',g.slashaxis,':')
375
- print()
376
- display(g)
377
- print()
378
- g.hist()
379
- print()
380
-
381
- uc.gummy.bayesian = False
346
+ if prnt:
347
+ print('------')
348
+ print()
349
+ if rand.randint(2):
350
+ styles = ['pm','pmi','concise','ueq','x','xf','u','uf','xunit','uunit']
351
+ g.style = styles[rand.randint(10)]
352
+
353
+ g.show_k = bool(rand.randint(2))
354
+ g.show_dof = bool(rand.randint(2))
355
+ g.show_p = bool(rand.randint(2))
356
+ g.show_name = bool(rand.randint(2))
357
+ g.solidus = bool(rand.randint(2))
358
+ g.mulsep = bool(rand.randint(2))
359
+ if not rand.randint(5):
360
+ g.nsig = rand.randint(5) + 1
361
+
362
+ self.assertTrue('?' not in g.tostring())
363
+ print(g.style,', show_k=',g.show_k,', show_dof=',g.show_dof,', show_p=',g.show_p,', show_name=',g.show_name,', solidus=',g.solidus,', mulsep=',g.mulsep,', nsig=',g.nsig,':')
364
+ print()
365
+ display(g)
366
+ print()
367
+
368
+ if plot:
369
+ print('------')
370
+ print()
371
+ print(g)
372
+ g.sim()
373
+ if rand.randint(2):
374
+ styles = ['pmsim','pmsimi','mcisim','cisim','usim','ufsim']
375
+ g.style = styles[rand.randint(6)]
376
+ g.slashaxis = bool(rand.randint(2))
377
+ print(g.style,', slashaxis=',g.slashaxis,':')
378
+ print()
379
+ display(g)
380
+ print()
381
+ g.hist()
382
+ print()
383
+
384
+ uc.gummy.bayesian = False
385
+ finally:
386
+ uc.gummy.p_method = 'loc'
387
+
382
388
 
389
+ if __name__ == '__main__':
390
+ unittest.main()