Skip to content

Commit

Permalink
[python] Rename set_reader_coords to set_coords (#3253) (#3255)
Browse files Browse the repository at this point in the history
Co-authored-by: John Kerl <kerl.john.r@gmail.com>
  • Loading branch information
github-actions[bot] and johnkerl authored Oct 29, 2024
1 parent dc34c35 commit 0829e20
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def read(
if value_filter is not None:
sr.set_condition(QueryCondition(value_filter), handle.schema)

self._set_reader_coords(sr, coords)
self._set_coords(sr, coords)

# # TODO: batch_size
return TableReadIter(sr)
Expand Down Expand Up @@ -744,7 +744,7 @@ def write(

return self

def _set_reader_coord(
def _set_coord(
self,
sr: clib.SOMAArray,
dim_idx: int,
Expand All @@ -765,7 +765,7 @@ def _set_reader_coord(
return True

if isinstance(coord, (Sequence, np.ndarray)):
if self._set_reader_coord_by_py_seq_or_np_array(sr, dim_idx, dim, coord):
if self._set_coord_by_py_seq_or_np_array(sr, dim_idx, dim, coord):
return True

if isinstance(coord, slice):
Expand All @@ -775,7 +775,7 @@ def _set_reader_coord(

if isinstance(coord, slice):
_util.validate_slice(coord)
if self._set_reader_coord_by_numeric_slice(sr, dim_idx, dim, coord):
if self._set_coord_by_numeric_slice(sr, dim_idx, dim, coord):
return True

domain = self.domain[dim_idx]
Expand Down Expand Up @@ -814,12 +814,12 @@ def _set_reader_coord(
sr.set_dim_ranges_int64(dim.name, [(istart, istop)])
return True

if super()._set_reader_coord(sr, dim_idx, dim, coord):
if super()._set_coord(sr, dim_idx, dim, coord):
return True

return False

def _set_reader_coord_by_py_seq_or_np_array(
def _set_coord_by_py_seq_or_np_array(
self,
sr: clib.SOMAArray,
dim_idx: int,
Expand Down Expand Up @@ -860,7 +860,7 @@ def _set_reader_coord_by_py_seq_or_np_array(

raise ValueError(f"unhandled type {dim.type} for index column named {dim.name}")

def _set_reader_coord_by_numeric_slice(
def _set_coord_by_numeric_slice(
self, sr: clib.SOMAArray, dim_idx: int, dim: pa.Field, coord: Slice[Any]
) -> bool:
try:
Expand Down
4 changes: 2 additions & 2 deletions apis/python/src/tiledbsoma/_dense_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def read(
timestamp=handle.timestamp and (0, handle.timestamp),
)

self._set_reader_coords(sr, coords)
self._set_coords(sr, coords)

arrow_tables = []
while True:
Expand Down Expand Up @@ -329,7 +329,7 @@ def write(
input = np.ascontiguousarray(input)
order = clib.ResultOrder.rowmajor
clib_dense_array.reset(result_order=order)
self._set_reader_coords(clib_dense_array, new_coords)
self._set_coords(clib_dense_array, new_coords)
clib_dense_array.write(input)

tiledb_write_options = TileDBWriteOptions.from_platform_config(platform_config)
Expand Down
2 changes: 1 addition & 1 deletion apis/python/src/tiledbsoma/_point_cloud_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def read(
if value_filter is not None:
sr.set_condition(QueryCondition(value_filter), handle.schema)

self._set_reader_coords(sr, coords)
self._set_coords(sr, coords)

# # TODO: batch_size
return TableReadIter(sr)
Expand Down
2 changes: 1 addition & 1 deletion apis/python/src/tiledbsoma/_read_iters.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _table_reader(self) -> Iterator[BlockwiseTableReadIterResult]:
self.sr.reset(**kwargs)
step_coords = list(self.coords)
step_coords[self.major_axis] = coord_chunk
self.array._set_reader_coords(self.sr, step_coords)
self.array._set_coords(self.sr, step_coords)

joinids = list(self.joinids)
joinids[self.major_axis] = pa.array(coord_chunk)
Expand Down
6 changes: 3 additions & 3 deletions apis/python/src/tiledbsoma/_soma_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _maxdomain(self) -> Tuple[Tuple[Any, Any], ...]:
"""
return self._handle.maxdomain

def _set_reader_coords(self, sr: clib.SOMAArray, coords: Sequence[object]) -> None:
def _set_coords(self, sr: clib.SOMAArray, coords: Sequence[object]) -> None:
"""Parses the given coords and sets them on the SOMA Reader."""
if not is_nonstringy_sequence(coords):
raise TypeError(
Expand All @@ -162,13 +162,13 @@ def _set_reader_coords(self, sr: clib.SOMAArray, coords: Sequence[object]) -> No
)
for i, coord in enumerate(coords):
dim = self.schema.field(i)
if not self._set_reader_coord(sr, i, dim, coord):
if not self._set_coord(sr, i, dim, coord):
raise TypeError(
f"coord type {type(coord)} for dimension {dim.name}"
f" (slot {i}) unsupported"
)

def _set_reader_coord(
def _set_coord(
self, sr: clib.SOMAArray, dim_idx: int, dim: pa.Field, coord: object
) -> bool:
"""Parses a single coordinate entry.
Expand Down
8 changes: 4 additions & 4 deletions apis/python/src/tiledbsoma/_sparse_nd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ def write(
f"Unsupported Arrow type or non-arrow type for values argument: {type(values)}"
)

def _set_reader_coord(
def _set_coord(
self, sr: clib.SOMAArray, dim_idx: int, dim: pa.Field, coord: object
) -> bool:
if super()._set_reader_coord(sr, dim_idx, dim, coord):
if super()._set_coord(sr, dim_idx, dim, coord):
return True
if isinstance(coord, Sequence):
if pa.types.is_int64(dim.type):
Expand Down Expand Up @@ -642,7 +642,7 @@ def coos(self, shape: Optional[NTuple] = None) -> SparseCOOTensorReadIter:
"""
if shape is not None and (len(shape) != len(self.shape)):
raise ValueError(f"shape must be a tuple of size {len(self.shape)}")
self.array._set_reader_coords(self.sr, self.coords)
self.array._set_coords(self.sr, self.coords)
return SparseCOOTensorReadIter(self.sr, shape or self.shape)

def tables(self) -> TableReadIter:
Expand All @@ -653,7 +653,7 @@ def tables(self) -> TableReadIter:
Lifecycle:
Maturing.
"""
self.array._set_reader_coords(self.sr, self.coords)
self.array._set_coords(self.sr, self.coords)
return TableReadIter(self.sr)

def blockwise(
Expand Down
12 changes: 6 additions & 6 deletions apis/python/src/tiledbsoma/_spatial_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def write(
"""
raise NotImplementedError("must be implemented by child class")

def _set_reader_coord(
def _set_coord(
self,
sr: clib.SOMAArray,
dim_idx: int,
Expand All @@ -195,7 +195,7 @@ def _set_reader_coord(
return True

if isinstance(coord, (Sequence, np.ndarray)):
if self._set_reader_coord_by_py_seq_or_np_array(sr, dim_idx, dim, coord):
if self._set_coord_by_py_seq_or_np_array(sr, dim_idx, dim, coord):
return True

if isinstance(coord, slice):
Expand All @@ -205,7 +205,7 @@ def _set_reader_coord(

if isinstance(coord, slice):
_util.validate_slice(coord)
if self._set_reader_coord_by_numeric_slice(sr, dim_idx, dim, coord):
if self._set_coord_by_numeric_slice(sr, dim_idx, dim, coord):
return True

domain = self.domain[dim_idx]
Expand Down Expand Up @@ -244,12 +244,12 @@ def _set_reader_coord(
sr.set_dim_ranges_int64(dim.name, [(istart, istop)])
return True

if super()._set_reader_coord(sr, dim_idx, dim, coord):
if super()._set_coord(sr, dim_idx, dim, coord):
return True

return False

def _set_reader_coord_by_py_seq_or_np_array(
def _set_coord_by_py_seq_or_np_array(
self,
sr: clib.SOMAArray,
dim_idx: int,
Expand Down Expand Up @@ -290,7 +290,7 @@ def _set_reader_coord_by_py_seq_or_np_array(

raise ValueError(f"unhandled type {dim.type} for index column named {dim.name}")

def _set_reader_coord_by_numeric_slice(
def _set_coord_by_numeric_slice(
self, sr: clib.SOMAArray, dim_idx: int, dim: pa.Field, coord: Slice[Any]
) -> bool:
try:
Expand Down

0 comments on commit 0829e20

Please sign in to comment.