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 Nov 27, 2023
1 parent 1953090 commit cb0c7d0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pvnet/data/wind_datamodule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Data module for pytorch lightning """
import glob
from datetime import datetime

Check warning on line 3 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L2-L3

Added lines #L2 - L3 were not covered by tests

import numpy as np
Expand All @@ -10,7 +11,6 @@
from torch.utils.data import DataLoader
from torch.utils.data.datapipes._decorator import functional_datapipe
from torch.utils.data.datapipes.datapipe import IterDataPipe

Check warning on line 13 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L5-L13

Added lines #L5 - L13 were not covered by tests
import glob


def copy_batch_to_device(batch, device):

Check warning on line 16 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L16

Added line #L16 was not covered by tests
Expand Down Expand Up @@ -98,7 +98,6 @@ def __init__(
self.batch_size = batch_size
self.batch_dir = batch_dir

Check warning on line 99 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L96-L99

Added lines #L96 - L99 were not covered by tests


if batch_dir is not None:
if any([period != [None, None] for period in [train_period, val_period, test_period]]):
raise ValueError("Cannot set `(train/val/test)_period` with presaved batches")

Check warning on line 103 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L101-L103

Added lines #L101 - L103 were not covered by tests
Expand Down Expand Up @@ -131,7 +130,7 @@ def __init__(
def _get_datapipe(self, start_time, end_time):
data_pipeline = windnet_netcdf_datapipe(

Check warning on line 131 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L130-L131

Added lines #L130 - L131 were not covered by tests
self.configuration,
keys=["sensor","nwp"],
keys=["sensor", "nwp"],
)

data_pipeline = (

Check warning on line 136 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L136

Added line #L136 was not covered by tests
Expand All @@ -142,9 +141,11 @@ def _get_datapipe(self, start_time, end_time):
return data_pipeline

Check warning on line 141 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L141

Added line #L141 was not covered by tests

def _get_premade_batches_datapipe(self, subdir, shuffle=False):
data_pipeline = windnet_netcdf_datapipe(config_filename=self.configuration,
keys=["sensor","nwp"],
filenames=list(glob.glob(f"{self.batch_dir}/{subdir}/*.nc")))
data_pipeline = windnet_netcdf_datapipe(

Check warning on line 144 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L143-L144

Added lines #L143 - L144 were not covered by tests
config_filename=self.configuration,
keys=["sensor", "nwp"],
filenames=list(glob.glob(f"{self.batch_dir}/{subdir}/*.nc")),
)
if shuffle:
data_pipeline = (

Check warning on line 150 in pvnet/data/wind_datamodule.py

View check run for this annotation

Codecov / codecov/patch

pvnet/data/wind_datamodule.py#L149-L150

Added lines #L149 - L150 were not covered by tests
data_pipeline.shuffle(buffer_size=100)
Expand Down

0 comments on commit cb0c7d0

Please sign in to comment.