From 6ec66a11d74e6ef5d224a2a91d3336bb8a5846d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de> Date: Mon, 17 Apr 2023 11:44:22 +0200 Subject: [PATCH] Slight reformat. --- enstools/encoding/dataset_encoding.py | 1 - enstools/encoding/variable_encoding.py | 49 +++----------------------- 2 files changed, 4 insertions(+), 46 deletions(-) diff --git a/enstools/encoding/dataset_encoding.py b/enstools/encoding/dataset_encoding.py index 6ce3336..2485c1b 100644 --- a/enstools/encoding/dataset_encoding.py +++ b/enstools/encoding/dataset_encoding.py @@ -1,4 +1,3 @@ -import chunk import os from copy import deepcopy from pathlib import Path diff --git a/enstools/encoding/variable_encoding.py b/enstools/encoding/variable_encoding.py index 51a1fc6..b9ef7f3 100644 --- a/enstools/encoding/variable_encoding.py +++ b/enstools/encoding/variable_encoding.py @@ -1,9 +1,8 @@ -from abc import ABC from .definitions import lossy_compressors_and_modes import logging -from typing import Mapping, Union, Protocol +from typing import Mapping, Union import hdf5plugin @@ -22,6 +21,7 @@ class _Mapping(Mapping): """ Subclass to implement dunder methods that are mandatory for Mapping to avoid repeating the code everywhere. """ + def __init__(self) -> None: super().__init__() self._kwargs = {} @@ -54,7 +54,7 @@ class Encoding(_Mapping): def __repr__(self): return f"{self.__class__.__name__}({self.to_string()})" - + def set_chunk_sizes(self, chunk_sizes: tuple) -> None: """ Method to add chunksizes into the encoding dictionary. @@ -97,6 +97,7 @@ class VariableEncoding(_Mapping): >>> VariableEncoding(backend="snappy", compression_level=9) """ + def __new__(cls, specification: str = None, compressor: str = None, @@ -264,48 +265,6 @@ def parse_variable_specification(var_spec: str) -> Encoding: raise InvalidCompressionSpecification(f"Invalid specification {var_spec!r}") -# class VariableEncoding(_Mapping): -# """ -# Class to encapsulate compression specification parameters for a single variable. -# -# It stores the compressor, the mode and the parameter. -# -# It has a method to create a new instance from a specification string, -# a method to get the corresponding specification string from an existing object -# and a method to obtain the corresponding mapping expected by h5py. -# -# """ -# -# def __init__(self, specification: Specification): -# # Init basic components -# self.specification = specification -# -# self._kwargs = self.filter_mapping() -# -# @staticmethod -# def from_string(string: str) -> 'VariableEncoding': -# specification = parse_variable_specification(string) -# """ -# Method to create a specification object from a specification string -# """ -# return VariableEncoding(specification) -# -# def to_string(self) -> str: -# """ -# Method to obtain a specification string from a specification object -# """ -# return self.specification.to_string() -# -# def filter_mapping(self) -> Mapping: -# """ -# Method to get the corresponding FilterRefBase expected by h5py/xarray -# """ -# -# return self.specification.encoding() -# -# def description(self): -# self.specification.description() - def get_variable_encoding( specification: str = None, compressor: str = None, -- GitLab