Skip to content

Commit

Permalink
Fix failing tests in older versions of Python
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-dark committed Oct 23, 2023
1 parent f03f118 commit ae0a02b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions tiledb/cf/core/_fragment_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def write(self, array: tiledb.libtiledb.Array, *, skip_metadata: bool = False):
if hasattr(attr_data, "fill") and attr_data.fill != attr.fill[0]:
attr_data.fill = attr.fill

array[*region] = {name: data.values for name, data in self._attr_data.items()}
array[region] = {name: data.values for name, data in self._attr_data.items()}

if not skip_metadata:
for name, data in self._attr_data.items():
Expand Down Expand Up @@ -152,7 +152,7 @@ def __init__(
)
self._size = np.prod(self._shape)

def coordinates(self):
def coordinates(self) -> Tuple[np.ndarray]:
def create_coords(dim_range, dtype):
if dtype.kind in {"u", "i"}:
dt = 1
Expand Down Expand Up @@ -188,15 +188,15 @@ def shape(self) -> Optional[Tuple[int, ...]]:
def size(self) -> int:
return self._size

def subarray(self) -> List[slice, ...]:
return [
def subarray(self) -> Tuple[slice, ...]:
return tuple(
(
slice(dim_range[0], dim_range[1] + 1)
if np.issubdtype(type(dim_range[1]), np.integer)
else slice(dim_range[0], dim_range[1])
)
for dim_range in self._region
]
)

def write_metadata(self, array: tiledb.libtiledb.Array):
"""Write any metadata associated with this region."""
Expand All @@ -211,7 +211,7 @@ def __init__(self, dims: Tuple[SharedDim], size: int):
# Set the size of the data.
self._size = size

def coordinates(self):
def coordinates(self) -> Tuple[np.ndarray]:
for idim, data in enumerate(self._dim_data):
if data is None:
raise ValueError(
Expand Down Expand Up @@ -247,7 +247,7 @@ def shape(self) -> Optional[Tuple[int, ...]]:
def size(self) -> int:
return self._size

def subarray(self) -> List[slice, ...]:
def subarray(self) -> Tuple[slice, ...]:
raise RuntimeError("Cannot construct a subarray for a sparse region.")

def write_metadata(self, array: tiledb.libtiledb.Array):
Expand Down Expand Up @@ -275,7 +275,7 @@ def __init__(self, dims: Tuple[SharedDim], shape: Tuple[int, ...]):
self._shape = shape
self._size = np.prod(shape)

def coordinates(self):
def coordinates(self) -> Tuple[np.ndarray]:
for idim, data in enumerate(self._dim_data):
if data is None:
raise ValueError(
Expand Down Expand Up @@ -315,7 +315,7 @@ def shape(self) -> Optional[Tuple[int, ...]]:
def size(self) -> int:
return self._size

def subarray(self) -> List[slice, ...]:
def subarray(self) -> Tuple[slice, ...]:
raise RuntimeError("Cannot construct a subarray for a sparse region.")

def write_metadata(self, array: tiledb.libtiledb.Array):
Expand Down
3 changes: 2 additions & 1 deletion tiledb/cf/core/source.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any, Mapping, Optional, Protocol, Tuple, Union
from typing import Any, Mapping, Optional, Tuple, Union

import numpy as np
from typing_extensions import Protocol


class FieldData(Protocol):
Expand Down

0 comments on commit ae0a02b

Please sign in to comment.