-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
[WIP] Add new groups to from_numpyro and from_dict #1125
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1125 +/- ##
==========================================
+ Coverage 92.99% 93.12% +0.12%
==========================================
Files 94 94
Lines 9242 9283 +41
==========================================
+ Hits 8595 8645 +50
+ Misses 647 638 -9
Continue to review full report at Codecov.
|
@OriolAbril what do you think? Also, can I update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, I'll try to review more in depth in the following days.
There would be no problem updating from_dict
here too as it would also make sense to do another PR for it, whatever you prefer.
|
||
def test_inference_data_only_posterior(self, data): | ||
idata = from_numpyro(data.obj) | ||
test_dict = {"posterior": ["mu", "tau", "eta"], "sample_stats": ["diverging"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think log_likelihood will also be present with only posterior
@@ -156,6 +169,26 @@ def constant_data_to_xarray(self): | |||
constant_data[key] = xr.DataArray(vals, dims=val_dims, coords=coords) | |||
return xr.Dataset(data_vars=constant_data, attrs=make_attrs(library=None)) | |||
|
|||
@requires("predictions_constant_data") | |||
def predictions_constant_data_to_xarray(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not too much to ask, no pressure, could you do the same trick here as with constant data and predictions constant data in from_pyro and from_numpyro? If I am not mistaken, the code here is actually shared not between the 2 constant data group but also with observed data group, it would significantly reduce code duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! It makes much more sense. Thanks! Should I also do this for other groups like posterior_predictive, predictions, prior_predictive etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be done, I am not sure it is worth it though, they are already 3 lines long, the bulk of the code is already the external function dict_to_dataset
, the only difference between them is the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
arviz/data/io_numpyro.py
Outdated
"""When constructing InferenceData must have at least | ||
one of posterior, prior, posterior_predictive or predictions.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using """ will keep all the spaces at the beginning of the line, formatting the output in a strange way, this should not keep the spaces:
raise ValueError(
"When constructing InferenceData must have at least"
"one of posterior, prior, posterior_predictive or predictions."
I think it is ready to merge |
73f0a2f
to
ac52779
Compare
* added groups * update tests and changelog * lint changes * update from_dict and tests * update changelog * modify io_dict * minor fixes * update changelog again Add warning for log scale default in compare/loo/waic functions (arviz-devs#1150) * Added scale warning to ELPDData * Added scale warning to compare function * Added changes to Changelog * Moved warning to end of string in loo function * Removed last test for loo_print * Ran Black * Integrated Oriol's comments add local to docstring, and use lowercase for ess (arviz-devs#1152) hardcode show=False in plot_posterior subplots (arviz-devs#1151) * hardcode show=False in plot_posterior subplots * update changelog Fix documentation and deprecation warning in pair plot (arviz-devs#1156) The "kind" argument is not described correctly. * Fix pairplot warning. Previously, because of incorrect argument checking, pairplot would mistakenly warn the caller not to use the "contour" argument when that argument was NOT supplied. Changed default value to None and did the defaulting by hand to fix this issue. Also added some type declarations. * Clarified docstring for contour argument. Co-authored-by: Robert P. Goldman <[email protected]> add viridis as default cmap (arviz-devs#1160) add examples to customize 2D KDE (arviz-devs#1158) * add examples to customize 2D KDE * blackify gallery example * update changelog * briefly explain contour_kwargs and contourf_kwargs
Description
Fixes #1030
Add the following groups:
from_numpyro
only)Checklist