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

Fix mypy and line-too-long errors #3313

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyro/poutine/indep_messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def vectorized(self) -> bool:
return self.dim is not None

def _key(self) -> Tuple[str, Optional[int], int, int]:
size = self.size
with ignore_jit_warnings(["Converting a tensor to a Python number"]):
size = (
self.size.item() if isinstance(self.size, torch.Tensor) else self.size # type: ignore[attr-defined, unreachable]
)
return self.name, self.dim, size, self.counter
if isinstance(size, torch.Tensor): # type: ignore[unreachable]
size = size.item() # type: ignore[unreachable]
return self.name, self.dim, size, self.counter

def __eq__(self, other: object) -> bool:
if not isinstance(other, CondIndepStackFrame):
Expand Down
2 changes: 1 addition & 1 deletion pyro/poutine/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def _fn(
if not am_i_wrapped():
return fn(*args, **kwargs)
else:
msg = Message[_P, _T](
msg = Message(
type=type,
name=name,
fn=fn,
Expand Down
Loading