Skip to content

Commit

Permalink
docs: add more type annotations to CrackleArray
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Aug 6, 2024
1 parent 1e5ca21 commit 09db51b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions crackle/array.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Union, Any
from typing import Optional, Union, Any, Dict

from .headers import CrackleHeader
from .codec import (
Expand Down Expand Up @@ -38,16 +38,16 @@ def random_access(self):
return True

@property
def size(self):
def size(self) -> int:
shape = self.shape
return shape[0] * shape[1] * shape[2]

@property
def ndim(self):
def ndim(self) -> int:
return sum([ dim >= 0 for dim in self.shape ])

@property
def nbytes(self):
def nbytes(self) -> int:
return nbytes(self.binary)

def copy(self):
Expand All @@ -60,16 +60,16 @@ def dtype(self):
def labels(self):
return labels(self.binary)

def num_labels(self):
def num_labels(self) -> int:
return num_labels(self.binary)

def min(self):
def min(self) -> int:
return codec.min(self.binary)

def max(self):
def max(self) -> int:
return codec.max(self.binary)

def remap(self, mapping, preserve_missing_labels=False):
def remap(self, mapping:Dict[int,int], preserve_missing_labels:bool = False):
return CrackleArray(remap(self.binary, mapping, preserve_missing_labels))

def refit(self):
Expand All @@ -81,7 +81,7 @@ def astype(self, dtype):
def renumber(self, start:int = 0) -> bytes:
return CrackleArray(renumber(self.binary, start))

def numpy(self):
def numpy(self) -> np.ndarray:
return self.decompress()

def decompress(self, label:Optional[int] = None) -> bytes:
Expand Down

0 comments on commit 09db51b

Please sign in to comment.