Skip to content

Commit

Permalink
upgrade pyre version in fbcode/kats - batch 1
Browse files Browse the repository at this point in the history
Differential Revision: D60993726

fbshipit-source-id: 9577a16262dc4a1f322639fdb0ba4507530df895
  • Loading branch information
generatedunixname89002005307016 authored and facebook-github-bot committed Aug 9, 2024
1 parent 17eda5e commit 1dcfad8
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions kats/detectors/cusum_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ def _if_normal(
check_decrease = 0 if decrease else np.inf

return (
# pyre-fixme[61]: `check_decrease` is undefined, or not always defined.
self.pre_mean - check_decrease * self.pre_std
<= cur_mean
# pyre-fixme[61]: `check_increase` is undefined, or not always defined.
<= self.pre_mean + check_increase * self.pre_std
)

Expand Down
3 changes: 3 additions & 0 deletions kats/detectors/rolling_stats_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ def calculate_iqr_median_deviation(
numerator, m, out=np.zeros_like(numerator), where=m != 0
)

# pyre-fixme[16]: `int` has no attribute `__getitem__`.
# pyre-fixme[6]: For 1st argument expected `pyre_extensions.ReadOnly[Sized]` but
# got `int`.
return result[0] if len(result) == 1 else result


Expand Down
1 change: 1 addition & 0 deletions kats/models/globalmodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def _format_fcst(
first_time[i], freq=self.params.freq, periods=steps
)
if "actual" in fcst_store:
# pyre-fixme[61]: `actual` is undefined, or not always defined.
df["actual"] = actual[i]
ans[idx] = df
return ans
Expand Down
4 changes: 3 additions & 1 deletion kats/models/ml_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,9 @@ def _predict(
# fill rest of the data with forecasts
if new_data_is_forecast:
in_window.update(
fc_wide[fc_wide.index <= fc_origin], overwrite=False
# pyre-fixme[61]: `fc_wide` is undefined, or not always defined.
fc_wide[fc_wide.index <= fc_origin],
overwrite=False,
)
else:
# in case the new_data is actually earlier than the training data, we need to remove any data
Expand Down
2 changes: 2 additions & 0 deletions kats/models/prophet.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,14 @@ def sample_linear_predictive_trend_vectorize(

# sample change points
changepoint_ts_new = 1 + np.random.rand(sample_size, max_possion_num) * (T - 1)
# pyre-fixme[16]: `int` has no attribute `sort`.
changepoint_ts_new.sort(axis=1)

# create mask for deltas -> to mute some deltas based on number of change points
mask = np.random.uniform(
0, max_possion_num, max_possion_num * sample_size
).reshape(sample_size, -1)
# pyre-fixme[61]: `possion_sample` is undefined, or not always defined.
mask = mask < possion_sample[:, None]

# Sample deltas
Expand Down
1 change: 1 addition & 0 deletions kats/tests/detectors/test_prophet_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def create_weekend_seasonality_ts(
ts.extend(sim.stl_sim() + trend)
rest_days_weekend = 2
if i >= weeks:
# pyre-fixme[61]: `rest_days` is undefined, or not always defined.
rest_days_weekend = rest_days - rest_days_weekday
if rest_days_weekend == 0:
break
Expand Down
1 change: 1 addition & 0 deletions kats/tests/tsfeatures/test_tsfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ def test_IntegerArrays(self) -> None:
],
}
)
# pyre-fixme[61]: `df` is undefined, or not always defined.
df["value"] = df["value"].astype(dtype=pd.Int64Dtype())
# pyre-fixme[61]: `df` may not be initialized here.
ts = TimeSeriesData(df)
Expand Down
1 change: 1 addition & 0 deletions kats/utils/decomposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ def _decompose_multi(self) -> None:
trend_jump=max(int((self.period + 1) * self.trend_jump_factor), 1),
)
assert self.decomp is not None
# pyre-fixme[16]: `Optional` has no attribute `__setitem__`.
self.decomp[str(i)] = decomposer.decomposer()

def remove_seasonality(self) -> TimeSeriesData:
Expand Down

0 comments on commit 1dcfad8

Please sign in to comment.