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

Static typing fixes #285

Merged
merged 3 commits into from
Jun 1, 2023
Merged

Static typing fixes #285

merged 3 commits into from
Jun 1, 2023

Conversation

frazane
Copy link
Contributor

@frazane frazane commented Jun 1, 2023

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've formatted the new code by running poetry run pre-commit run --all-files --show-diff-on-failure before committing.
  • I've added tests for new code.
  • I've added docstrings for the new code.

Description

I added two small improvements to the static typing which will make coding with GPJax a bit easier, especially in fully featured IDEs.

  • construct_posterior and __mul__ are overloaded such that the correct posterior (abstract, conjugate or nonconjugate) is returned when we construct the posterior (current behavior is that an AbstractPosterior is always returned). This way we get proper tab-completion and information (signatures, docstrings) when mouse-hovering on an object.
  • pass (and return) a TypeVar (with Module as the upper bound) in fit instead of Module itself, such that we retain the right static typing information about the model we are using

@frazane frazane requested a review from thomaspinder June 1, 2023 07:58
@thomaspinder thomaspinder merged commit 6138af4 into main Jun 1, 2023
@thomaspinder thomaspinder deleted the static-typing-fixes branch June 1, 2023 11:29
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.

2 participants