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

Make some Experiment/Query classes abstract #244

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ readme = "./python-spec/README.md"
dependencies = [
"anndata",
"attrs>=22.1",
"numba",
"numpy>=1.21",
"pandas",
"pyarrow",
Expand Down
1 change: 0 additions & 1 deletion python-spec/requirements-py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exceptiongroup==1.2.1
h5py==3.11.0
llvmlite==0.43.0
natsort==8.4.0
numba==0.60.0
numpy==2.0.0
packaging==24.1
pandas==2.2.2
Expand Down
1 change: 0 additions & 1 deletion python-spec/requirements-py3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ attrs==23.2.0
h5py==3.11.0
llvmlite==0.43.0
natsort==8.4.0
numba==0.60.0
numpy==2.0.0
packaging==24.1
pandas==2.2.2
Expand Down
1 change: 0 additions & 1 deletion python-spec/requirements-py3.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ attrs==23.2.0
h5py==3.11.0
llvmlite==0.43.0
natsort==8.4.0
numba==0.60.0
numpy==2.0.0
packaging==24.1
pandas==2.2.2
Expand Down
1 change: 0 additions & 1 deletion python-spec/requirements-py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ h5py==3.11.0
jmespath==1.0.1
llvmlite==0.43.0
natsort==8.4.0
numba==0.60.0
numpy==2.0.0
packaging==24.1
pandas==2.2.2
Expand Down
37 changes: 9 additions & 28 deletions python-spec/src/somacore/experiment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import abc
from typing import Generic, Optional, TypeVar

from typing_extensions import Final, Self
from typing_extensions import Final

from . import _mixin
from . import base
Expand All @@ -9,6 +10,7 @@
from . import measurement
from . import query
from . import scene
from .query import ExperimentAxisQuery

_DF = TypeVar("_DF", bound=data.DataFrame)
"""An implementation of a DataFrame."""
Expand All @@ -20,8 +22,10 @@
"""The root SOMA object type of the implementation."""


class Experiment(
collection.BaseCollection[_RootSO], Generic[_DF, _MeasColl, _SceneColl, _RootSO]
class Experiment( # type: ignore[misc] # __eq__ false positive
collection.BaseCollection[_RootSO],
Generic[_DF, _MeasColl, _SceneColl, _RootSO],
abc.ABC,
):
"""A collection subtype representing an annotated 2D matrix of measurements.

Expand All @@ -33,22 +37,6 @@ class Experiment(
Lifecycle: maturing
"""

# This class is implemented as a mixin to be used with SOMA classes.
# For example, a SOMA implementation would look like this:
#
# # This type-ignore comment will always be needed due to limitations
# # of type annotations; it is (currently) expected.
# class Experiment( # type: ignore[type-var]
# ImplBaseCollection[ImplSOMAObject],
# somacore.Experiment[
# ImplDataFrame, # _DF
# ImplMeasurement, # _MeasColl
# ImplScene, # _SceneColl
# ImplSOMAObject, # _RootSO
# ],
# ):
# ...

__slots__ = ()
soma_type: Final = "SOMAExperiment" # type: ignore[misc]

Expand Down Expand Up @@ -83,18 +71,11 @@ def axis_query(
*,
obs_query: Optional[query.AxisQuery] = None,
var_query: Optional[query.AxisQuery] = None,
) -> "query.ExperimentAxisQuery[Self]":
) -> ExperimentAxisQuery:
"""Creates an axis query over this experiment.

See :class:`query.ExperimentAxisQuery` for details on usage.

Lifecycle: maturing
"""
# mypy doesn't quite understand descriptors so it issues a spurious
# error here.
return query.ExperimentAxisQuery( # type: ignore[type-var]
self,
measurement_name,
obs_query=obs_query or query.AxisQuery(),
var_query=var_query or query.AxisQuery(),
)
raise NotImplementedError
2 changes: 2 additions & 0 deletions python-spec/src/somacore/query/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

ExperimentAxisQuery = query.ExperimentAxisQuery
AxisColumnNames = query.AxisColumnNames
AxisIndexer = query.AxisIndexer
AxisQuery = axis.AxisQuery

__all__ = (
"ExperimentAxisQuery",
"AxisColumnNames",
"AxisIndexer",
"AxisQuery",
)
51 changes: 0 additions & 51 deletions python-spec/src/somacore/query/_eager_iter.py

This file was deleted.

Loading
Loading