Skip to content

overhaul gp docstrings #6609

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

Closed

Conversation

daniel-saunders-phil
Copy link
Contributor

@daniel-saunders-phil daniel-saunders-phil commented Mar 17, 2023

What is this PR about?

#6608 noted some motivation for updating the docs throughout the GP module. Much of the work is just style changes. However a couple of new questions came up as I worked through. I'm marking this as a draft pull request until I can get some input:

  1. is_observed= argument is used on MarginalKron.marginal_likelihood and also Marginal.marginal_likelihood. In both cases it is deprecated. But on MarginalKron, there is still a docstring for the argument and on Marginal there isn't. Surely we should standardize but which direction is preferred? I imagine we should eliminate the doc on MarginalKron.
  2. The marginal GPs both have a predict method that can take a model argument. But no description is provided. I imagine the right description is something like the way we talk about it around the samplers - model : Model, optional if in with context

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Merging #6609 (8cdc77c) into main (c7279b5) will decrease coverage by 6.31%.
The diff coverage is 77.77%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6609      +/-   ##
==========================================
- Coverage   87.09%   80.78%   -6.31%     
==========================================
  Files          93       94       +1     
  Lines       15737    15927     +190     
==========================================
- Hits        13706    12867     -839     
- Misses       2031     3060    +1029     
Impacted Files Coverage Δ
pymc/gp/gp.py 93.82% <ø> (ø)
pymc/sampling/forward.py 95.45% <ø> (ø)
pymc/distributions/continuous.py 65.45% <33.33%> (-32.24%) ⬇️
pymc/testing.py 86.10% <81.81%> (-5.45%) ⬇️
pymc/distributions/discrete.py 98.73% <100.00%> (+0.01%) ⬆️

... and 42 files with indirect coverage changes

NathanielF and others added 2 commits March 18, 2023 09:20
Also extended testing.check_icdf with skip_paradomain_outside_edge_test param

---------

Co-authored-by: Michal Raczycki <[email protected]>
@daniel-saunders-phil
Copy link
Contributor Author

@OriolAbril would you be willing to help me with this?

@fonnesbeck
Copy link
Member

Thanks for taking this on!

@reshamas
Copy link
Member

@daniel-saunders-phil
Good to see you here again!
an option:

…ctive (pymc-devs#6616)

* Improved docstring for predictions argument in sample_posterior_predictive

* Fix typos

Co-authored-by: Ravin Kumar <[email protected]>

---------

Co-authored-by: Ravin Kumar <[email protected]>
@OriolAbril
Copy link
Member

If an argument is deprecated it should still be in the docs, with a note in the description about being deprecated. It is once it is eventually removed that both argument and itd docstring are deleted

For model you should use:

model : Model, optional
    Description, can be one sentence. It is here where conditions and further explanation om what optional means go. In the first line it is only argument name and type info.

Potential description "Model with the GP component for which predictions will be generated. It is optional when inside a with context, otherwise it is required"

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Quick review from my phone, not sure when I'll have time for a full review

pymc/gp/gp.py Outdated
The covariance function. Defaults to zero.
mean_func: None, instance of Mean
The mean function. Defaults to zero.
cov_func : 2D array, or instance of Covariance, default Zero
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cov_func : 2D array, or instance of Covariance, default Zero
cov_func : 2D array_like or Covariance, default ~pymc.gp.cov.Constant

Similar comment for mean_func, and I would also switch the order so it matches the order they appear in __init__

pymc/gp/gp.py Outdated
vector with shape `(n, 1)`.
given : dict, optional
Can take as key value pairs: `X`, `y`,
and `gp`. See the section in the documentation on additive GP
Copy link
Member

Choose a reason for hiding this comment

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

This can't be a mention, it should be a cross-reference. Anyone knows what page it means?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After digging around for a while, it looks like the only illustration of how additive GPs work is https://www.pymc.io/projects/examples/en/latest/gaussian_processes/GP-MaunaLoa.html

It seems like a gap in the examples/docs and might need to be addressed in future work.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's this page still pending update from v3? #5720 cc @bwengals @canyon289

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we link to unfinished work in a way that the docs will sync up once #5720 is finished or should we leave this be for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

pymc/gp/gp.py Outdated
**kwargs
Extra keyword arguments that are passed to distribution constructor.
Extra keyword arguments that are passed to 'MvStudentT' distribution constructor.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Extra keyword arguments that are passed to 'MvStudentT' distribution constructor.
Extra keyword arguments that are passed to :class:`~pymc.MvStudentT' distribution constructor.

pymc/gp/gp.py Outdated
Function input values. If one-dimensional, must be a column
vector with shape `(n, 1)`.
point: pymc.model.Point
point : pymc.model.Point, optional
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
point : pymc.model.Point, optional
point : pymc.Point, optional

@daniel-saunders-phil
Copy link
Contributor Author

Hi Oriol, thanks really helpful! I'll do another pass on this in the next couple days and then submit a real PR.

@daniel-saunders-phil daniel-saunders-phil marked this pull request as ready for review March 24, 2023 21:08
@daniel-saunders-phil daniel-saunders-phil marked this pull request as draft March 24, 2023 21:14
@daniel-saunders-phil daniel-saunders-phil marked this pull request as ready for review March 25, 2023 19:00
@daniel-saunders-phil
Copy link
Contributor Author

Okay, I got this pr into a stable shape. It’s ready for review whenever anyone is up for it.

the only unresolved bit is the reference to the additive GP example but given that it is still underconstruction, I’ll leave it be.

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

Some minor general comments:

  • I prefer using float/int (depending on which is correct) instead of scalar

  • I would also delete the "instance of Class" and leave "Class" only, I think the info conveyed by both is the same.

  • For the reference, I would add a

    See the :ref:`section <additive_gp>` in the documentation on additive GP models ...
    

    We can then comment on the issue to make sure that target is added when the doc is updated

@daniel-saunders-phil
Copy link
Contributor Author

Thanks for taking a look. I adjusted those things and sent in a new commit.

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

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

not sure what is going on with the extra modified files, so not merging yet. The docstrings look great already

@daniel-saunders-phil
Copy link
Contributor Author

Oh I see what happened with the extra files: a couple weeks ago I messed up some rebasing command and unwittingly added 4 other people's commits to my own. Do you know the best way to proceed? I could open up a new clean PR with only the finished GP file on it. Or is there a way to delete those commits off my branch?

@michaelosthege
Copy link
Member

michaelosthege commented Apr 1, 2023

Oh I see what happened with the extra files: a couple weeks ago I messed up some rebasing command and unwittingly added 4 other people's commits to my own. Do you know the best way to proceed? I could open up a new clean PR with only the finished GP file on it. Or is there a way to delete those commits off my branch?

You could try to rebase on latest main and drop the commits you want to remove, then force-push.

If that doesn't work just branch off main with a new branch, apply the GP docstring changes, then force-push to the old (this PR) branch.

@daniel-saunders-phil
Copy link
Contributor Author

Thanks Michael for the suggestions. I tried both routes and ran into trouble. After chatting with Oriol, we decided the best route was to just create a new branch and new PR #6652. We successfully merge it a little bit ago. I appreciate the help everyone!

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.

9 participants