Skip to content

Commit

Permalink
Make all coordinates coords and add type annotations. (#81)
Browse files Browse the repository at this point in the history
- Changes `ids`, `slices`, and `coords` to all be just `coords`
- Adds appropriate annotations for each type.
  • Loading branch information
thetorpedodog authored Jan 17, 2023
1 parent 9b8591a commit 928fa0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions python-spec/src/somacore/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

import abc
from typing import Any, Iterator, Optional, Sequence, Tuple, TypeVar, Union
from typing import Iterator, Optional, Sequence, Tuple, TypeVar, Union

import pyarrow
from typing_extensions import Final
Expand All @@ -28,7 +28,7 @@ class DataFrame(base.SOMAObject, metaclass=abc.ABCMeta):
@abc.abstractmethod
def read(
self,
ids, # TODO: Specify type
coords: options.SparseDFCoords,
column_names: Optional[Sequence[str]] = None,
*,
batch_size: options.BatchSize = options.BatchSize(),
Expand Down Expand Up @@ -161,7 +161,7 @@ class SparseNDArray(NDArray, metaclass=abc.ABCMeta):
@abc.abstractmethod
def read(
self,
slices: Any, # TODO: Define this type.
coords: options.SparseNDCoords,
*,
batch_size: options.BatchSize = options.BatchSize(),
partitions: Optional[options.ReadPartitions] = None,
Expand Down
8 changes: 4 additions & 4 deletions python-spec/src/somacore/query/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def obs(
"""Returns ``obs`` as an Arrow table iterator. [lifecycle: experimental]"""
obs_query = self._matrix_axis_query.obs
return self._obs_df.read(
ids=obs_query.coords,
obs_query.coords,
value_filter=obs_query.value_filter,
column_names=column_names,
)
Expand All @@ -92,7 +92,7 @@ def var(
"""Returns ``var`` as an Arrow table iterator. [lifecycle: experimental]"""
var_query = self._matrix_axis_query.var
return self._var_df.read(
ids=var_query.coords,
var_query.coords,
value_filter=var_query.value_filter,
column_names=column_names,
)
Expand Down Expand Up @@ -295,7 +295,7 @@ def _read_axis_dataframe(

# Do the actual query.
arrow_table = axis_df.read(
ids=axis_query.coords,
axis_query.coords,
value_filter=axis_query.value_filter,
column_names=query_columns,
).concat()
Expand Down Expand Up @@ -463,7 +463,7 @@ def var(self, val: pa.Array) -> None:

def _load_joinids(df: data.DataFrame, axq: axis.AxisQuery) -> pa.Array:
tbl = df.read(
ids=axq.coords,
axq.coords,
value_filter=axq.value_filter,
column_names=["soma_joinid"],
).concat()
Expand Down

0 comments on commit 928fa0e

Please sign in to comment.