Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for longdouble behavior have started failing #438

Closed
dfm opened this issue Sep 20, 2022 · 0 comments · Fixed by #439
Closed

Tests for longdouble behavior have started failing #438

dfm opened this issue Sep 20, 2022 · 0 comments · Fixed by #439

Comments

@dfm
Copy link
Owner

dfm commented Sep 20, 2022

In #436 we saw that the following test has started to fail:

def test_longdouble_actually_needed(cls):
if issubclass(cls, TempHDFBackend) and not does_hdf5_support_longdouble():
pytest.xfail("HDF5 does not support long double on this platform")
mjd = np.longdouble(58000.0)
sigma = 100 * np.finfo(np.longdouble).eps * mjd
def log_prob(x):
assert x.dtype == np.longdouble
return -0.5 * np.sum(((x - mjd) / sigma) ** 2)
ndim, nwalkers = 1, 20
steps = 1000
p0 = sigma * np.random.randn(nwalkers, ndim).astype(np.longdouble) + mjd
assert not all(p0 == mjd)
with cls(dtype=np.longdouble) as backend:
sampler = emcee.EnsembleSampler(
nwalkers, ndim, log_prob, backend=backend
)
sampler.run_mcmc(p0, steps)
samples = sampler.get_chain().reshape((-1,))
assert samples.dtype == np.longdouble
assert not np.all(samples == mjd)
assert np.abs(np.mean(samples) - mjd) < 10 * sigma / np.sqrt(
len(samples)
)
assert 0.1 * sigma < np.std(samples) < 10 * sigma

@hendriko373 noted that the test is not seeded (which we probably should fix), but this never failed previously so I worry that something else is problematic.

@aarchiba: Since you developed this feature, do you have any thoughts about this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant