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

Type annotate pyro.poutine.runtime #3288

Merged
merged 8 commits into from
Nov 1, 2023
Merged

Type annotate pyro.poutine.runtime #3288

merged 8 commits into from
Nov 1, 2023

Conversation

ordabayevy
Copy link
Member

No description provided.

@ordabayevy ordabayevy added the WIP label Oct 30, 2023
@ordabayevy ordabayevy changed the title Type annotate pyro/poutine/runtime Type annotate pyro.poutine.runtime Oct 30, 2023
@@ -112,7 +112,7 @@ def get_posterior(
"""
raise NotImplementedError

def upstream_value(self, name: str) -> torch.Tensor:
def upstream_value(self, name: str):
Copy link
Member Author

@ordabayevy ordabayevy Oct 30, 2023

Choose a reason for hiding this comment

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

Temporarily removed the return type (changed to Any) so that mypy wouldn't complain. Will be fixed in a later PR.

Copy link
Member

@fritzo fritzo left a comment

Choose a reason for hiding this comment

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

LGTM, I'll try to keep review latency low...

# the global pyro stack
_PYRO_STACK = []
_PYRO_STACK: List[Messenger] = []
Copy link
Member

Choose a reason for hiding this comment

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

This is great!

"""
Allocate a dimension to an :class:`plate` with given name.
Dim should be either None for automatic allocation or a negative
integer for manual allocation.
"""
if name in self._stack:
raise ValueError('duplicate plate "{}"'.format(name))
raise ValueError(f"duplicate plate '{name}'")
Copy link
Member

Choose a reason for hiding this comment

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

No need to change, but I've been using the notation f"duplicate plate {name!r}" which I find easier to read.

ignore_errors = True
warn_unused_ignores = True
Copy link
Member

Choose a reason for hiding this comment

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

Can we add warn_unused_ignores to the top level [mypy] config? I've found that some # type: ignores mask real errors on the same line, so I've started using warn_unused_ignores globally, but maybe this practice is too pedantic for a user base with diverse mypy versions.

@fritzo fritzo merged commit ae725ef into dev Nov 1, 2023
9 checks passed
@ordabayevy ordabayevy deleted the type-runtime branch November 1, 2023 17:38
@ordabayevy ordabayevy mentioned this pull request Feb 5, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants