Skip to content

Commit

Permalink
Fix filter tables (scverse#619)
Browse files Browse the repository at this point in the history
* fix filter_tables

* add test

* add fix to changelog

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
melonora and pre-commit-ci[bot] authored Jul 6, 2024
1 parent c3ad40c commit 95d69ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning][].

### Minor

- Relaxing `spatial-image` package requirement #616
- Relaxing `spatial-image` package requirement #616

## [0.2.0] - 2024-07-03

Expand Down Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning][].
### Fixed

- Preserve channel names of multi-scale images in `transform` (#379)
- Fix `filter_by_coordinate_system` with SpatialData object having a table not annotating an element (#619)

## [0.1.2] - 2024-03-30

Expand Down
2 changes: 2 additions & 0 deletions src/spatialdata/_core/spatialdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ def _filter_tables(
if include_orphan_tables and not table.uns.get(TableModel.ATTRS_KEY):
tables[table_name] = table
continue
if not include_orphan_tables and not table.uns.get(TableModel.ATTRS_KEY):
continue
if table_name in names_tables_to_keep:
tables[table_name] = table
continue
Expand Down
8 changes: 8 additions & 0 deletions tests/core/query/test_relational_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,14 @@ def test_filter_table_categorical_bug(shapes):
shapes.filter_by_coordinate_system("global")


def test_filter_table_non_annotating(full_sdata):
obs = pd.DataFrame({"test": ["a", "b", "c"]})
adata = AnnData(obs=obs)
table = TableModel.parse(adata)
full_sdata["table"] = table
full_sdata.filter_by_coordinate_system("global")


def test_labels_table_joins(full_sdata):
element_dict, table = join_spatialelement_table(
sdata=full_sdata,
Expand Down

0 comments on commit 95d69ff

Please sign in to comment.