Skip to content

Sc336/api documentation refresh#2012

Merged
sc336 merged 7 commits into
developfrom
sc336/api_documentation_refresh
Nov 2, 2022
Merged

Sc336/api documentation refresh#2012
sc336 merged 7 commits into
developfrom
sc336/api_documentation_refresh

Conversation

@sc336
Copy link
Copy Markdown
Contributor

@sc336 sc336 commented Nov 1, 2022

PR type: doc improvement

Related issue(s)/PRs: Contributes to #1823

Summary

A few comments were in places that meant they weren't getting picked up by Sphinx. A few others were unclear enough I had to ask for some help in understanding them; I've updated these to make them more clear.

Fully backwards compatible: yes

PR checklist

  • New features: code is well-documented
    • detailed docstrings (API documentation)
    • notebook examples (usage demonstration)
  • The bug case / new feature is covered by unit tests
  • Code has type annotations
  • Build checks
    • I ran the black+isort formatter (make format)
    • I locally tested that the tests pass (make check-all)
  • Release management
    • RELEASE.md updated with entry for this change
    • New contributors: I've added myself to CONTRIBUTORS.md

@sc336 sc336 requested a review from uri-granta November 1, 2022 11:40
@sc336 sc336 force-pushed the sc336/api_documentation_refresh branch from 304a1f6 to db3e9b6 Compare November 1, 2022 11:50
Comment thread gpflow/base.py Outdated
class Module(tf.Module):
"""
Modules recursively compose other Modules and parameters to create models.
All GPFlow models, kernels, mean functions etc. are Modules.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
All GPFlow models, kernels, mean functions etc. are Modules.
All GPflow models, kernels, mean functions etc. are Modules.

Comment thread gpflow/base.py Outdated
Comment on lines +79 to +80
See also `this <https://www.tensorflow.org/api_docs/python/tf/Module>`_ documentation for the base class in
Tensorflow which goes into more detail as to why we use Module objects to compose things.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
See also `this <https://www.tensorflow.org/api_docs/python/tf/Module>`_ documentation for the base class in
Tensorflow which goes into more detail as to why we use Module objects to compose things.
See also `TensorFlow's documentation <https://www.tensorflow.org/api_docs/python/tf/Module>`_ for the base class
which goes into more detail as to why we use Module objects to compose things.

Comment thread gpflow/base.py

class Module(tf.Module):
"""
Modules recursively compose other Modules and parameters to create models.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Modules recursively compose other Modules and parameters to create models.
Modules recursively compose other Modules and parameters to create models.
Compared to the `tf.Module` base class, `gpflow.Module` includes additional support for handling `gpflow.Parameter` attributes, see :py:attr:`~parameters` and :py:attr:`~trainable_parameters`.
It also adds pretty-printing within IPython and Jupyter notebooks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to explain why there's a separate class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice, thanks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(as an aside, it would be nice if the pretty printing were accessible via a public method!)

Comment thread gpflow/base.py Outdated
Comment on lines +118 to +120
is provided, these two values will be the same. It is often challenging to operate with
unconstrained parameters. For example, a variance cannot be negative, therefore we need a
positive constraint and it is natural to use constrained values. A prior can be imposed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While we're looking at this, would it be worth clarifying that for us (humans), the constrained space is "natural" and "easy", whereas for the optimizer, constraints are hard and the unconstrained space is natural/easy, which is why we want to present it to the optimizer in unconstrained form?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a good idea.

Comment thread gpflow/functions.py Outdated
independently for each row of X.

This class is not only used for mean functions. For example, the variance of a
heteroskedastic model is specified using a Function.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is only true for some heteroskedastic models, when the variance is given in a parametric form. You can also build heteroskedastic models where the variance is modeled with another GP. Then it doesn't use this class.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
heteroskedastic model is specified using a Function.
heteroskedastic model can be specified using a `Function`.

and add a link to the corresponding notebook?

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 1, 2022

Codecov Report

Base: 98.09% // Head: 98.09% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (29c2e0d) compared to base (f66a708).
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2012      +/-   ##
===========================================
- Coverage    98.09%   98.09%   -0.01%     
===========================================
  Files           93       93              
  Lines         5262     5261       -1     
===========================================
- Hits          5162     5161       -1     
  Misses         100      100              
Impacted Files Coverage Δ
gpflow/functions.py 96.18% <ø> (ø)
gpflow/kernels/__init__.py 100.00% <ø> (ø)
gpflow/kernels/base.py 93.05% <ø> (-0.05%) ⬇️
gpflow/models/model.py 98.64% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
Member

@uri-granta uri-granta left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread gpflow/base.py
class Parameter(tfp.util.TransformedVariable):
"""A parameter retains both constrained and unconstrained representations. If no transform
is provided, these two values will be the same. It is often challenging for humans to operate with
unconstrained parameters, although this is typically easier for the optimiser. For example, a variance cannot be negative, therefore we need a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this giving "line too long" linting errors? Either way, should probably rejustify.

Comment thread doc/build_docs.py
type=str,
nargs="*",
help="Only process the notebooks with this base/stem name. Useful when debugging.",
help="Only process the notebooks with this base/stem name; this is typically much faster and is useful when debugging. For example, to process notebooks/tailor/external-mean-function.pct.py, use --limit_notebooks external-mean-function\n",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
help="Only process the notebooks with this base/stem name; this is typically much faster and is useful when debugging. For example, to process notebooks/tailor/external-mean-function.pct.py, use --limit_notebooks external-mean-function\n",
help="Only process the notebooks with this base/stem name; this is much faster and is useful when debugging. For example, to process notebooks/tailor/external-mean-function.pct.py, use --limit_notebooks external-mean-function\n",

Comment thread gpflow/base.py

class Module(tf.Module):
"""
Modules recursively compose other Modules and parameters to create models.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(as an aside, it would be nice if the pretty printing were accessible via a public method!)

Comment thread gpflow/models/model.py
) -> tf.Tensor:
"""
Compute the log density of the data at the new data points.
Compute the log of the probability density of the data at the new data points.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Genuine question: is log-density not a standard term?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's standard enough, but it doesn't hurt to be a bit verbose in the docstring. The function is already called log_density..

@sc336 sc336 merged commit 26a27a4 into develop Nov 2, 2022
@st--
Copy link
Copy Markdown
Member

st-- commented Nov 2, 2022

@uri-granta

(as an aside, it would be nice if the pretty printing were accessible via a public method!)

gpflow.utilities.print_summary() ?

@sc336 sc336 deleted the sc336/api_documentation_refresh branch November 7, 2022 14:04
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.

3 participants