-
-
Notifications
You must be signed in to change notification settings - Fork 411
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
data io - change from_cmdstanpy
to work with CmdStanPy version 0.9.68
#1558
Conversation
I didn't add any new unit tests; existing tests work. |
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.
Looks good.
I think the latest release is the default way to handle (and we can drop support for the old code when time goes forward; 1year?)
arviz/data/io_cmdstanpy.py
Outdated
@@ -393,6 +438,105 @@ def to_inference_data(self): | |||
}, | |||
) | |||
|
|||
@requires("posterior") | |||
def posterior_to_xarray_v68(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.
Could we change the logic so this is "default" and the other function is "old"?
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.
yes!
Codecov Report
@@ Coverage Diff @@
## main #1558 +/- ##
==========================================
- Coverage 91.07% 90.17% -0.90%
==========================================
Files 105 105
Lines 11361 11420 +59
==========================================
- Hits 10347 10298 -49
- Misses 1014 1122 +108
Continue to review full report at Codecov.
|
hi @ahartikainen, refactored - added a bunch of helper functions that do the data munging, specifically:
|
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 looks great, thanks!
Regarding developing and maintaining the converters, do you think it would be easier to have a to_arviz
in cmdstanpy instead?
It will probably be a bit more complicated in terms of setting up tests and ci in the inference libraries repos, but I feel like all the converters are becoming increasingly complicated due to having to support multiple versions: from_pystan
is basically 2 converters in one to work with pystan2 and 3, from_pymc3
also has multiple checks, which get more complicated every time and it already gets to the point of monkeypatching pymc3.
I can see how this is a problem. are you suggesting that |
Yes, we can discuss that on the lab meeting this Friday, I have added a point about it. Currently ArviZ has cmdstanpy as a runtime dependency for It may also require some changes to ArviZ (making sure all functions used by the converters are not private methods to begin with, maybe documenting how to create converters) but in the long run it this approach will probably serve ArviZ's goals better and ease ArviZ integration with new libraries. In fact, mcx supports InferenceData natively: https://github.com/rlouf/mcx/blob/master/mcx/trace.py using this approach, and it basically uses |
PR is now failing because of code coverage - we need tests for CmdStanPy 0.9.65 and 0.9.68. |
on further consideration, this isn't possible because the dependency is going in the wrong direction - CmdStanPy is upstream. also, desiderata for CmdStanPy is minimal dependencies on other packages. |
I think it's no problem that the converters for old cmdstanpy versions are not tested. I am merging like this, it can always be added in a follow up pr. |
…68 (arviz-devs#1558) * from_cmdstanpy for v0.9.68 * from_cmdstanpy for v0.9.68 * lint fix * lint fix * echanges per code review, also, refactor * lint fix * added docstrings * docstrings lint fix * docstrings lint fix * lintfix, baby one more time
Description
CmdStanPy version 0.9.68 changed several properties and methods on the CmdStanMCMC object;
critically, the protected property
_num_warmup
was replaced with propertynum_draws_warmup
and corresponding
num_draws_sampling
. Also, the CmdStanMCMC object propertiesstan_vars_cols
andsampler_vars_cols
provide a mapping from variable names to the output columns.To fix
from_cmdstanpy
, I added a few helper functions which manipulate lists of variable names.Going forward, the method
_unpack_fit
can be used instead of_unpack_frame
.Checklist