Skip to content

Commit

Permalink
Import implementation of ExperimentAxisQuery. (#78)
Browse files Browse the repository at this point in the history
As discussed in #76,
the full implementation of `ExperientAxisQuery` should be provided by
the base SOMA implementation since it does not vary from storage engine
to storage engine. This copies most of the implementation from the
existing TileDB version, with some reorganization to make the main
query class a little smaller:

- Pulls more of the caching-specific behavior of join IDs into the
  `_JoinIDCache` class.
- Pulls more indexing-related work into the `_AxisIndexer` class.
  - Makes formerly-public `AxisIndexer` private.
    (If this should be public this can be easily reverted.)
  - Renames methods to `by_[axis]`.
  - Separates out index caching logic from main methods.
- Uses an `_Axis` enum internally for axis selection.
- Shortens `AxisQueryResult` name.
- Make `_read` and `_AxisQueryResult` internal-only.
  • Loading branch information
thetorpedodog authored Jan 17, 2023
1 parent e935e28 commit 9b8591a
Show file tree
Hide file tree
Showing 9 changed files with 551 additions and 40 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ dependencies = [
"anndata",
"attrs>=22.1",
"numpy>=1.21",
"pandas",
"pyarrow",
"scipy",
"typing-extensions",
]
requires-python = "~=3.7"
Expand Down Expand Up @@ -43,5 +45,5 @@ single_line_exclusions = ["typing", "typing_extensions"]

[[tool.mypy.overrides]]
# These dependencies do not currently have canonical type stubs.
module = ["anndata", "pyarrow"]
module = ["anndata", "pandas", "pyarrow", "scipy"]
ignore_missing_imports = true
9 changes: 9 additions & 0 deletions python-spec/requirements-py3.10.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
anndata==0.8.0
attrs==22.2.0
h5py==3.7.0
natsort==8.2.0
numpy==1.24.1
packaging==23.0
pandas==1.5.2
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.7
scipy==1.10.0
six==1.16.0
typing_extensions==4.4.0
11 changes: 11 additions & 0 deletions python-spec/requirements-py3.7-lint.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
anndata==0.8.0
attrs==22.2.0
h5py==3.7.0
importlib-metadata==6.0.0
mypy==0.991
mypy-extensions==0.4.3
natsort==8.2.0
numpy==1.21.6
packaging==23.0
pandas==1.3.5
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.7
scipy==1.7.3
six==1.16.0
tomli==2.0.1
typed-ast==1.5.4
typing_extensions==4.4.0
zipp==3.11.0
11 changes: 11 additions & 0 deletions python-spec/requirements-py3.7.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
anndata==0.8.0
attrs==22.2.0
h5py==3.7.0
importlib-metadata==6.0.0
natsort==8.2.0
numpy==1.21.6
packaging==23.0
pandas==1.3.5
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.7
scipy==1.7.3
six==1.16.0
typing_extensions==4.4.0
zipp==3.11.0
9 changes: 9 additions & 0 deletions python-spec/requirements-py3.8.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
anndata==0.8.0
attrs==22.2.0
h5py==3.7.0
natsort==8.2.0
numpy==1.24.1
packaging==23.0
pandas==1.5.2
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.7
scipy==1.10.0
six==1.16.0
typing_extensions==4.4.0
9 changes: 9 additions & 0 deletions python-spec/requirements-py3.9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
anndata==0.8.0
attrs==22.2.0
h5py==3.7.0
natsort==8.2.0
numpy==1.24.1
packaging==23.0
pandas==1.5.2
pyarrow==10.0.1
python-dateutil==2.8.2
pytz==2022.7
scipy==1.10.0
six==1.16.0
typing_extensions==4.4.0
2 changes: 2 additions & 0 deletions python-spec/src/somacore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from somacore import ephemeral
from somacore import options
from somacore.query import axis
from somacore.query import query

try:
# This trips up mypy since it's a generated file:
Expand Down Expand Up @@ -37,6 +38,7 @@
ResultOrder = options.ResultOrder

AxisQuery = axis.AxisQuery
ExperimentAxisQuery = query.ExperimentAxisQuery

__all__ = (
"SOMAObject",
Expand Down
12 changes: 6 additions & 6 deletions python-spec/src/somacore/composed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Implementations of the composed SOMA data types."""

from typing import Optional

from typing_extensions import Final

from somacore import _wrap
Expand Down Expand Up @@ -76,13 +74,15 @@ def axis_query(
self,
measurement_name: str,
*,
obs_query: Optional[axis.AxisQuery] = None,
var_query: Optional[axis.AxisQuery] = None,
) -> query.ExperimentAxisQuery:
obs_query: axis.AxisQuery = axis.AxisQuery(),
var_query: axis.AxisQuery = axis.AxisQuery(),
) -> "query.ExperimentAxisQuery":
"""Creates an axis query over this experiment.
See :class:`query.ExperimentAxisQuery` for details on usage.
"""
raise NotImplementedError()
return query.ExperimentAxisQuery(
self, measurement_name, obs_query=obs_query, var_query=var_query
)

soma_type: Final = "SOMAExperiment"
Loading

0 comments on commit 9b8591a

Please sign in to comment.