diff --git a/climetlab/readers/bzip.py b/climetlab/readers/bzip.py index 9d68013f..d6d07d6a 100644 --- a/climetlab/readers/bzip.py +++ b/climetlab/readers/bzip.py @@ -8,7 +8,6 @@ # import bz2 -import os from . import Reader from . import reader as find_reader @@ -33,7 +32,7 @@ def uncompress(target, _): ) def mutate(self): - print('mutare', self.source, self.unzipped) + print("mutare", self.source, self.unzipped) return find_reader(self.source, self.unzipped) diff --git a/climetlab/readers/grib/pytorch.py b/climetlab/readers/grib/pytorch.py index 37a59f48..de971925 100644 --- a/climetlab/readers/grib/pytorch.py +++ b/climetlab/readers/grib/pytorch.py @@ -11,8 +11,6 @@ import numpy as np -# from climetlab.ml.torch import to_pytorch_dataloader - from .tensorflow import default_merger, to_funcs LOG = logging.getLogger(__name__) @@ -63,6 +61,8 @@ def __getitem__(self, i): # -> Tuple[np.ndarray, ...]: class PytorchMixIn: def to_pytorch_dataloader(self, *args, dataloader_kwargs=None, **kwargs): + from climetlab.ml.torch import to_pytorch_dataloader + if dataloader_kwargs is None: dataloader_kwargs = {} dataset = self.to_pytorch(*args, **kwargs) diff --git a/climetlab/utils/patterns.py b/climetlab/utils/patterns.py index 86903411..3727338f 100644 --- a/climetlab/utils/patterns.py +++ b/climetlab/utils/patterns.py @@ -17,6 +17,7 @@ RE3 = re.compile(r"\(([^}]*)\)") + class Any: def substitute(self, value, name): return value @@ -115,11 +116,13 @@ def substitute(self, params): raise ValueError("Missing parameter '{}'".format(self.name)) return self.kind.substitute(params[self.name], self.name) + FUNCTIONS = dict(lower=lambda s: s.lower()) + class Function: def __init__(self, value): - functions = value.split('|') + functions = value.split("|") self.name = functions[0] self.variable = Variable(functions[0]) self.functions = functions[1:] @@ -131,7 +134,6 @@ def substitute(self, params): return value - class Pattern: def __init__(self, pattern, ignore_missing_keys=False): self.ignore_missing_keys = ignore_missing_keys @@ -142,7 +144,7 @@ def __init__(self, pattern, ignore_missing_keys=False): if i % 2 == 0: self.pattern.append(Constant(p)) else: - if '|' in p: + if "|" in p: v = Function(p) else: v = Variable(p) diff --git a/climetlab/version b/climetlab/version index 19270385..c3f65805 100644 --- a/climetlab/version +++ b/climetlab/version @@ -1 +1 @@ -0.16.5 +0.16.6