Skip to content

Commit

Permalink
use Sequence instead of Iterable, since Sequence supports len, and in…
Browse files Browse the repository at this point in the history
…dexing
  • Loading branch information
pattonw committed Aug 25, 2024
1 parent 6ab3d07 commit 97c899a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions funlib/persistence/arrays/array.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from functools import reduce
from typing import Iterable, Optional, Union
from typing import Sequence, Optional, Union

import dask.array as da
import numpy as np
Expand All @@ -25,22 +25,22 @@ class Array(Freezable):
The numpy array like object to wrap.
offset (``Optional[Iterable[int]]``):
offset (``Optional[Sequence[int]]``):
The offset of the array in world units. Defaults to 0 for
every dimension if not provided
voxel_size (``Optional[Iterable[int]]``):
voxel_size (``Optional[Sequence[int]]``):
The size of a voxel. If not provided the voxel size is
assumed to be 1 in all dimensions.
axis_names (``Optional[Iterable[str]]``):
axis_names (``Optional[Sequence[str]]``):
The name of each axis. If not provided, the axis names
are given names ["c1", "c2", "c3", ...]
units (``Optional[Iterable[str]]``):
units (``Optional[Sequence[str]]``):
The units of each spatial dimension.
Expand All @@ -58,16 +58,15 @@ class Array(Freezable):
"""

data: da.Array
lazy_op: LazyOp

def __init__(
self,
data,
offset: Optional[Iterable[int]] = None,
voxel_size: Optional[Iterable[int]] = None,
axis_names: Optional[Iterable[str]] = None,
units: Optional[Iterable[str]] = None,
chunks: Optional[Union[int, Iterable[int], str]] = "auto",
offset: Optional[Sequence[int]] = None,
voxel_size: Optional[Sequence[int]] = None,
axis_names: Optional[Sequence[str]] = None,
units: Optional[Sequence[str]] = None,
chunks: Optional[Union[int, Sequence[int], str]] = "auto",
lazy_op: Optional[LazyOp] = None,
):
self.data = da.from_array(data, chunks=chunks)
Expand Down Expand Up @@ -190,7 +189,7 @@ def is_writeable(self):
[self._is_slice(lazy_op, writeable=True) for lazy_op in self.lazy_ops]
)

def apply_lazy_ops(self, lazy_op: LazyOp):
def apply_lazy_ops(self, lazy_op):
if self._is_slice(lazy_op):
if not isinstance(lazy_op, tuple):
lazy_op = (lazy_op,)
Expand Down

0 comments on commit 97c899a

Please sign in to comment.