Skip to content

Commit

Permalink
Add type annotations in c2array.py
Browse files Browse the repository at this point in the history
  • Loading branch information
martaiborra committed Sep 13, 2024
1 parent dbeb43a commit 8f15af7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/blosc2/c2array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`.
Expand All @@ -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 <C2Array>`) urlpath.
This is meant to be used in the :func:`blosc2.open` function.
Expand Down

0 comments on commit 8f15af7

Please sign in to comment.