From 3acf2671ee431305360fd5402aa8f9c1db7e86dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:38:53 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/backtest_sites.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/backtest_sites.py b/scripts/backtest_sites.py index b2482466..ca6c5313 100644 --- a/scripts/backtest_sites.py +++ b/scripts/backtest_sites.py @@ -23,6 +23,7 @@ except RuntimeError: pass +import json import logging import os import sys @@ -32,6 +33,8 @@ import pandas as pd import torch import xarray as xr +from huggingface_hub import hf_hub_download +from huggingface_hub.constants import CONFIG_NAME, PYTORCH_WEIGHTS_NAME from ocf_datapipes.batch import ( BatchKey, NumpyBatch, @@ -57,10 +60,6 @@ from pvnet.load_model import get_model_from_checkpoints from pvnet.utils import SiteLocationLookup -import json -from huggingface_hub import hf_hub_download -from huggingface_hub.constants import CONFIG_NAME, PYTORCH_WEIGHTS_NAME - # ------------------------------------------------------------------ # USER CONFIGURED VARIABLES TO RUN THE SCRIPT @@ -109,7 +108,7 @@ # FUNCTIONS -@functional_datapipe('pad_forward_pv') +@functional_datapipe("pad_forward_pv") class PadForwardPVIterDataPipe(IterDataPipe): """ Pads forecast pv. Sun position is calculated based off of pv time index @@ -128,8 +127,8 @@ def __iter__(self): """Iter""" for xr_data in self.pv_dp: - t0 = xr_data.time_utc.data[int(xr_data.attrs['t0_idx'])] - pv_step = np.timedelta64(xr_data.attrs['sample_period_duration']) + t0 = xr_data.time_utc.data[int(xr_data.attrs["t0_idx"])] + pv_step = np.timedelta64(xr_data.attrs["sample_period_duration"]) t_end = t0 + self.forecast_duration + pv_step time_idx = np.arange(xr_data.time_utc.data[0], t_end, pv_step) yield xr_data.reindex(time_utc=time_idx, fill_value=-1) @@ -424,8 +423,8 @@ def get_datapipe(config_path: str) -> NumpyBatch: ) config = load_yaml_configuration(config_path) - data_pipeline['pv'] = data_pipeline['pv'].pad_forward_pv( - forecast_duration=np.timedelta64(config.input_data.pv.forecast_minutes, 'm') + data_pipeline["pv"] = data_pipeline["pv"].pad_forward_pv( + forecast_duration=np.timedelta64(config.input_data.pv.forecast_minutes, "m") ) data_pipeline = DictDatasetIterDataPipe(