Skip to content

Conversation

@khurram-ghani
Copy link
Collaborator

@khurram-ghani khurram-ghani commented Apr 19, 2023

PR type: doc improvement

Related issue(s)/PRs: resolves #2056

Summary

Proposed changes

  • Fix issues with API doc generation for SquaredExponential and Constant kernels.
  • Due to use of aliases, previously the doc generation for these two kernels was missing. Only the minimal docs for RBF and Bias aliases (respectively) were present.

Doc example with missing classes: https://gpflow.github.io/GPflow/2.7.1/api/gpflow/kernels/index.html#gpflow-kernels-rbf

Generated fixed documentation locally and checked the classes are present.

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

Aliases were previously resulting in the doc generation for the main
object to be skipped.
@uri-granta uri-granta self-requested a review April 20, 2023 14:13
Copy link
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.

Looks good! One question.

if id(f.obj) not in seen:
seen.add(id(f.obj))
# See comment above (for classes) about aliases.
if f.name.endswith("." + f.obj.__name__):
Copy link
Member

Choose a reason for hiding this comment

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

(strictly speaking we could also have an alias for one of the dispatcher functions handled above, though in practice I expect we won't)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot; I missed that. I'll add that as well for completeness.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have added that now (3bc0aac).

for impl in impls:
seen.add(id(impl))
# See comment below (for classes) about aliases.
if function.name.endswith("." + function.obj.__name__):
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be checking for aliases of the implementations impl rather than of the dispatcher function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess you could have aliases at both levels, dispatcher and implementations. Adding a check at the implementation level is more tricky since there is no existing Documentable* wrapper class for the implementations -> so there is no pathname to reference, only the function objects themselves. It seems to me that it is unlikely we will have aliases for implementations, since there is not a need for users to call them directly. What do you think?

for f in module.functions:
if id(f.obj) not in seen:
seen.add(id(f.obj))
# See comment above (for classes) about aliases.
Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this a bit more, wouldn't it make more sense to just use a different key? That way we would also remove duplicate aliases.

Suggested change
# See comment above (for classes) about aliases.
key = (id(f.obj), f.name[f.name.rfind(".")+1:])
if key not in seen:
seen.add(key)
new_functions.append(f)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. I have updated the keys.
This required changes to the dispatcher part as well to use the function implementation __name__ in the key, so that it then later matches correctly here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This addresses your previous comment as well I think. The check is now against the implementation instead of the dispatcher itself.

Copy link
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!

@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (39bd130) 98.06% compared to head (4bbb264) 98.06%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2063   +/-   ##
========================================
  Coverage    98.06%   98.06%           
========================================
  Files           97       97           
  Lines         5436     5436           
========================================
  Hits          5331     5331           
  Misses         105      105           

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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@khurram-ghani khurram-ghani merged commit cb88277 into develop Apr 25, 2023
@khurram-ghani khurram-ghani deleted the khurram/fix_doc_aliases branch April 25, 2023 11:48
@khurram-ghani khurram-ghani mentioned this pull request May 3, 2023
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.

Missing documentation for SquaredExponential kernel

3 participants