diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 221d62ef4d5756f0030e8360dea3f89bb41d782e..c4d80d94d1308bfad3f44ff85a3625908c826817 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ test_docker: rules: - if: '$CI_COMMIT_TAG == null' -deploy to testpypi: +deploy-to-testpypi: stage: deploy_test image: python:3.8 tags: @@ -29,7 +29,7 @@ deploy to testpypi: - python setup.py sdist bdist_wheel - twine upload -u "__token__" -p "$PYPI_TEST_PASSWORD" --repository-url https://test.pypi.org/legacy/ --skip-existing dist/* -install from testpypi: +install-from-testpypi: stage: test_install image: python:3.8 tags: @@ -44,7 +44,7 @@ install from testpypi: paths: - "*.log" -deploy to pypi: +deploy-to-pypi: stage: deploy_prod image: python:3.8 only: diff --git a/enstools/encoding/variable_encoding.py b/enstools/encoding/variable_encoding.py index 33219a7278c9fa0d395562313aacb481583d2789..9691946ba61637432764fe29a062d1cde18c02c8 100644 --- a/enstools/encoding/variable_encoding.py +++ b/enstools/encoding/variable_encoding.py @@ -1,4 +1,3 @@ -from abc import ABC from .definitions import lossy_compressors_and_modes import logging @@ -69,6 +68,19 @@ class Encoding(_Mapping): """ self._kwargs["chunksizes"] = chunk_sizes + def set_chunk_sizes(self, chunk_sizes: tuple) -> None: + """ + Method to add chunksizes into the encoding dictionary. + Parameters + ---------- + chunk_sizes + + Returns + ------- + + """ + self._kwargs["chunksizes"] = chunk_sizes + class VariableEncoding(_Mapping): """ @@ -98,6 +110,7 @@ class VariableEncoding(_Mapping): >>> VariableEncoding(backend="snappy", compression_level=9) """ + def __new__(cls, specification: str = None, compressor: str = None, @@ -265,48 +278,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,