Skip to content

Commit

Permalink
Merge 1e87467 into 80c7acb
Browse files Browse the repository at this point in the history
  • Loading branch information
OriolAbril committed Oct 29, 2019
2 parents 80c7acb + 1e87467 commit 3a1015d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arviz/data/io_emcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def blobs_to_dict(self):
blobs = np.array(self.sampler.blobs)
if blobs is None or blobs.size == 0:
raise ValueError("No blobs in sampler, blob_names must be None")
if len(blobs.shape) == 2:
blobs = np.expand_dims(blobs, axis=-1)
blobs = blobs.swapaxes(0, 2)
nblobs, nwalkers, ndraws, *_ = blobs.shape
if len(self.blob_names) != nblobs and len(self.blob_names) != 1:
Expand Down
7 changes: 7 additions & 0 deletions arviz/tests/test_data_emcee.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ def test_peculiar_blobs(self, data):
fails = check_multiple_attrs({"sample_stats": ["mix"]}, inference_data)
assert not fails

def test_single_blob(self):
sampler = emcee.EnsembleSampler(6, 1, lambda x: (-x ** 2, 3))
sampler.run_mcmc(np.random.normal(size=(6, 1)), 20)
inference_data = from_emcee(sampler, blob_names=["blob"])
fails = check_multiple_attrs({"sample_stats": ["blob"]}, inference_data)
assert not fails

@pytest.mark.parametrize(
"blob_args",
[
Expand Down

0 comments on commit 3a1015d

Please sign in to comment.