Skip to content

Commit

Permalink
type ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Jul 16, 2024
1 parent 019697e commit e8df014
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/gluonts/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def split_into(xs: Sequence, n: int) -> Sequence:
# e.g. 10 by 3 -> 4, 3, 3
relative_splits[:remainder] += 1

return split(xs, np.cumsum(relative_splits))
return split(xs, np.cumsum(relative_splits)) # type: ignore[arg-type]


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions src/gluonts/model/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ class Quantile:
@classmethod
def from_float(cls, quantile: float) -> "Quantile":
assert isinstance(quantile, float)
return cls(value=quantile, name=str(quantile))
return cls(value=quantile, name=str(quantile)) # type: ignore[call-arg]

@classmethod
def from_str(cls, quantile: str) -> "Quantile":
assert isinstance(quantile, str)

try:
return cls(value=float(quantile), name=quantile)
return cls(value=float(quantile), name=quantile) # type: ignore[call-arg]
except ValueError:
m = re.match(r"^p(\d+)$", quantile)

Expand Down
4 changes: 2 additions & 2 deletions src/gluonts/mx/trainer/learning_rate_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ def __init__(
0 <= min_lr <= base_lr
), "The value of `min_lr` should be >= 0 and <= base_lr"

self.lr_scheduler = MetricAttentiveScheduler(
patience=Patience(
self.lr_scheduler = MetricAttentiveScheduler( # type: ignore[call-arg]
patience=Patience( # type: ignore[call-arg]
patience=patience, objective=Objective.from_str(objective)
),
learning_rate=base_lr,
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/patch_tst/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def forward(
# shift time features by `prediction_length` so that they are
# aligned with the target input.
time_feat = take_last(
torch.cat((past_time_feat, future_time_feat), dim=1),
torch.cat((past_time_feat, future_time_feat), dim=1), # type: ignore[arg-type]
dim=1,
num=self.context_length,
)
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/tft/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def forward(self, features: torch.Tensor) -> List[torch.Tensor]: # type: ignore
concat_features = super().forward(features=features)

if self._num_features > 1:
return torch.chunk(concat_features, self._num_features, dim=-1)
return torch.chunk(concat_features, self._num_features, dim=-1) # type: ignore[return-value]
else:
return [concat_features]

Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/modules/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def forward(self, features: torch.Tensor) -> torch.Tensor:
features, self._num_features, dim=-1
)
else:
cat_feature_slices = [features]
cat_feature_slices = [features] # type: ignore[assignment]

return torch.cat(
[
Expand Down
4 changes: 2 additions & 2 deletions src/gluonts/zebras/_time_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ def split(

# If past_length is not provided, it will equal to `index`, since
# `len(tf.split(5).past) == 5`
past_length: int = maybe.unwrap_or(past_length, index)
past_length: int = maybe.unwrap_or(past_length, index) # type: ignore[annotation-unchecked]

# Same logic applies to future_length, except that we deduct from the
# right. (We can't use past_length, since it can be unequal to index).
future_length: int = maybe.unwrap_or(future_length, len(self) - index)
future_length: int = maybe.unwrap_or(future_length, len(self) - index) # type: ignore[annotation-unchecked]

if self.index is None:
new_index = None
Expand Down

0 comments on commit e8df014

Please sign in to comment.