Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_missing(self):
with self.assertRaises(ValueError):
parse_var_dims(None)
def test_parse_empty(self):
x = []
vars_dict = parse_var_dims(x)
self.assertEqual(len(vars_dict), 0)
x = [
'foo',
'phi.1.1',
'phi.1.2',
'phi.1.3',
'phi.1.4',
'phi.1.5',
'phi.2.1',
'phi.2.2',
'phi.2.3',
'phi.2.4',
'phi.2.5',
'bar.1',
'bar.2',
]
vars_dict = parse_var_dims(x)
self.assertEqual(len(vars_dict), 3)
self.assertEqual(vars_dict['foo'], 1)
self.assertEqual(vars_dict['phi'], [2, 5])
self.assertEqual(vars_dict['bar'], [2])
def test_parse_scalar(self):
x = ['foo']
vars_dict = parse_var_dims(x)
self.assertEqual(len(vars_dict), 1)
self.assertEqual(vars_dict['foo'], 1)
def test_parse_scalar_vec_scalar(self):
x = [
'foo',
'phi.1',
'phi.2',
'phi.3',
'phi.4',
'phi.5',
'phi.6',
'phi.7',
'phi.8',
'phi.9',
'phi.10',
'bar',
]
vars_dict = parse_var_dims(x)
self.assertEqual(len(vars_dict), 3)
self.assertEqual(vars_dict['foo'], 1)
self.assertEqual(vars_dict['phi'], [10])
self.assertEqual(vars_dict['bar'], 1)
def test_parse_scalars(self):
x = ['foo', 'foo1']
vars_dict = parse_var_dims(x)
self.assertEqual(len(vars_dict), 2)
self.assertEqual(vars_dict['foo'], 1)
self.assertEqual(vars_dict['foo1'], 1)
self.runset.csv_files[i],
key,
dzero[key],
drest[key],
)
)
self._draws_sampling = dzero['draws_sampling']
if self._save_warmup:
self._draws_warmup = dzero['draws_warmup']
else:
self._draws_warmup = 0
self._column_names = dzero['column_names']
if not self._is_fixed_param:
self._num_params = dzero['num_params']
self._metric_type = dzero.get('metric')
self._stan_var_dims = parse_var_dims(dzero['column_names'])