Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
phis = ['phi.{}'.format(str(x + 1)) for x in range(2095)]
column_names = sampler_state + phis
self.assertEqual(runset.columns, len(column_names))
self.assertEqual(runset.column_names, tuple(column_names))
self.assertEqual(runset.metric_type, 'diag_e')
self.assertEqual(runset.stepsize.shape, (2,))
self.assertEqual(runset.metric.shape, (2, 2095))
self.assertEqual((1000, 2, 2102), runset.sample.shape)
phis = get_drawset(runset, params=['phi'])
self.assertEqual((2000, 2095), phis.shape)
phi1 = get_drawset(runset, params=['phi.1'])
self.assertEqual((2000, 1), phi1.shape)
mo_phis = get_drawset(runset, params=['phi.1', 'phi.10', 'phi.100'])
self.assertEqual((2000, 3), mo_phis.shape)
phi2095 = get_drawset(runset, params=['phi.2095'])
self.assertEqual((2000, 1), phi2095.shape)
with self.assertRaises(Exception):
get_drawset(runset, params=['phi.2096'])
with self.assertRaises(Exception):
get_drawset(runset, params=['ph'])
'accept_stat__',
'stepsize__',
'treedepth__',
'n_leapfrog__',
'divergent__',
'energy__',
]
phis = ['phi.{}'.format(str(x + 1)) for x in range(2095)]
column_names = sampler_state + phis
self.assertEqual(runset.columns, len(column_names))
self.assertEqual(runset.column_names, tuple(column_names))
self.assertEqual(runset.metric_type, 'diag_e')
self.assertEqual(runset.stepsize.shape, (2,))
self.assertEqual(runset.metric.shape, (2, 2095))
self.assertEqual((1000, 2, 2102), runset.sample.shape)
phis = get_drawset(runset, params=['phi'])
self.assertEqual((2000, 2095), phis.shape)
phi1 = get_drawset(runset, params=['phi.1'])
self.assertEqual((2000, 1), phi1.shape)
mo_phis = get_drawset(runset, params=['phi.1', 'phi.10', 'phi.100'])
self.assertEqual((2000, 3), mo_phis.shape)
phi2095 = get_drawset(runset, params=['phi.2095'])
self.assertEqual((2000, 1), phi2095.shape)
with self.assertRaises(Exception):
get_drawset(runset, params=['phi.2096'])
with self.assertRaises(Exception):
get_drawset(runset, params=['ph'])
'treedepth__',
'n_leapfrog__',
'divergent__',
'energy__',
]
phis = ['phi.{}'.format(str(x + 1)) for x in range(2095)]
column_names = sampler_state + phis
self.assertEqual(runset.columns, len(column_names))
self.assertEqual(runset.column_names, tuple(column_names))
self.assertEqual(runset.metric_type, 'diag_e')
self.assertEqual(runset.stepsize.shape, (2,))
self.assertEqual(runset.metric.shape, (2, 2095))
self.assertEqual((1000, 2, 2102), runset.sample.shape)
phis = get_drawset(runset, params=['phi'])
self.assertEqual((2000, 2095), phis.shape)
phi1 = get_drawset(runset, params=['phi.1'])
self.assertEqual((2000, 1), phi1.shape)
mo_phis = get_drawset(runset, params=['phi.1', 'phi.10', 'phi.100'])
self.assertEqual((2000, 3), mo_phis.shape)
phi2095 = get_drawset(runset, params=['phi.2095'])
self.assertEqual((2000, 1), phi2095.shape)
with self.assertRaises(Exception):
get_drawset(runset, params=['phi.2096'])
with self.assertRaises(Exception):
get_drawset(runset, params=['ph'])
'divergent__',
'energy__',
]
phis = ['phi.{}'.format(str(x + 1)) for x in range(2095)]
column_names = sampler_state + phis
self.assertEqual(runset.columns, len(column_names))
self.assertEqual(runset.column_names, tuple(column_names))
self.assertEqual(runset.metric_type, 'diag_e')
self.assertEqual(runset.stepsize.shape, (2,))
self.assertEqual(runset.metric.shape, (2, 2095))
self.assertEqual((1000, 2, 2102), runset.sample.shape)
phis = get_drawset(runset, params=['phi'])
self.assertEqual((2000, 2095), phis.shape)
phi1 = get_drawset(runset, params=['phi.1'])
self.assertEqual((2000, 1), phi1.shape)
mo_phis = get_drawset(runset, params=['phi.1', 'phi.10', 'phi.100'])
self.assertEqual((2000, 3), mo_phis.shape)
phi2095 = get_drawset(runset, params=['phi.2095'])
self.assertEqual((2000, 1), phi2095.shape)
with self.assertRaises(Exception):
get_drawset(runset, params=['phi.2096'])
with self.assertRaises(Exception):
get_drawset(runset, params=['ph'])
self.assertEqual(runset.metric_type, 'diag_e')
self.assertEqual(runset.stepsize.shape, (2,))
self.assertEqual(runset.metric.shape, (2, 2095))
self.assertEqual((1000, 2, 2102), runset.sample.shape)
phis = get_drawset(runset, params=['phi'])
self.assertEqual((2000, 2095), phis.shape)
phi1 = get_drawset(runset, params=['phi.1'])
self.assertEqual((2000, 1), phi1.shape)
mo_phis = get_drawset(runset, params=['phi.1', 'phi.10', 'phi.100'])
self.assertEqual((2000, 3), mo_phis.shape)
phi2095 = get_drawset(runset, params=['phi.2095'])
self.assertEqual((2000, 1), phi2095.shape)
with self.assertRaises(Exception):
get_drawset(runset, params=['phi.2096'])
with self.assertRaises(Exception):
get_drawset(runset, params=['ph'])
def test_bernoulli(self):
stan = os.path.join(datafiles_path, 'bernoulli.stan')
exe = os.path.join(datafiles_path, 'bernoulli')
if not os.path.exists(exe):
compile_model(stan)
model = Model(stan, exe_file=exe)
jdata = os.path.join(datafiles_path, 'bernoulli.data.json')
post_sample = sample(
model, chains=4, cores=2, seed=12345, sampling_iters=200, data=jdata
)
post_sample.assemble_sample()
df = get_drawset(post_sample)
self.assertEqual(
df.shape,
(
post_sample.chains * post_sample.draws,
len(post_sample.column_names),
),