Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_fast_csr type fix, docstr/pre-commit tweaks #242

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tag_regex = '^python-(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$'
[tool.ruff]
lint.extend-select = ["I"]
target-version = "py39"
fix = true

[tool.ruff.lint.isort]
force-single-line = true
Expand Down
15 changes: 8 additions & 7 deletions python-spec/src/somacore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ def closed(self) -> bool:
raise NotImplementedError()

soma_type: ClassVar[LiteralString]
"""A string describing the SOMA type of this object. This is constant."""
# This uses ClassVar since you can't do abstract class properties.
# This is the equivalent, just without abc-based automatic verification.
#
# Overrides are marked Final with an ignore[misc] because mypy by default
# wants this to be mutable, and doesn't like overriding the mutable member
# with a Final member.
"""A string describing the SOMA type of this object. This is constant.

This uses ClassVar since you can't do abstract class properties.
This is the equivalent, just without abc-based automatic verification.
Overrides are marked Final with an ignore[misc] because mypy by default
wants this to be mutable, and doesn't like overriding the mutable member
with a Final member.
"""

# Context management

Expand Down
2 changes: 1 addition & 1 deletion python-spec/src/somacore/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
_MeasColl = TypeVar("_MeasColl", bound=collection.Collection[measurement.Measurement])
"""An implementation of a collection of Measurements."""
_SceneColl = TypeVar("_SceneColl", bound=collection.Collection[scene.Scene])
"""An implemenation of a collection of spatial data."""
"""An implementation of a collection of spatial data."""
_RootSO = TypeVar("_RootSO", bound=base.SOMAObject)
"""The root SOMA object type of the implementation."""

Expand Down
4 changes: 2 additions & 2 deletions python-spec/src/somacore/query/_fast_csr.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class _CSRAccumulator:

def __init__(
self,
obs_joinids: npt.NDArray[np.int64],
var_joinids: npt.NDArray[np.int64],
obs_joinids: pa.Array,
var_joinids: pa.Array,
pool: futures.Executor,
index_factory: types.IndexFactory,
):
Expand Down
1 change: 0 additions & 1 deletion python-spec/src/somacore/query/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ def _read(
) -> "_AxisQueryResult":
"""Reads the entire query result in memory.


This is a low-level routine intended to be used by loaders for other
in-core formats, such as AnnData, which can be created from the
resulting objects.
Expand Down
9 changes: 6 additions & 3 deletions python-spec/src/somacore/query/types.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Common types used across SOMA query modules."""

from typing import Any, Callable
from typing import Any, Callable, Union

import numpy as np
import numpy.typing as npt
import pyarrow as pa
from typing_extensions import Protocol

_Array = Union[npt.NDArray[np.int64], pa.Array]


class IndexLike(Protocol):
"""The basics of what we expect an Index to be.
Expand All @@ -16,11 +19,11 @@ class IndexLike(Protocol):
not as a full specification of the types and behavior of ``get_indexer``.
"""

def get_indexer(self, target: npt.NDArray[np.int64]) -> Any:
def get_indexer(self, target: _Array) -> Any:
"""Something compatible with Pandas' Index.get_indexer method."""


IndexFactory = Callable[[npt.NDArray[np.int64]], "IndexLike"]
IndexFactory = Callable[[_Array], "IndexLike"]
"""Function that builds an index over the given NDArray.

This interface is implemented by the callable ``pandas.Index``.
Expand Down
Loading