Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 24, 2023
1 parent 77ecaa8 commit 2fdbec1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ocf_datapipes/training/pvnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import numpy as np
import xarray as xr
from torchdata.datapipes.iter import IterDataPipe
from torchdata.datapipes import functional_datapipe
from torchdata.datapipes.iter import IterDataPipe

from ocf_datapipes.batch import MergeNumpyModalities
from ocf_datapipes.config.model import Configuration
Expand Down Expand Up @@ -92,6 +92,7 @@ def gsp_drop_national(x: Union[xr.DataArray, xr.Dataset]):
"""
return x.where(x.gsp_id != 0, drop=True)


@functional_datapipe("pvnet_select_pv_by_ml_id")
class PVNetSelectPVbyMLIDIterDataPipe(IterDataPipe):
"""Select specific set of PV systems by ML ID."""
Expand All @@ -111,17 +112,15 @@ def __init__(self, source_datapipe: IterDataPipe, ml_ids: np.array):

def __iter__(self):
for x in self.source_datapipe:

Check warning on line 114 in ocf_datapipes/training/pvnet.py

View check run for this annotation

Codecov / codecov/patch

ocf_datapipes/training/pvnet.py#L114

Added line #L114 was not covered by tests

# Check for missing IDs
# Check for missing IDs
ml_ids_not_in_data = ~np.isin(self.ml_ids, x.ml_id)
if ml_ids_not_in_data.any():
missing_ml_ids = np.array(self.ml_ids)[ml_ids_not_in_data]
logger.warning(

Check warning on line 119 in ocf_datapipes/training/pvnet.py

View check run for this annotation

Codecov / codecov/patch

ocf_datapipes/training/pvnet.py#L116-L119

Added lines #L116 - L119 were not covered by tests
f"The following ML IDs were mising in the PV site-level input data: "
f"{missing_ml_ids}. The values for these IDs will be set to NaN."

)

x_filtered = (

Check warning on line 124 in ocf_datapipes/training/pvnet.py

View check run for this annotation

Codecov / codecov/patch

ocf_datapipes/training/pvnet.py#L124

Added line #L124 was not covered by tests
# Many ML-IDs are null, so filter first
x.where(~x.ml_id.isnull(), drop=True)
Expand Down

0 comments on commit 2fdbec1

Please sign in to comment.