def test_hdf5_compression(): with backends.TempHDFBackend(compression="gzip") as b: run_sampler(b, blobs=True) # re-open and read b.get_chain() b.get_blobs() b.get_log_prob() b.accepted
def test_hdf5_dtypes(): nwalkers = 10 ndim = 2 with backends.TempHDFBackend(dtype=np.longdouble) as b: assert b.dtype == np.longdouble b.reset(nwalkers, ndim) with h5py.File(b.filename, "r") as f: g = f["test"] assert g["chain"].dtype == np.longdouble
def test_multi_hdf5(): with backends.TempHDFBackend() as backend1: run_sampler(backend1) backend2 = backends.HDFBackend(backend1.filename, name="mcmc2") run_sampler(backend2) chain2 = backend2.get_chain() with h5py.File(backend1.filename, "r") as f: assert set(f.keys()) == {backend1.name, "mcmc2"} backend1.reset(10, 2) assert np.allclose(backend2.get_chain(), chain2) with pytest.raises(AttributeError): backend1.get_chain()