Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
eaafdd1
changed pyproject to zarr>=3
LucaMarconato Aug 18, 2025
3047662
adjust dependencies
LucaMarconato Aug 18, 2025
9f26ce0
wip
LucaMarconato Aug 18, 2025
241bbfe
more fixes
LucaMarconato Aug 18, 2025
bdb6da0
update ome-zarr dep
melonora Aug 26, 2025
e3a53df
Add zarr v3 formats
melonora Aug 26, 2025
41b980f
refactoring formats
LucaMarconato Aug 26, 2025
cf6e90b
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Aug 26, 2025
67d2dd9
wip replace parse_url() with _open_zarr_store()
LucaMarconato Aug 26, 2025
5d0b0cf
update way of writing transforms, update typehints
melonora Aug 27, 2025
2c486b5
attempt fix consolidated metadata, fix channel names write
melonora Aug 29, 2025
fa4622f
fix partial read tests
melonora Aug 29, 2025
4137c5e
fix path
melonora Aug 29, 2025
90c8f92
access name in group directly
melonora Aug 29, 2025
c9a610b
fix read in consolidated metadata
melonora Aug 31, 2025
e6236e6
initial ugly fix groups and consolidated metadata when deleting
melonora Aug 31, 2025
3e63bfe
fix reading back table
melonora Sep 1, 2025
3c298a4
open group without using consolidated metadata when writing
melonora Sep 1, 2025
b6c2885
revert adding labels
melonora Sep 1, 2025
1127edd
fix read / write issues with consolidated metadata
melonora Sep 2, 2025
2502629
use_consolidated False when writing transforms
melonora Sep 2, 2025
d398e96
add ome_format arg
melonora Sep 2, 2025
0fd4cce
check valid element formats in container format
melonora Sep 3, 2025
484489e
uncomment code arrayNotFoundError
melonora Sep 3, 2025
ff4cfee
remove future annotations import
melonora Sep 3, 2025
4d9003c
Merge branch 'main' into zarrv3
melonora Sep 3, 2025
89b53f0
update workflow mac version
melonora Sep 3, 2025
607580a
drop python 3.10
melonora Sep 3, 2025
75e656b
change target python version and readthedocs python version
melonora Sep 3, 2025
b977b36
minor updates
melonora Sep 3, 2025
0cfd29f
update Self import
melonora Sep 3, 2025
3d0c3eb
fix ome errors
melonora Sep 3, 2025
fc7efda
add windows workflow
melonora Sep 3, 2025
46c7b34
prevent consolidation labels group when deleting element
melonora Sep 3, 2025
38f29fe
add shapes test
melonora Sep 3, 2025
a88c7e7
fix shape conversion
melonora Sep 3, 2025
16aa529
update dask dependency because of zarr v3
melonora Sep 3, 2025
bdea210
fix multipoly
melonora Sep 3, 2025
ebc5080
fix invalid read name test
melonora Sep 3, 2025
6ba53e4
use UPath
melonora Sep 3, 2025
9608232
fix paths
melonora Sep 3, 2025
dd5bc23
resolve paths
melonora Sep 3, 2025
8d788e0
refactor overwrite transformations
melonora Sep 4, 2025
a48ba23
refactor
melonora Sep 4, 2025
6c5ee98
further refactor, add docstrings
melonora Sep 4, 2025
25aca86
refactor io_raster
melonora Sep 4, 2025
934c2bf
several refactors io
melonora Sep 4, 2025
ee78d30
war on warnings
melonora Sep 5, 2025
42923c4
checks backward compatibility
melonora Sep 6, 2025
f11d683
correct test
melonora Sep 6, 2025
2b71939
further reduce warnings
melonora Sep 6, 2025
94971cb
remove log with no useful info
melonora Sep 6, 2025
5672e19
remove log as it is stated in doc string
melonora Sep 6, 2025
6a67034
move log to info in docstring
melonora Sep 6, 2025
68ce29f
remove deprecated warning
melonora Sep 7, 2025
82f12b0
get rid of categorical and str casting warnings
melonora Sep 7, 2025
bf607b3
below 1000 warnings
melonora Sep 7, 2025
20469f8
further reduction of warnings
melonora Sep 7, 2025
429db46
remove deprecated code
melonora Sep 7, 2025
2a5ec5b
correct location for storing transforms
melonora Sep 7, 2025
016da2e
consistent naming
melonora Sep 8, 2025
3e5490e
update according to ome-zarr-py
melonora Sep 8, 2025
be1ae2f
correct docstring
melonora Sep 8, 2025
8873fa0
update docstring
melonora Sep 8, 2025
b1ade7e
remove todo
melonora Sep 8, 2025
421b56f
remove unassigned function call
melonora Sep 8, 2025
0bb8bc9
refactor new _open_zarr_store to _resolve_zarr_store
melonora Sep 8, 2025
fd08907
silence zarr parquet warnings
melonora Sep 8, 2025
74a81cd
change overwriting warning, silence in tests
melonora Sep 8, 2025
2bc809c
silence overwriting warnings
melonora Sep 8, 2025
6e43b42
silence chunk warning
melonora Sep 8, 2025
bd0468e
remove argument from docstring, update typehint
melonora Sep 9, 2025
54e0d87
update typehint
melonora Sep 9, 2025
fc052d7
small fixes
LucaMarconato Sep 9, 2025
421d45c
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 9, 2025
fc41701
merge
melonora Sep 9, 2025
7c1bd7e
fail if not root does not exist
melonora Sep 9, 2025
b9e5d92
write out function name
melonora Sep 9, 2025
8544684
small fixes
LucaMarconato Sep 9, 2025
6840304
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 9, 2025
fa62038
initial replacement parse_url
melonora Sep 9, 2025
c21ac8c
initial replacement parse_url
melonora Sep 9, 2025
6a0c2d0
alter docstring
melonora Sep 10, 2025
0c44ddb
adjust argument docstring
melonora Sep 10, 2025
a2a2a45
remove overwrite warnings
melonora Sep 10, 2025
ac56372
fix test
melonora Sep 10, 2025
22fce41
replace parse_url
melonora Sep 10, 2025
92390d2
change version
melonora Sep 10, 2025
ffc7ab0
remove type hints from docstrings
melonora Sep 10, 2025
1decd22
refactor to one function
melonora Sep 10, 2025
daa804b
change typehint
melonora Sep 10, 2025
564abae
remove typehints from docstring
melonora Sep 10, 2025
aa8e686
remove type hint return in docstring
melonora Sep 10, 2025
36c5987
remove comment
melonora Sep 10, 2025
48f0b81
ensure comment added back
melonora Sep 10, 2025
b6e23f7
fix channel metadata
melonora Sep 10, 2025
7959e02
get rid of TableValidateMixin
melonora Sep 10, 2025
8e16c8e
code fixes
LucaMarconato Sep 10, 2025
62101b6
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 10, 2025
906e3a9
fix
LucaMarconato Sep 10, 2025
878dce1
remove format without effect
melonora Sep 10, 2025
a9f4ca0
remove unnecessary catch warnings
melonora Sep 10, 2025
09ac152
add todo
melonora Sep 10, 2025
f6bae29
fixes
LucaMarconato Sep 10, 2025
76157b6
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 10, 2025
7997f3b
remove unnecessary .get('ome')
melonora Sep 10, 2025
28e8c3e
merge
melonora Sep 10, 2025
b19256b
add clarifying comment
melonora Sep 10, 2025
2bed0ce
wip tests readwrite across formats
LucaMarconato Sep 10, 2025
a616e77
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 10, 2025
21e5794
return None instead of AnnData
melonora Sep 10, 2025
46c0753
remove TODO
melonora Sep 10, 2025
9c3914e
remove invalid characters from test
melonora Sep 10, 2025
0f230b7
remove unused fixture and commented code
melonora Sep 10, 2025
5f5b8d7
almost completed extending readwrite tests to all container versions
LucaMarconato Sep 10, 2025
a190626
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 10, 2025
02a5df7
add OSError
melonora Sep 10, 2025
f10c9bf
partial fix writing empty spatialdata
melonora Sep 10, 2025
e731261
fix type
melonora Sep 11, 2025
b431781
fix overwrite when no zarr store
melonora Sep 11, 2025
4e33d98
fix write element to empty directory location
melonora Sep 11, 2025
04aae9f
correct no zarr store write test
melonora Sep 11, 2025
594003b
remove unnecessary code
melonora Sep 11, 2025
17eaf8d
fix write_element
LucaMarconato Sep 11, 2025
e38e5ff
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 11, 2025
ffdc9da
delete group isntead of .zattrs
melonora Sep 11, 2025
8f0f438
remove parse_url
LucaMarconato Sep 11, 2025
dacac00
Merge branch 'zarrv3' of https://github.com/scverse/spatialdata into …
LucaMarconato Sep 11, 2025
d3191a3
removed logger.ingo() and most of remaining warnings from tests
LucaMarconato Sep 11, 2025
48ad6fd
addressing review comments
LucaMarconato Sep 11, 2025
a9e7242
addressed consolidate metadata comment
LucaMarconato Sep 11, 2025
71adfe1
make full coverage of _validate_can_safely_write_to_path() easier to …
LucaMarconato Sep 11, 2025
7c56b25
restore partial read/write tests
melonora Sep 12, 2025
c88b488
minor changes in test_partial_read(); code review finished
LucaMarconato Sep 12, 2025
51292d5
support ome-zarr-py master
LucaMarconato Sep 16, 2025
d2b0463
fix docs
LucaMarconato Sep 16, 2025
709bdd8
ensure multiscales written correctly
melonora Sep 17, 2025
59df1ca
refactor read_zarr (#982)
melonora Sep 17, 2025
5521a2a
Refactor zarrv3 (#986)
melonora Sep 17, 2025
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
6 changes: 4 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.12"]
python: ["3.11", "3.13"]
os: [ubuntu-latest]
include:
- os: macos-latest
python: "3.10"
python: "3.11"
- os: macos-latest
python: "3.12"
pip-flags: "--pre"
name: "Python 3.12 (pre-release)"
- os: windows-latest
python: "3.11"

env:
OS: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.10
python_version = 3.11

ignore_errors = False
warn_redundant_casts = True
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.10"
python: "3.11"
sphinx:
configuration: docs/conf.py
fail_on_warning: true
Expand Down
4 changes: 2 additions & 2 deletions docs/api/data_formats.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Data formats (advanced)

The SpatialData format is defined as a set of versioned subclasses of `spatialdata._io.format.SpatialDataFormat`, one per type of element.
These classes are useful to ensure backward compatibility whenever a major version change is introduced. We also provide pointers to the latest format.
The SpatialData format is defined as a set of versioned subclasses of `ome_zarr.format.Format`, one per type of element. The `spatialdata.SpatialDataFormatType` is a union type encompassing the possible valid formats.
These format subclasses are useful to ensure backward compatibility whenever a major version change is introduced. We also provide pointers to the latest format.

```{eval-rst}
.. currentmodule:: spatialdata._io.format
Expand Down
1 change: 0 additions & 1 deletion docs/api/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ use any of the [spatialdata-io readers](https://spatialdata.scverse.org/projects
.. currentmodule:: spatialdata

.. autofunction:: read_zarr
.. autofunction:: save_transformations
.. autofunction:: get_dask_backing_files
```
22 changes: 15 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ maintainers = [
urls.Documentation = "https://spatialdata.scverse.org/en/latest"
urls.Source = "https://github.com/scverse/spatialdata.git"
urls.Home-page = "https://github.com/scverse/spatialdata.git"
requires-python = ">=3.10"
requires-python = ">=3.11"
dynamic= [
"version" # allow version to be set by git tags
]
Expand All @@ -25,15 +25,15 @@ dependencies = [
"anndata>=0.9.1",
"click",
"dask-image",
"dask>=2024.4.1,<=2024.11.2",
"dask>=2024.10.0,<=2024.11.2",
"datashader",
"fsspec",
"fsspec[s3,http]",
"geopandas>=0.14",
"multiscale_spatial_image>=2.0.3",
"networkx",
"numba>=0.55.0",
"numpy",
"ome_zarr>=0.8.4",
"ome_zarr>=0.12.2",
"pandas",
"pooch",
"pyarrow",
Expand All @@ -44,15 +44,17 @@ dependencies = [
"scikit-image",
"scipy",
"typing_extensions>=4.8.0",
"universal_pathlib>=0.2.6",
"xarray>=2024.10.0",
"xarray-schema",
"xarray-spatial>=0.3.5",
"zarr<3",
"zarr>=3.0.0",
]

[project.optional-dependencies]
dev = [
"bump2version",
"sentry-prevent-cli",
]
test = [
"pytest",
Expand Down Expand Up @@ -97,7 +99,13 @@ xfail_strict = true
addopts = [
# "-Werror", # if 3rd party libs raise DeprecationWarnings, just use filterwarnings below
"--import-mode=importlib", # allow using test files with same name
"-s" # print output from tests
"-s", # print output from tests
]
# These are all markers coming from xarray, dask or anndata. Added here to silence warnings.
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"gpu: run test on GPU using CuPY.",
"skip_with_pyarrow_strings: skipwhen pyarrow string conversion is turned on",
]
# info on how to use this https://stackoverflow.com/questions/57925071/how-do-i-avoid-getting-deprecationwarning-from-inside-dependencies-with-pytest
filterwarnings = [
Expand Down Expand Up @@ -131,7 +139,7 @@ exclude = [

]
line-length = 120
target-version = "py310"
target-version = "py311"

[tool.ruff.lint]
ignore = [
Expand Down
6 changes: 3 additions & 3 deletions src/spatialdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"SpatialData",
"get_extent",
"get_centroids",
"SpatialDataFormatType",
"read_zarr",
"unpad_raster",
"get_pyramid_levels",
"save_transformations",
"get_dask_backing_files",
"are_extents_equal",
"relabel_sequential",
Expand Down Expand Up @@ -79,7 +79,7 @@
)
from spatialdata._core.query.spatial_query import bounding_box_query, polygon_query
from spatialdata._core.spatialdata import SpatialData
from spatialdata._io._utils import get_dask_backing_files, save_transformations
from spatialdata._io.format import SpatialDataFormat
from spatialdata._io._utils import get_dask_backing_files
from spatialdata._io.format import SpatialDataFormatType
from spatialdata._io.io_zarr import read_zarr
from spatialdata._utils import get_pyramid_levels, unpad_raster
2 changes: 1 addition & 1 deletion src/spatialdata/_core/_deepcopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _(sdata: SpatialData) -> SpatialData:
for _, element_name, element in sdata.gen_elements():
elements_dict[element_name] = deepcopy(element)
deepcopied_attrs = _deepcopy(sdata.attrs)
return SpatialData.from_elements_dict(elements_dict, attrs=deepcopied_attrs)
return SpatialData.init_from_elements(elements_dict, attrs=deepcopied_attrs)


@deepcopy.register(DataArray)
Expand Down
5 changes: 1 addition & 4 deletions src/spatialdata/_core/_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections import UserDict
from collections.abc import Iterable, KeysView, ValuesView
from typing import TypeVar
from warnings import warn

from anndata import AnnData
from dask.dataframe import DataFrame as DaskDataFrame
Expand Down Expand Up @@ -41,9 +40,7 @@ def _remove_shared_key(self, key: str) -> None:
@staticmethod
def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | None]) -> None:
check_valid_name(key)
if key in element_keys:
warn(f"Key `{key}` already exists. Overwriting it in-memory.", UserWarning, stacklevel=2)
else:
if key not in element_keys:
try:
check_key_is_case_insensitively_unique(key, shared_keys)
except ValueError as e:
Expand Down
7 changes: 4 additions & 3 deletions src/spatialdata/_core/concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def _concatenate_tables(
TableModel.INSTANCE_KEY: instance_key,
}
merged_table.uns[TableModel.ATTRS_KEY] = attrs

return TableModel().validate(merged_table)
return TableModel().parse(merged_table)


def concatenate(
Expand Down Expand Up @@ -252,6 +251,8 @@ def _fix_ensure_unique_element_names(
tables_by_sdata.append(tables)
sdatas_fixed = []
for elements, tables in zip(elements_by_sdata, tables_by_sdata, strict=True):
sdata = SpatialData.init_from_elements(elements, tables=tables)
if tables is not None:
elements.update(tables)
sdata = SpatialData.init_from_elements(elements)
sdatas_fixed.append(sdata)
return sdatas_fixed
2 changes: 1 addition & 1 deletion src/spatialdata/_core/operations/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def transform_to_data_extent(
set_transformation(el, transformation={coordinate_system: Identity()}, set_all=True)
for k, v in sdata.tables.items():
sdata_to_return_elements[k] = v.copy()
return SpatialData.from_elements_dict(sdata_to_return_elements, attrs=sdata.attrs)
return SpatialData.init_from_elements(sdata_to_return_elements, attrs=sdata.attrs)


def _parse_element(
Expand Down
8 changes: 4 additions & 4 deletions src/spatialdata/_core/operations/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _create_sdata_from_table_and_shapes(
f"Instance key column dtype in table resulting from aggregation cannot be cast to the dtype of"
f"element {shapes_name}.index"
) from err
table.obs[region_key] = shapes_name
table.obs[region_key] = pd.Categorical([shapes_name] * len(table))
table = TableModel.parse(table, region=shapes_name, region_key=region_key, instance_key=instance_key)

# labels case, needs conversion from str to int
Expand All @@ -242,7 +242,7 @@ def _create_sdata_from_table_and_shapes(
if deepcopy:
shapes = _deepcopy(shapes)

return SpatialData.from_elements_dict({shapes_name: shapes, table_name: table})
return SpatialData.init_from_elements({shapes_name: shapes, table_name: table})


def _aggregate_image_by_labels(
Expand Down Expand Up @@ -440,7 +440,7 @@ def _aggregate_shapes(
vk = value_key[0]
if fractions_of_values is not None:
joined[ONES_COLUMN] = fractions_of_values
aggregated = joined.groupby([INDEX, vk])[ONES_COLUMN].agg(agg_func).reset_index()
aggregated = joined.groupby([INDEX, vk], observed=False)[ONES_COLUMN].agg(agg_func).reset_index()
aggregated_values = aggregated[ONES_COLUMN].values
else:
if fractions_of_values is not None:
Expand Down Expand Up @@ -478,7 +478,7 @@ def _aggregate_shapes(

anndata = ad.AnnData(
X,
obs=pd.DataFrame(index=rows_categories),
obs=pd.DataFrame(index=list(map(str, rows_categories))),
var=pd.DataFrame(index=columns_categories),
)

Expand Down
5 changes: 3 additions & 2 deletions src/spatialdata/_core/operations/rasterize_bins.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def rasterize_bins(

random_indices = RNG.choice(table.n_obs, min(20, table.n_obs), replace=True)
location_ids = table.obs[instance_key].iloc[random_indices].values
sub_df, sub_table = element.loc[location_ids], table[random_indices]
sub_df = element.loc[location_ids]
sub_table = table[random_indices]

src = np.stack([sub_table.obs[col_key] - min_col, sub_table.obs[row_key] - min_row], axis=1)
if isinstance(sub_df, GeoDataFrame):
Expand Down Expand Up @@ -281,7 +282,7 @@ def rasterize_bins_link_table_to_labels(sdata: SpatialData, table_name: str, ras
The name of the rasterized labels in the spatial data object.
"""
_, region_key, instance_key = get_table_keys(sdata[table_name])
sdata[table_name].obs[region_key] = rasterized_labels_name
sdata[table_name].obs[region_key] = pd.Categorical([rasterized_labels_name] * sdata[table_name].n_obs)
relabled_instance_key = _get_relabeled_column_name(instance_key)
sdata.set_table_annotates_spatialelement(
table_name=table_name, region=rasterized_labels_name, region_key=region_key, instance_key=relabled_instance_key
Expand Down
2 changes: 1 addition & 1 deletion src/spatialdata/_core/operations/vectorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _(gdf: GeoDataFrame, buffer_resolution: int = 16) -> GeoDataFrame:
if isinstance(gdf.geometry.iloc[0], Point):
buffered_df = gdf.copy()
buffered_df["geometry"] = buffered_df.apply(
lambda row: row.geometry.buffer(row[ShapesModel.RADIUS_KEY], resolution=buffer_resolution), axis=1
lambda row: row.geometry.buffer(row[ShapesModel.RADIUS_KEY], quad_segs=buffer_resolution), axis=1
)

# Ensure the GeoDataFrame recognizes the updated geometry column
Expand Down
10 changes: 1 addition & 9 deletions src/spatialdata/_core/query/relational_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def join_spatialelement_table(
if sdata is not None:
elements_dict = _create_sdata_elements_dict_for_join(sdata, spatial_element_names)
else:
derived_sdata = SpatialData.from_elements_dict(dict(zip(spatial_element_names, spatial_elements, strict=True)))
derived_sdata = SpatialData.init_from_elements(dict(zip(spatial_element_names, spatial_elements, strict=True)))
element_types = ["labels", "shapes", "points"]
elements_dict = defaultdict(lambda: defaultdict(dict))
for element_type in element_types:
Expand Down Expand Up @@ -738,14 +738,6 @@ def match_table_to_element(sdata: SpatialData, element_name: str, table_name: st
match_element_to_table : Function to match a spatial element to a table.
join_spatialelement_table : General function, to join spatial elements with a table with more control.
"""
if table_name is None:
warnings.warn(
"Assumption of table with name `table` being present is being deprecated in SpatialData v0.1. "
"Please provide the name of the table as argument to table_name.",
DeprecationWarning,
stacklevel=2,
)
table_name = "table"
_, table = join_spatialelement_table(
sdata=sdata, spatial_element_names=element_name, table_name=table_name, how="left", match_rows="left"
)
Expand Down
37 changes: 0 additions & 37 deletions src/spatialdata/_core/query/spatial_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,30 +797,13 @@ def _(
return queried_polygons


# TODO: we can replace the manually triggered deprecation warning heres with the decorator from Wouter
def _check_deprecated_kwargs(kwargs: dict[str, Any]) -> None:
deprecated_args = ["shapes", "points", "images", "labels"]
for arg in deprecated_args:
if arg in kwargs and kwargs[arg] is False:
warnings.warn(
f"The '{arg}' argument is deprecated and will be removed in one of the next following releases. Please "
f"filter the SpatialData object before calling this function.",
DeprecationWarning,
stacklevel=2,
)


@singledispatch
def polygon_query(
element: SpatialElement | SpatialData,
polygon: Polygon | MultiPolygon,
target_coordinate_system: str,
filter_table: bool = True,
clip: bool = False,
shapes: bool = True,
points: bool = True,
images: bool = True,
labels: bool = True,
) -> SpatialElement | SpatialData | None:
"""
Query a SpatialData object or a SpatialElement by a polygon or multipolygon.
Expand All @@ -845,18 +828,6 @@ def polygon_query(
Importantly, when clipping is enabled, the circles will be converted to polygons before the clipping. This may
affect downstream operations that rely on the circle radius or on performance, so it is recommended to disable
clipping when querying circles or when querying a `SpatialData` object that contains circles.
shapes [Deprecated]
This argument is now ignored and will be removed. Please filter the SpatialData object before calling this
function.
points [Deprecated]
This argument is now ignored and will be removed. Please filter the SpatialData object before calling this
function.
images [Deprecated]
This argument is now ignored and will be removed. Please filter the SpatialData object before calling this
function.
labels [Deprecated]
This argument is now ignored and will be removed. Please filter the SpatialData object before calling this
function.

Returns
-------
Expand All @@ -879,12 +850,7 @@ def _(
target_coordinate_system: str,
filter_table: bool = True,
clip: bool = False,
shapes: bool = True,
points: bool = True,
images: bool = True,
labels: bool = True,
) -> SpatialData:
_check_deprecated_kwargs({"shapes": shapes, "points": points, "images": images, "labels": labels})
new_elements = {}
for element_type in ["points", "images", "labels", "shapes"]:
elements = getattr(sdata, element_type)
Expand All @@ -911,7 +877,6 @@ def _(
return_request_only: bool = False,
**kwargs: Any,
) -> DataArray | DataTree | None:
_check_deprecated_kwargs(kwargs)
gdf = GeoDataFrame(geometry=[polygon])
min_x, min_y, max_x, max_y = gdf.bounds.values.flatten().tolist()
return bounding_box_query(
Expand All @@ -933,7 +898,6 @@ def _(
) -> DaskDataFrame | None:
from spatialdata.transformations import get_transformation, set_transformation

_check_deprecated_kwargs(kwargs)
polygon_gdf = _get_polygon_in_intrinsic_coordinates(points, target_coordinate_system, polygon)

points_gdf = points_dask_dataframe_to_geopandas(points, suppress_z_warning=True)
Expand Down Expand Up @@ -966,7 +930,6 @@ def _(
) -> GeoDataFrame | None:
from spatialdata.transformations import get_transformation, set_transformation

_check_deprecated_kwargs(kwargs)
polygon_gdf = _get_polygon_in_intrinsic_coordinates(element, target_coordinate_system, polygon)
polygon = polygon_gdf["geometry"].iloc[0]

Expand Down
Loading
Loading