From 7b90ced3781c894df477cb60cc986e12f04f027c Mon Sep 17 00:00:00 2001 From: LucaMarconato <2664412+LucaMarconato@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:38:37 +0200 Subject: [PATCH 1/3] Fix xenium default value and add deprecation warning This PR is AI generated (Copilot Workspace). Related to #184 Revert the default value of `cells_as_circles` to `True` and add a deprecation warning. * Change the default value of the `cells_as_circles` parameter to `None` in the `xenium` function. * Add a deprecation warning indicating that the default will change to `False` in the next release. * Add logic to set `cells_as_circles` to `True` if it is `None` and display the deprecation warning. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/scverse/spatialdata-io/issues/184?shareId=XXXX-XXXX-XXXX-XXXX). --- src/spatialdata_io/readers/xenium.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spatialdata_io/readers/xenium.py b/src/spatialdata_io/readers/xenium.py index 741065b0..e0563d48 100644 --- a/src/spatialdata_io/readers/xenium.py +++ b/src/spatialdata_io/readers/xenium.py @@ -56,7 +56,7 @@ def xenium( *, cells_boundaries: bool = True, nucleus_boundaries: bool = True, - cells_as_circles: bool = False, + cells_as_circles: bool = None, cells_labels: bool = True, nucleus_labels: bool = True, transcripts: bool = True, @@ -146,6 +146,14 @@ def xenium( ... ) >>> sdata.write("path/to/data.zarr") """ + if cells_as_circles is None: + cells_as_circles = True + warnings.warn( + "The default value of `cells_as_circles` will change to `False` in the next release. " + "Please pass `True` explicitly to maintain the current behavior.", + DeprecationWarning, + stacklevel=2, + ) image_models_kwargs, labels_models_kwargs = _initialize_raster_models_kwargs( image_models_kwargs, labels_models_kwargs ) From caa84d46b8eb2261460cb634a5293f247400b636 Mon Sep 17 00:00:00 2001 From: Luca Marconato Date: Thu, 1 Aug 2024 21:40:11 +0200 Subject: [PATCH 2/3] fix pre-commit --- src/spatialdata_io/readers/xenium.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spatialdata_io/readers/xenium.py b/src/spatialdata_io/readers/xenium.py index e0563d48..86bcec5b 100644 --- a/src/spatialdata_io/readers/xenium.py +++ b/src/spatialdata_io/readers/xenium.py @@ -56,7 +56,7 @@ def xenium( *, cells_boundaries: bool = True, nucleus_boundaries: bool = True, - cells_as_circles: bool = None, + cells_as_circles: bool | None = None, cells_labels: bool = True, nucleus_labels: bool = True, transcripts: bool = True, From f5263e10dc696060d8d8bf4735ea8581538a1cd6 Mon Sep 17 00:00:00 2001 From: Luca Marconato Date: Thu, 1 Aug 2024 21:45:50 +0200 Subject: [PATCH 3/3] fix xenium test; fix stacklevel --- src/spatialdata_io/readers/xenium.py | 2 +- tests/test_xenium.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spatialdata_io/readers/xenium.py b/src/spatialdata_io/readers/xenium.py index 86bcec5b..b9d0e500 100644 --- a/src/spatialdata_io/readers/xenium.py +++ b/src/spatialdata_io/readers/xenium.py @@ -152,7 +152,7 @@ def xenium( "The default value of `cells_as_circles` will change to `False` in the next release. " "Please pass `True` explicitly to maintain the current behavior.", DeprecationWarning, - stacklevel=2, + stacklevel=3, ) image_models_kwargs, labels_models_kwargs = _initialize_raster_models_kwargs( image_models_kwargs, labels_models_kwargs diff --git a/tests/test_xenium.py b/tests/test_xenium.py index a6818af4..f5127a85 100644 --- a/tests/test_xenium.py +++ b/tests/test_xenium.py @@ -57,7 +57,7 @@ def test_roundtrip_with_data_limits() -> None: def test_example_data(dataset: str, expected: str) -> None: f = Path("./data") / dataset assert f.is_dir() - sdata = xenium(f) + sdata = xenium(f, cells_as_circles=False) from spatialdata import get_extent extent = get_extent(sdata, exact=False)