Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit d90e0d1

Browse files
authored
Merge pull request #44 from openclimatefix/jacob/more-linting
Updated all docstrings Still have flak8 and such to do
2 parents c2f4f44 + 945e2bf commit d90e0d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+604
-226
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
"""Convert to BatchML object"""
12
from torchdata.datapipes import functional_datapipe
23
from torchdata.datapipes.iter import IterDataPipe

ocf_datapipes/batch/merge_numpy_examples_to_batch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Merge individual examples into a batch"""
12
from torchdata.datapipes import functional_datapipe
23
from torchdata.datapipes.iter import IterDataPipe
34

@@ -7,11 +8,21 @@
78

89
@functional_datapipe("merge_numpy_examples_to_batch")
910
class MergeNumpyExamplesToBatchIterDataPipe(IterDataPipe):
11+
"""Merge individual examples into a batch"""
12+
1013
def __init__(self, source_datapipe: IterDataPipe, n_examples_per_batch: int):
14+
"""
15+
Merge individual examples into a batch
16+
17+
Args:
18+
source_datapipe: Datapipe of NumpyBatch data
19+
n_examples_per_batch: Number of examples per batch
20+
"""
1121
self.source_datapipe = source_datapipe
1222
self.n_examples_per_batch = n_examples_per_batch
1323

1424
def __iter__(self) -> NumpyBatch:
25+
"""Merge individual examples into a batch"""
1526
np_examples = []
1627
for np_batch in self.source_datapipe:
1728
np_examples.append(np_batch)

ocf_datapipes/batch/merge_numpy_modalities.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Merge multiple modalities together in NumpyBatch"""
12
from torchdata.datapipes import functional_datapipe
23
from torchdata.datapipes.iter import IterDataPipe, Zipper
34

@@ -6,10 +7,19 @@
67

78
@functional_datapipe("merge_numpy_modalities")
89
class MergeNumpyModalitiesIterDataPipe(IterDataPipe):
10+
"""Merge multiple modalities together in NumpyBatch"""
11+
912
def __init__(self, source_datapipes: [IterDataPipe]):
13+
"""
14+
Merge multiple modalities together in NumpyBatch
15+
16+
Args:
17+
source_datapipes: Set of datapipes to merge emitting NumpyBatch objects
18+
"""
1019
self.source_datapipes = source_datapipes
1120

1221
def __iter__(self) -> NumpyBatch:
22+
"""Merge multiple modalities together in NumpyBatch"""
1323
for np_batches in Zipper(*self.source_datapipes):
1424
example: NumpyBatch = {}
1525
for np_batch in np_batches:

ocf_datapipes/convert/coordinates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Convert coordinates Datapipes"""
12
from typing import Union
23

34
import xarray as xr

ocf_datapipes/convert/gsp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Convert GSP to Numpy Batch"""
12
from torchdata.datapipes import functional_datapipe
23
from torchdata.datapipes.iter import IterDataPipe
34

ocf_datapipes/convert/nwp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Convert NWP to NumpyBatch"""
12
import numpy as np
23
from torchdata.datapipes import functional_datapipe
34
from torchdata.datapipes.iter import IterDataPipe

ocf_datapipes/convert/pv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Convert PV to Numpy Batch"""
12
import numpy as np
23
from torchdata.datapipes import functional_datapipe
34
from torchdata.datapipes.iter import IterDataPipe

ocf_datapipes/convert/satellite.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Convert Satellite to NumpyBatch"""
12
from torchdata.datapipes import functional_datapipe
23
from torchdata.datapipes.iter import IterDataPipe
34

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""Collection of experimental datapipes, explicitly not ready for production,
2-
but can be upgraded later, these might not be tested, and are to make quick experiments easier"""
1+
"""Experimental Datapipes
2+
3+
Collection of experimental datapipes, explicitly not ready for production,
4+
but can be upgraded later, these might not be tested, and are to make quick experiments easier
5+
"""
36
from .ensure_n_nwp_variables import EnsureNNWPVariables
47
from .set_system_id_to_one import SetSystemIDsToOneIterDataPipe as SetSystemIDsToOne

ocf_datapipes/experimental/ensure_n_nwp_variables.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
"""Ensure there are N NWP variables by tiling the data"""
12
import numpy as np
2-
import xarray as xr
33
from torchdata.datapipes import functional_datapipe
44
from torchdata.datapipes.iter import IterDataPipe
55

@@ -8,11 +8,21 @@
88

99
@functional_datapipe("ensure_n_nwp_variables")
1010
class EnsureNNWPVariables(IterDataPipe):
11+
"""Ensure there are N NWP variables by tiling the data"""
12+
1113
def __init__(self, source_datapipe: IterDataPipe, num_variables: int):
14+
"""
15+
Ensure there are N NWP variables by tiling the data
16+
17+
Args:
18+
source_datapipe: NumpyBatch emitting NWP datapipe
19+
num_variables: Number of variables needed
20+
"""
1221
self.source_datapipe = source_datapipe
1322
self.num_variables = num_variables
1423

15-
def __iter__(self):
24+
def __iter__(self) -> NumpyBatch:
25+
"""Ensure there are N NWP variables by tiling the data"""
1626
for np_batch in self.source_datapipe:
1727
num_tiles = int(np.ceil(self.num_variables / len(np_batch[BatchKey.nwp_channel_names])))
1828
np_batch[BatchKey.nwp_channel_names] = np.tile(

0 commit comments

Comments
 (0)