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

support warmup groups in from_pymc3 #1171

Merged
merged 5 commits into from
May 6, 2020
Merged

support warmup groups in from_pymc3 #1171

merged 5 commits into from
May 6, 2020

Conversation

OriolAbril
Copy link
Member

@OriolAbril OriolAbril commented May 4, 2020

Description

Support warmup groups in from_pymc3. It should already work, but I have not figured out the dependencies of the whole thing (it may only work on pymc3 master) nor added any test yet.

Will fix #1146

Checklist

  • Follows official PR format
  • New features are properly documented (with an example if appropriate)?
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

@codecov
Copy link

codecov bot commented May 4, 2020

Codecov Report

Merging #1171 into master will increase coverage by 0.00%.
The diff coverage is 93.75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1171   +/-   ##
=======================================
  Coverage   93.11%   93.11%           
=======================================
  Files          94       94           
  Lines        9322     9339   +17     
=======================================
+ Hits         8680     8696   +16     
- Misses        642      643    +1     
Impacted Files Coverage Δ
arviz/plots/backends/__init__.py 29.11% <ø> (ø)
arviz/utils.py 91.49% <0.00%> (ø)
arviz/data/io_pymc3.py 92.74% <96.66%> (+0.10%) ⬆️
arviz/data/inference_data.py 81.88% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4afbfae...6ac27fa. Read the comment docs.

@michaelosthege
Copy link
Contributor

looks like pylint doesn't want us to access _warmup_posterior in the test (protected member)
https://dev.azure.com/ArviZ/ArviZ/_build/results?buildId=2376&view=logs&j=e6a7683b-6131-58a8-ef68-5f3a9120796c&t=b52e026f-cc99-5e74-288f-e4d4024efc71&l=15

@OriolAbril
Copy link
Member Author

Ready for review or even merge

Also related to #1083, this starts storing number of tuning steps in inference data as attrs of posterior and sample stats (both samples and warmup).

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Oriol! LGTM but I just had two questions.

Comment on lines 427 to 432
assert idata.posterior.sizes["chain"] == 2
assert idata.posterior.sizes["draw"] == 200
if save_warmup:
# pylint: disable=protected-access
assert idata._warmup_posterior.dims["chain"] == 2
assert idata._warmup_posterior.dims["draw"] == 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Just out of curiosity: why is the attribute to access different for posterior (sizes) and _warmup_posterior (dims), whereas you want to see the number of chains and draws in both cases?
  • Also, does it mean we keep the _ before warmup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ should stay before warmup. it is not a mcmc draw (in hmc; maybe) so it is only for advanced users

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding first question, both attributes do the same, the test Michael sent had sizes and I used dims to make it more xarray-y but missed half of them 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahartikainen how opposed would you be to removing the _ before warmup? Even if only for advanced users it is still for users, the default would still be data.save_warmup = false so unless they change it they would not have warmup groups, I feel like hiding them so much makes harder the live of advanced users without much gain for novices.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too opposed.

@OriolAbril
Copy link
Member Author

I think it is ready to merge

@AlexAndorra
Copy link
Contributor

AlexAndorra commented May 6, 2020 via email

Copy link
Contributor

@ahartikainen ahartikainen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ahartikainen ahartikainen merged commit 7177393 into master May 6, 2020
@OriolAbril OriolAbril deleted the pymc_warmup branch May 6, 2020 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically handle warmup draws and sampling metadata from_pymc3
4 participants