Add pyright as a second type checker #14
1 changed files with 20 additions and 28 deletions
Iterate over the rows in Forecast.from_dataframe()
commit
804a4a0966
|
|
@ -222,40 +222,32 @@ class Forecast(meta.Base):
|
|||
"""
|
||||
forecasts = []
|
||||
|
||||
for timestamp_idx in data.index:
|
||||
start_at = timestamp_idx.to_pydatetime()
|
||||
actual = int(data.loc[timestamp_idx, "actual"])
|
||||
prediction = float(round(data.loc[timestamp_idx, "prediction"], 5))
|
||||
|
||||
# Explicit type casting. SQLAlchemy does not convert
|
||||
# `float('NaN')`s into plain `None`s.
|
||||
|
||||
low80 = data.loc[timestamp_idx, "low80"]
|
||||
high80 = data.loc[timestamp_idx, "high80"]
|
||||
low95 = data.loc[timestamp_idx, "low95"]
|
||||
high95 = data.loc[timestamp_idx, "high95"]
|
||||
|
||||
low80 = None if math.isnan(low80) else float(round(low80, 5))
|
||||
|
||||
high80 = None if math.isnan(high80) else float(round(high80, 5))
|
||||
|
||||
low95 = None if math.isnan(low95) else float(round(low95, 5))
|
||||
|
||||
high95 = None if math.isnan(high95) else float(round(high95, 5))
|
||||
rows = data[["actual", "prediction", "low80", "high80", "low95", "high95"]]
|
||||
|
||||
for (
|
||||
timestamp_idx,
|
||||
actual,
|
||||
prediction,
|
||||
low80,
|
||||
high80,
|
||||
low95,
|
||||
high95,
|
||||
) in rows.itertuples(name=None):
|
||||
forecasts.append(
|
||||
cls(
|
||||
pixel=pixel,
|
||||
start_at=start_at,
|
||||
start_at=timestamp_idx.to_pydatetime(),
|
||||
time_step=time_step,
|
||||
train_horizon=train_horizon,
|
||||
model=model,
|
||||
actual=actual,
|
||||
prediction=prediction,
|
||||
low80=low80,
|
||||
high80=high80,
|
||||
low95=low95,
|
||||
high95=high95,
|
||||
actual=int(actual),
|
||||
prediction=float(round(prediction, 5)),
|
||||
# Explicit type casting. SQLAlchemy does not convert
|
||||
# `float('NaN')`s into plain `None`s.
|
||||
low80=None if math.isnan(low80) else float(round(low80, 5)),
|
||||
high80=None if math.isnan(high80) else float(round(high80, 5)),
|
||||
low95=None if math.isnan(low95) else float(round(low95, 5)),
|
||||
high95=None if math.isnan(high95) else float(round(high95, 5)),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue