Hi,
I’m encountering an IndexError when using sd.filter_by_table_query() on a SpatialData object.
Versions
spatialdata: 0.7.3
anndata: 0.12.6
annsel: 0.1.2
Variables
print(type(keep_mask))
><class 'pandas.Series'>
print(getattr(keep_mask, "dtype", None))
>bool
print(getattr(keep_mask, "shape", None))
>(576096,)
keep_mask.index.equals(sdata.tables["table"].obs.index)
>True
Code
import annsel as an
import spatialdata as sd
sdata_filtered = sd.filter_by_table_query(
sdata,
table_name="table",
obs_expr=keep_mask,
)
Error
File .../python3.14/site-packages/spatialdata/_core/query/relational_query.py:898, in filter_by_table_query
filtered_table: AnnData = sdata_subset.tables[table_name].an.filter(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
obs=obs_expr, var=var_expr, x=x_expr, obs_names=obs_names_expr, var_names=var_names_expr, layer=layer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File .../python3.14/site-packages/annsel/tl/anndata.py:80, in filter
_adata = _filter(self._obj, obs, var, x, obs_names, var_names, obsm, varm, layer)
File ...python3.14/site-packages/annsel/tl/_filter.py:84, in _filter
return _construct_adata_from_indices(adata, final_obs_idx, final_var_idx)
File .../python3.14/site-packages/annsel/core/utils.py:52, in _construct_adata_from_indices
_adata = adata[obs_idx.to_series(), var_idx.to_series()]
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File .../python3.14/site-packages/anndata/_core/anndata.py:1049, in __getitem__
oidx, vidx = self._normalize_indices(index)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File .../python3.14/site-packages/anndata/_core/anndata.py:1030, in _normalize_indices
return _normalize_indices(index, self.obs_names, self.var_names)
File .../python3.14/site-packages/anndata/_core/index.py:35, in _normalize_indices
ax0 = _normalize_index(ax0, names0)
File .../python3.14/site-packages/anndata/_core/index.py:114, in _normalize_index
raise IndexError()
IndexError
Is this a known compatibility issue between annsel 0.1.2 and anndata 0.12.x, or is there something wrong with how I’m passing the boolean filter?