From 8f15af71248969045fa2693859e0f7867c26add1 Mon Sep 17 00:00:00 2001 From: Marta Iborra Date: Fri, 13 Sep 2024 10:54:02 +0200 Subject: [PATCH] Add type annotations in c2array.py --- src/blosc2/c2array.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/blosc2/c2array.py b/src/blosc2/c2array.py index f002e54a..23a68def 100644 --- a/src/blosc2/c2array.py +++ b/src/blosc2/c2array.py @@ -34,7 +34,7 @@ def c2context( username: (str | None) = None, password: (str | None) = None, auth_token: (str | None) = None, -): +) -> None: """ Context manager that sets parameters in Caterva2 subscriber requests. @@ -180,7 +180,7 @@ def slice_to_string(slice_): class C2Array(blosc2.Operand): - def __init__(self, path, /, urlbase=None, auth_token=None): + def __init__(self, path: str, /, urlbase: str = None, auth_token: str = None): """Create an instance of a remote NDArray. Parameters @@ -239,7 +239,7 @@ def __getitem__(self, slice_: int | slice | Sequence[slice]) -> np.ndarray: slice_ = slice_to_string(slice_) return fetch_data(self.path, self.urlbase, {"slice_": slice_}, auth_token=self.auth_token) - def get_chunk(self, nchunk: int): + def get_chunk(self, nchunk: int) -> bytes: """ Get the compressed unidimensional chunk of a :ref:`C2Array`. @@ -259,28 +259,28 @@ def get_chunk(self, nchunk: int): return response.content @property - def shape(self): + def shape(self) -> tuple[int]: """The shape of the remote array""" return tuple(self.meta["shape"]) @property - def chunks(self): + def chunks(self) -> tuple[int]: """The chunks of the remote array""" return tuple(self.meta["chunks"]) @property - def blocks(self): + def blocks(self) -> tuple[int]: """The blocks of the remote array""" return tuple(self.meta["blocks"]) @property - def dtype(self): + def dtype(self) -> np.dtype: """The dtype of the remote array""" return np.dtype(self.meta["dtype"]) class URLPath: - def __init__(self, path, /, urlbase=None, auth_token=None): + def __init__(self, path: str, /, urlbase: str = None, auth_token: str = None): """ Create an instance of a remote data file (aka :ref:`C2Array `) urlpath. This is meant to be used in the :func:`blosc2.open` function.