Skip to content

Commit 99b22f9

Browse files
Make some Experiment/Query classes abstract (#244)
* make `{experiment,query}.py` classes abstract * `rm _{{test_,}eager_iter,fast_csr}.py` (moved to TileDB-SOMA) * `ExperimentAxisQuery`, `AxisIndexer` are explicitly `ABC`s * rm `somacore.ephemeral` (and associated tests)
1 parent 415c32b commit 99b22f9

17 files changed

Lines changed: 102 additions & 1451 deletions

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ readme = "./python-spec/README.md"
1313
dependencies = [
1414
"anndata",
1515
"attrs>=22.1",
16-
"numba",
1716
"numpy>=1.21",
1817
"pandas",
1918
"pyarrow",

python-spec/requirements-py3.10.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ exceptiongroup==1.2.1
55
h5py==3.11.0
66
llvmlite==0.43.0
77
natsort==8.4.0
8-
numba==0.60.0
98
numpy==2.0.0
109
packaging==24.1
1110
pandas==2.2.2

python-spec/requirements-py3.11.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ attrs==23.2.0
44
h5py==3.11.0
55
llvmlite==0.43.0
66
natsort==8.4.0
7-
numba==0.60.0
87
numpy==2.0.0
98
packaging==24.1
109
pandas==2.2.2

python-spec/requirements-py3.12.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ attrs==23.2.0
44
h5py==3.11.0
55
llvmlite==0.43.0
66
natsort==8.4.0
7-
numba==0.60.0
87
numpy==2.0.0
98
packaging==24.1
109
pandas==2.2.2

python-spec/requirements-py3.9.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ h5py==3.11.0
77
jmespath==1.0.1
88
llvmlite==0.43.0
99
natsort==8.4.0
10-
numba==0.60.0
1110
numpy==2.0.0
1211
packaging==24.1
1312
pandas==2.2.2

python-spec/src/somacore/ephemeral/__init__.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

python-spec/src/somacore/ephemeral/collections.py

Lines changed: 0 additions & 234 deletions
This file was deleted.

python-spec/src/somacore/experiment.py

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from abc import ABC
2+
from abc import abstractmethod
13
from typing import Generic, Optional, TypeVar
24

3-
from typing_extensions import Final, Self
5+
from typing_extensions import Final
46

57
from . import _mixin
68
from . import base
@@ -9,6 +11,7 @@
911
from . import measurement
1012
from . import query
1113
from . import scene
14+
from .query import ExperimentAxisQuery
1215

1316
_DF = TypeVar("_DF", bound=data.DataFrame)
1417
"""An implementation of a DataFrame."""
@@ -20,8 +23,10 @@
2023
"""The root SOMA object type of the implementation."""
2124

2225

23-
class Experiment(
24-
collection.BaseCollection[_RootSO], Generic[_DF, _MeasColl, _SceneColl, _RootSO]
26+
class Experiment( # type: ignore[misc] # __eq__ false positive
27+
collection.BaseCollection[_RootSO],
28+
Generic[_DF, _MeasColl, _SceneColl, _RootSO],
29+
ABC,
2530
):
2631
"""A collection subtype representing an annotated 2D matrix of measurements.
2732
@@ -33,22 +38,6 @@ class Experiment(
3338
Lifecycle: maturing
3439
"""
3540

36-
# This class is implemented as a mixin to be used with SOMA classes.
37-
# For example, a SOMA implementation would look like this:
38-
#
39-
# # This type-ignore comment will always be needed due to limitations
40-
# # of type annotations; it is (currently) expected.
41-
# class Experiment( # type: ignore[type-var]
42-
# ImplBaseCollection[ImplSOMAObject],
43-
# somacore.Experiment[
44-
# ImplDataFrame, # _DF
45-
# ImplMeasurement, # _MeasColl
46-
# ImplScene, # _SceneColl
47-
# ImplSOMAObject, # _RootSO
48-
# ],
49-
# ):
50-
# ...
51-
5241
__slots__ = ()
5342
soma_type: Final = "SOMAExperiment" # type: ignore[misc]
5443

@@ -77,24 +66,18 @@ class Experiment(
7766
``scene_id`` and ``False`` otherwise.
7867
"""
7968

69+
@abstractmethod
8070
def axis_query(
8171
self,
8272
measurement_name: str,
8373
*,
8474
obs_query: Optional[query.AxisQuery] = None,
8575
var_query: Optional[query.AxisQuery] = None,
86-
) -> "query.ExperimentAxisQuery[Self]":
76+
) -> ExperimentAxisQuery:
8777
"""Creates an axis query over this experiment.
8878
8979
See :class:`query.ExperimentAxisQuery` for details on usage.
9080
9181
Lifecycle: maturing
9282
"""
93-
# mypy doesn't quite understand descriptors so it issues a spurious
94-
# error here.
95-
return query.ExperimentAxisQuery( # type: ignore[type-var]
96-
self,
97-
measurement_name,
98-
obs_query=obs_query or query.AxisQuery(),
99-
var_query=var_query or query.AxisQuery(),
100-
)
83+
raise NotImplementedError

python-spec/src/somacore/query/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
ExperimentAxisQuery = query.ExperimentAxisQuery
55
AxisColumnNames = query.AxisColumnNames
6+
AxisIndexer = query.AxisIndexer
67
AxisQuery = axis.AxisQuery
78

89
__all__ = (
910
"ExperimentAxisQuery",
1011
"AxisColumnNames",
12+
"AxisIndexer",
1113
"AxisQuery",
1214
)

0 commit comments

Comments
 (0)