Enable PD in flake8 and ruff
This commit is contained in:
parent
f266adad45
commit
95f08bc96d
8 changed files with 36 additions and 15 deletions
|
|
@ -38,7 +38,7 @@ def predict(
|
|||
# Re-seed R every time it is used to ensure reproducibility.
|
||||
robjects.r("set.seed(42)")
|
||||
|
||||
if training_ts.isnull().any():
|
||||
if training_ts.isna().any():
|
||||
raise ValueError("`training_ts` must not contain `NaN` values")
|
||||
|
||||
# Copy the data from Python to R.
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ def stl( # noqa:C901,PLR0912,PLR0913,PLR0915
|
|||
"""
|
||||
# Validate all arguments and set default values.
|
||||
|
||||
if time_series.isnull().any():
|
||||
if time_series.isna().any():
|
||||
raise ValueError("`time_series` must not contain `NaN` values")
|
||||
|
||||
if ns % 2 == 0 or ns < 7:
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ def predict(
|
|||
# Re-seed R every time it is used to ensure reproducibility.
|
||||
robjects.r("set.seed(42)")
|
||||
|
||||
if training_ts.isnull().any():
|
||||
if training_ts.isna().any():
|
||||
raise ValueError("`training_ts` must not contain `NaN` values")
|
||||
|
||||
# Copy the data from Python to R.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ def predict(
|
|||
ValueError: if `training_ts` contains `NaN` values or some predictions
|
||||
could not be made for time steps in the `forecast_interval`
|
||||
"""
|
||||
if training_ts.isnull().any():
|
||||
if training_ts.isna().any():
|
||||
raise ValueError("`training_ts` must not contain `NaN` values")
|
||||
|
||||
extrapolated_ts = pd.Series(index=forecast_interval, dtype=float)
|
||||
|
|
@ -60,7 +60,7 @@ def predict(
|
|||
idx += seasonal_lag
|
||||
|
||||
# Sanity check.
|
||||
if extrapolated_ts.isnull().any(): # pragma: no cover
|
||||
if extrapolated_ts.isna().any(): # pragma: no cover
|
||||
raise ValueError("missing predictions in the `forecast_interval`")
|
||||
|
||||
return pd.DataFrame(
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class HorizontalETSModel(base.ForecastingModelABC):
|
|||
predictions.insert(loc=0, column="actual", value=actuals_ts)
|
||||
|
||||
# Sanity checks.
|
||||
if predictions.isnull().sum().any(): # pragma: no cover
|
||||
if predictions.isna().sum().any(): # pragma: no cover
|
||||
raise RuntimeError("missing predictions in hets model")
|
||||
if predict_at not in predictions.index: # pragma: no cover
|
||||
raise RuntimeError("missing prediction for `predict_at`")
|
||||
|
|
@ -121,7 +121,7 @@ class HorizontalSMAModel(base.ForecastingModelABC):
|
|||
predictions = pd.DataFrame(
|
||||
data={
|
||||
"actual": actuals_ts,
|
||||
"prediction": training_ts.values.mean(),
|
||||
"prediction": training_ts.to_numpy().mean(),
|
||||
"low80": float("NaN"),
|
||||
"high80": float("NaN"),
|
||||
"low95": float("NaN"),
|
||||
|
|
@ -131,9 +131,7 @@ class HorizontalSMAModel(base.ForecastingModelABC):
|
|||
)
|
||||
|
||||
# Sanity checks.
|
||||
if (
|
||||
predictions[["actual", "prediction"]].isnull().any().any()
|
||||
): # pragma: no cover
|
||||
if predictions[["actual", "prediction"]].isna().any().any(): # pragma: no cover
|
||||
raise RuntimeError("missing predictions in hsma model")
|
||||
if predict_at not in predictions.index: # pragma: no cover
|
||||
raise RuntimeError("missing prediction for `predict_at`")
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class TrivialModel(base.ForecastingModelABC):
|
|||
)
|
||||
|
||||
# Sanity checks.
|
||||
if predictions["actual"].isnull().any(): # pragma: no cover
|
||||
if predictions["actual"].isna().any(): # pragma: no cover
|
||||
raise RuntimeError("missing actuals in trivial model")
|
||||
if predict_at not in predictions.index: # pragma: no cover
|
||||
raise RuntimeError("missing prediction for `predict_at`")
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class RealtimeARIMAModel(base.ForecastingModelABC):
|
|||
# Sanity checks.
|
||||
if len(predictions) != 1: # pragma: no cover
|
||||
raise RuntimeError("real-time models should predict exactly one time step")
|
||||
if predictions.isnull().sum().any(): # pragma: no cover
|
||||
if predictions.isna().sum().any(): # pragma: no cover
|
||||
raise RuntimeError("missing predictions in rtarima model")
|
||||
if predict_at not in predictions.index: # pragma: no cover
|
||||
raise RuntimeError("missing prediction for `predict_at`")
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class VerticalARIMAModel(base.ForecastingModelABC):
|
|||
# Sanity checks.
|
||||
if len(predictions) <= 1: # pragma: no cover
|
||||
raise RuntimeError("vertical models should predict several time steps")
|
||||
if predictions.isnull().sum().any(): # pragma: no cover
|
||||
if predictions.isna().sum().any(): # pragma: no cover
|
||||
raise RuntimeError("missing predictions in varima model")
|
||||
if predict_at not in predictions.index: # pragma: no cover
|
||||
raise RuntimeError("missing prediction for `predict_at`")
|
||||
|
|
|
|||
Loading…
Reference in a new issue