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

Update from_cmdstanpy converter to follow schema convention #1550

Merged
merged 1 commit into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## v0.x.x Unreleased
### New features
* Added `to_zarr` and `from_zarr` methods to InferenceData ([1518](https://github.com/arviz-devs/arviz/pull/1535))
* Added `to_zarr` and `from_zarr` methods to InferenceData ([1518](https://github.com/arviz-devs/arviz/pull/1518))
* Added confidence interval band to auto-correlation plot ([1535](https://github.com/arviz-devs/arviz/pull/1535))

### Maintenance and fixes
* Updated `from_cmdstan`, `from_numpyro` and `from_pymc3` converters to follow schema convention ([1541](https://github.com/arviz-devs/arviz/pull/1541), [1525](https://github.com/arviz-devs/arviz/pull/1525) and [1555](https://github.com/arviz-devs/arviz/pull/1555))
* Updated `from_cmdstanpy`, `from_cmdstan`, `from_numpyro` and `from_pymc3` converters to follow schema convention ([1550](https://github.com/arviz-devs/arviz/pull/1550), [1541](https://github.com/arviz-devs/arviz/pull/1541), [1525](https://github.com/arviz-devs/arviz/pull/1525) and [1555](https://github.com/arviz-devs/arviz/pull/1555))
* Fix calculation of mode as point estimate ([1552](https://github.com/arviz-devs/arviz/pull/1552))
* Remove variable name from legend in posterior predictive plot ([1559](https://github.com/arviz-devs/arviz/pull/1559))

Expand Down
9 changes: 8 additions & 1 deletion arviz/data/io_cmdstanpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def stats_to_xarray(self, fit):

dtypes = {"divergent__": bool, "n_leapfrog__": np.int64, "treedepth__": np.int64}
items = list(self.posterior.sampler_vars_cols.keys())
rename_dict = {
"divergent": "diverging",
"n_leapfrog": "n_steps",
"treedepth": "tree_depth",
"stepsize": "step_size",
"accept_stat": "acceptance_rate",
}

data, data_warmup = _unpack_fit(
fit,
Expand All @@ -121,7 +128,7 @@ def stats_to_xarray(self, fit):
)
for item in items:
name = re.sub("__$", "", item)
name = "diverging" if name == "divergent" else name
name = rename_dict.get(name, name)
data[name] = data.pop(item).astype(dtypes.get(item, float))
if data_warmup:
data_warmup[name] = data_warmup.pop(item).astype(dtypes.get(item, float))
Expand Down