feat(arviz): add arviz import and export #32
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a very basic import and export scheme with ArviZ.
Checks for new file types
If it finds netcdf ".nc" or zarr ".zarr" files, it tries to read them with ArviZ.
la_forge/la_forge/core.py
Lines 118 to 126 in 6d23069
Converts ArviZ data and metadata into a single "chain" for La Forge to consume
It filters out any parameters that do not correspond to samples in the chain. This means that the number of parameters always equals the number of columns in the chain. It therefore skips the check later on that would add extra PTMCMC parameters, such as
lnpost
.In this implementation, you need to have already named your variables in the ArviZ
InferenceData
object to their desired final names. I would recommend naming them to their usual PTMCMC values for backwards compatibility.la_forge/la_forge/core.py
Lines 127 to 129 in 6d23069
Adds an
arviz
cached_property
to theCore
classAssuming you have a
Core
namedmy_core
, callingmy_core.arviz
will return an ArviZInferenceData
object populated with theCore
's data.la_forge/la_forge/core.py
Lines 687 to 713 in 6d23069
Self contained example