Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[WIP] Add group argument in plot_ppc (fix #1002) #1008

Merged
merged 4 commits into from
Jan 17, 2020

Conversation

nitishp25
Copy link
Contributor

  • Add group argument in plot_ppc in ppcplot.py

  • Update bokeh backend of plot_ppc

  • Update matplotlib backend of plot_ppc

fixes #1002

@@ -38,34 +38,34 @@ def plot_ppc(
backend=None,
backend_kwargs=None,
show=None,
Copy link
Member

Choose a reason for hiding this comment

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

group must be added here somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, what is the reason for that?

Should I add it below backend_kwargs?

@@ -110,6 +110,9 @@ def plot_ppc(
check the plotting method of the backend.
show : bool, optional
Call backend show function.
group : str, optional
Copy link
Member

Choose a reason for hiding this comment

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

I would use group : {"prior", "posterior"}, optional trying to follow numpydoc style. Also, just to be extra clear, I would only allow two options, prior or posterior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that makes sense

if group not in ("posterior_predictive", "prior_predictive", "observed_data"):
raise TypeError(
'`group` argument must be `posterior_predictive`, `prior_predictive` or `observed_data`'
)
Copy link
Member

Choose a reason for hiding this comment

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

I would divide the argument checks in 2 parts. First check that the group is one of the valid options, and then make sure that the 2 needed groups are present in the inference data object (like it was done before with the hasattr). Also, note that if group="posterior" then the inference data must have posterior predictive and observed data groups but prior predictive is not needed

Copy link
Member

Choose a reason for hiding this comment

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

Also, make sure to not use group as argument and loop variable at the same time ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah actually I was confused earlier about how to check for the group and display error, now I got it. Thanks :)

@nitishp25 nitishp25 requested a review from OriolAbril January 16, 2020 09:36
raise TypeError(
'`data` argument must have the group "{group}" for ppcplot'.format(group=group)
)
if group == "posterior":
Copy link
Member

Choose a reason for hiding this comment

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

We should start by checking group in ("prior", "posterior"): and raise an error if it is not.

This would also allow to simplify the attribute checking by using for groups in ("{}_predictive".format(group), "observed_data"):...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah and it looks much cleaner. Thanks!

@nitishp25 nitishp25 force-pushed the add-prior-in-plot-ppc branch from 038bfca to b6d6fbd Compare January 17, 2020 06:25
@nitishp25 nitishp25 requested a review from OriolAbril January 17, 2020 06:50
@OriolAbril
Copy link
Member

LGTM

@nitishp25
Copy link
Contributor Author

Was there a specific reason for moving the group argument from the end to somewhere in between the others?

@OriolAbril
Copy link
Member

In the first commits group was only in the docstring, it was not an argument of the function

@nitishp25
Copy link
Contributor Author

nitishp25 commented Jan 17, 2020

I just checked the first commit again and it's the last argument there (line 41), though it doen't matter now :)

@OriolAbril
Copy link
Member

I must have missed it then, sorry.

@OriolAbril OriolAbril merged commit a372926 into arviz-devs:master Jan 17, 2020
@OriolAbril
Copy link
Member

Thanks for the PR!

@nitishp25
Copy link
Contributor Author

No problem :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add group keyword to plot_ppc
2 participants