Skip to content

Commit b1e4dcc

Browse files
committed
fix(types): annotate get_transform return type in distributions
1 parent 3cc9e06 commit b1e4dcc

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

deeptab/utils/distributions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections.abc import Callable
2+
13
import numpy as np
24
import torch
35
import torch.distributions as dist
@@ -31,7 +33,7 @@ def __init__(self, name, param_names):
3133
self.param_names = param_names
3234
self.param_count = len(param_names)
3335
# Predefined transformation functions accessible to all subclasses
34-
self.predefined_transforms = {
36+
self.predefined_transforms: dict[str, Callable[[torch.Tensor], torch.Tensor]] = {
3537
"positive": torch.nn.functional.softplus,
3638
"none": lambda x: x,
3739
"square": lambda x: x**2,
@@ -50,7 +52,9 @@ def name(self):
5052
def parameter_count(self):
5153
return self.param_count
5254

53-
def get_transform(self, transform_name):
55+
def get_transform(
56+
self, transform_name: str | Callable[[torch.Tensor], torch.Tensor]
57+
) -> Callable[[torch.Tensor], torch.Tensor]:
5458
"""
5559
Retrieve a transformation function by name, or return the function if it's custom.
5660
"""

0 commit comments

Comments
 (0)