Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type annotations #255

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/blosc2/blosc2_ext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def set_nthreads(nthreads):
return rc

def set_blocksize(size_t blocksize=0):
return blosc1_set_blocksize(blocksize)
blosc1_set_blocksize(blocksize)

def clib_info(codec):
cdef char* clib
Expand Down Expand Up @@ -2486,7 +2486,6 @@ cdef class NDArray:
new_shape_[i] = s
_check_rc(b2nd_resize(self.array, new_shape_, NULL),
"Error while resizing the array")
return self

def squeeze(self):
_check_rc(b2nd_squeeze(self.array), "Error while performing the squeeze")
Expand Down
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
Loading
Loading