-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Overview
Most of the tests in test_hmc.py fail, likely as a result of the recent refactoring of hmc.py. To reproduce, simply call the functions in test_hmc.py from the base directory of the bayes-kit repo.
I noticed that there are two distinct errors causing these tests to fail.
List Comprehension Error
The first issue occurs when using list comprehension to sample from the hmc object:
draws = np.array([hmc.sample()[0] for _ in range(M)])
This line of code is used throughout test_hmc.py and is supposed to create an array of HMC samples. Instead, this code creates an array containing the last hmc.sample() element repeated M times. My hunch is that this occurs because of late-binding in Python lists, as explained here.
To resolve this issue on my machine, I have simply removed the list comprehension:
draws = np.zeros(M)
for i in range(M):
draws[i] = hmc.sample()[0]
Statistical Error
After fixing the list comprehension error, the test_hmc_diag_rep() and test_hmc_binom() tests still fail. These errors are harder to diagnose and may arise from incorrect HMC implementation, improper HMC parameters, etc.