napari-spatialdata 0.5.3__tar.gz → 0.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/workflows/test.yml +6 -1
  2. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.mypy.ini +1 -1
  3. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.pre-commit-config.yaml +4 -4
  4. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/CHANGELOG.md +18 -0
  5. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/PKG-INFO +5 -4
  6. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/README.md +1 -1
  7. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/benchmark_qt_widget.py +4 -0
  8. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/index.md +1 -0
  9. napari_spatialdata-0.5.4/docs/limitations.md +8 -0
  10. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/notebooks/mibitof_analysis.ipynb +10 -11
  11. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/notebooks/nanostring_analysis.ipynb +11 -11
  12. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/notebooks/scatterwidget.ipynb +20 -19
  13. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/notebooks/spatialdata.ipynb +12 -11
  14. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/examples/spatialdata_visium.py +2 -1
  15. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/pyproject.toml +2 -2
  16. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/setup.cfg +3 -2
  17. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_interactive.py +27 -2
  18. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_model.py +25 -16
  19. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_reader.py +1 -1
  20. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_scatterwidgets.py +17 -16
  21. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_version.py +2 -2
  22. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_view.py +5 -3
  23. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_viewer.py +5 -8
  24. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_widgets.py +32 -22
  25. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/constants/_pkg_constants.py +6 -5
  26. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/constants/_utils.py +2 -1
  27. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/utils/_test_utils.py +4 -5
  28. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/utils/_utils.py +35 -40
  29. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/PKG-INFO +5 -4
  30. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/SOURCES.txt +1 -0
  31. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/conftest.py +15 -6
  32. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_cli.py +2 -1
  33. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_interactive.py +30 -1
  34. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_scatterwidgets.py +1 -0
  35. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_spatialdata.py +10 -10
  36. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_utils.py +2 -1
  37. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_view.py +3 -2
  38. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_viewer.py +5 -4
  39. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/test_widgets.py +13 -12
  40. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tox.ini +2 -2
  41. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/BENCHMARK_FAIL_TEMPLATE.md +0 -0
  42. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/dependabot.yml +0 -0
  43. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/workflows/benchmarks.yml +0 -0
  44. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/workflows/benchmarks_report.yml +0 -0
  45. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.github/workflows/release.yml +0 -0
  46. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.gitignore +0 -0
  47. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.napari/DESCRIPTION.md +0 -0
  48. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/.readthedocs.yaml +0 -0
  49. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/LICENSE +0 -0
  50. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/MANIFEST.in +0 -0
  51. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/asv.conf.json +0 -0
  52. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/Readme.md +0 -0
  53. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/__init__.py +0 -0
  54. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/benchmark.in +0 -0
  55. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/benchmark.txt +0 -0
  56. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/benchmarks/benchmark_model.py +0 -0
  57. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/Makefile +0 -0
  58. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/_static/.gitkeep +0 -0
  59. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/_templates/.gitkeep +0 -0
  60. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/_templates/autosummary/class.rst +0 -0
  61. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/api.md +0 -0
  62. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/cli.md +0 -0
  63. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/conf.py +0 -0
  64. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/contributing.md +0 -0
  65. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/extensions/typed_returns.py +0 -0
  66. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/make.bat +0 -0
  67. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/references.bib +0 -0
  68. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/references.md +0 -0
  69. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/docs/template_usage.md +0 -0
  70. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/examples/spatialdata_empty.py +0 -0
  71. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/__init__.py +0 -0
  72. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/__main__.py +0 -0
  73. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_annotationwidgets.py +0 -0
  74. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/_sdata_widgets.py +0 -0
  75. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/constants/__init__.py +0 -0
  76. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/constants/_constants.py +0 -0
  77. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/constants/config.py +0 -0
  78. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/napari.yaml +0 -0
  79. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/resources/exclamation.png +0 -0
  80. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/utils/__init__.py +0 -0
  81. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/utils/_categoricals_utils.py +0 -0
  82. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata/utils/_viewer_utils.py +0 -0
  83. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/dependency_links.txt +0 -0
  84. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/entry_points.txt +0 -0
  85. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/requires.txt +0 -0
  86. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/src/napari_spatialdata.egg-info/top_level.txt +0 -0
  87. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/__init__.py +0 -0
  88. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/plots/groundtruth/Images_can_add_element_image.png +0 -0
  89. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/plots/groundtruth/Images_can_add_element_label.png +0 -0
  90. {napari_spatialdata-0.5.3 → napari_spatialdata-0.5.4}/tests/plots/groundtruth/Images_can_add_element_multiple.png +0 -0
@@ -23,7 +23,7 @@ jobs:
23
23
  strategy:
24
24
  matrix:
25
25
  platform: [ubuntu-latest, macos-latest] # [ubuntu-latest, windows-latest, macos-latest]
26
- python-version: ["3.9", "3.11"]
26
+ python-version: ["3.10", "3.12"]
27
27
 
28
28
  steps:
29
29
  - uses: actions/checkout@v4
@@ -86,6 +86,11 @@ jobs:
86
86
  python-version: 3.11
87
87
  cache-dependency-path: pyproject.toml
88
88
 
89
+ - name: Install dependencies with 'pre' extras (since the above doesn't check pre-releases)
90
+ run: |
91
+ python -m pip install --upgrade pip
92
+ pip install .[pre]
93
+
89
94
  - uses: tlambert03/setup-qt-libs@v1
90
95
 
91
96
  - uses: octokit/request-action@v2.x
@@ -1,6 +1,6 @@
1
1
  [mypy]
2
2
  mypy_path = napari-spatialdata
3
- python_version = 3.9
3
+ python_version = 3.10
4
4
  plugins = numpy.typing.mypy_plugin
5
5
 
6
6
  ignore_errors = False
@@ -2,12 +2,12 @@ fail_fast: false
2
2
  default_language_version:
3
3
  python: python3
4
4
  default_stages:
5
- - commit
6
- - push
5
+ - pre-commit
6
+ - pre-push
7
7
  minimum_pre_commit_version: 2.9.3
8
8
  repos:
9
9
  - repo: https://github.com/pre-commit/mirrors-mypy
10
- rev: v1.11.1
10
+ rev: v1.11.2
11
11
  hooks:
12
12
  - id: mypy
13
13
  additional_dependencies: [numpy>=1.23]
@@ -49,7 +49,7 @@ repos:
49
49
  hooks:
50
50
  - id: blacken-docs
51
51
  - repo: https://github.com/astral-sh/ruff-pre-commit
52
- rev: v0.5.7
52
+ rev: v0.6.8
53
53
  hooks:
54
54
  - id: ruff
55
55
  args: [--fix, --exit-non-zero-on-fix]
@@ -8,6 +8,24 @@ and this project adheres to [Semantic Versioning][].
8
8
  [keep a changelog]: https://keepachangelog.com/en/1.0.0/
9
9
  [semantic versioning]: https://semver.org/spec/v2.0.0.html
10
10
 
11
+ ## [0.5.4] - 2024-11-26
12
+
13
+ ### Changed
14
+
15
+ - Support for `xarray.DataTree` (which moved from `datatree.DataTree`)
16
+
17
+ ### Added
18
+
19
+ - CLI interface from spatialdata branch
20
+ - New function to get layer by name #315 @minhtien-trinh
21
+ - New annotation function to display text near polygons #315 @minhtien-trinh
22
+
23
+ ### Fixed
24
+
25
+ - Bug wrong radii transformed circles (e.g. with Visium lowres) #318
26
+ - Bugs: instance id shifted by 1; obsm visualization; background color for labels #320
27
+ - Bug adjusting contrast limit for RGB data #276
28
+
11
29
  ## [0.5.3] - 2024-09-25
12
30
 
13
31
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: napari-spatialdata
3
- Version: 0.5.3
3
+ Version: 0.5.4
4
4
  Summary: Interactive visualization of spatial omics data with napari
5
5
  Home-page: https://github.com/scverse/napari-spatialdata.git
6
6
  Author: giovanni palla
@@ -16,11 +16,12 @@ Classifier: Framework :: napari
16
16
  Classifier: Topic :: Software Development :: Testing
17
17
  Classifier: Programming Language :: Python
18
18
  Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.9
20
19
  Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
21
22
  Classifier: Operating System :: OS Independent
22
23
  Classifier: License :: OSI Approved :: BSD License
23
- Requires-Python: >=3.9.2
24
+ Requires-Python: >=3.10
24
25
  Description-Content-Type: text/markdown
25
26
  License-File: LICENSE
26
27
  Requires-Dist: anndata
@@ -88,7 +89,7 @@ Requires-Dist: napari[pyqt5]; extra == "all"
88
89
  [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-spatialdata)](https://napari-hub.org/plugins/napari-spatialdata)
89
90
  [![DOI](https://zenodo.org/badge/477021400.svg)](https://zenodo.org/badge/latestdoi/477021400)
90
91
 
91
- This repository contains a napari plugin for interactively exploring and annotating SpatialData objects. `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [documentation](https://spatialdata.scverse.org/).
92
+ This repository contains a napari plugin for interactively exploring and annotating SpatialData objects. Here you can find the [napari-spatialdata documentation](https://spatialdata.scverse.org/projects/napari/en/latest/notebooks/spatialdata.html). `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [spatialdata documentation](https://spatialdata.scverse.org/).
92
93
 
93
94
  ## Installation
94
95
 
@@ -11,7 +11,7 @@
11
11
  [![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-spatialdata)](https://napari-hub.org/plugins/napari-spatialdata)
12
12
  [![DOI](https://zenodo.org/badge/477021400.svg)](https://zenodo.org/badge/latestdoi/477021400)
13
13
 
14
- This repository contains a napari plugin for interactively exploring and annotating SpatialData objects. `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [documentation](https://spatialdata.scverse.org/).
14
+ This repository contains a napari plugin for interactively exploring and annotating SpatialData objects. Here you can find the [napari-spatialdata documentation](https://spatialdata.scverse.org/projects/napari/en/latest/notebooks/spatialdata.html). `napari-spatialdata` is part of the `SpatialData` ecosystem. To learn more about SpatialData, please see the [spatialdata documentation](https://spatialdata.scverse.org/).
15
15
 
16
16
  ## Installation
17
17
 
@@ -2,6 +2,7 @@ import numpy as np
2
2
  from napari import Viewer
3
3
  from napari.layers import Image
4
4
  from napari.utils.events import EventedList
5
+
5
6
  from napari_spatialdata._sdata_widgets import SdataWidget
6
7
 
7
8
 
@@ -17,3 +18,6 @@ class SdataWidgetSuite:
17
18
 
18
19
  def time_layer_added(self) -> None:
19
20
  self.viewer.add_layer(self.image)
21
+
22
+ def teardown(self) -> None:
23
+ self.viewer.close()
@@ -9,6 +9,7 @@
9
9
  api.md
10
10
  cli.md
11
11
  contributing.md
12
+ limitations.md
12
13
  references.md
13
14
  ```
14
15
 
@@ -0,0 +1,8 @@
1
+ # Limitations
2
+
3
+ Contributions are welcomed!
4
+
5
+ - On macOS, the maximum point size is constrained ([details in the Vispy issue tracker](https://github.com/vispy/vispy/issues/2078));
6
+ it is important to keep this in mind when zooming in on points to [explore the points property on mouse hover](https://github.com/scverse/napari-spatialdata/issues/35#issuecomment-2383792431).
7
+ - 3D data representation is supported in `spatialdata`; 3D data visualization is supported in `napari`.
8
+ Still, in `napari-spatialdata` we currently don't support 3D data visualization.
@@ -46,12 +46,11 @@
46
46
  "source": [
47
47
  "%matplotlib inline\n",
48
48
  "import matplotlib.pyplot as plt\n",
49
- "from napari_spatialdata import Interactive\n",
50
49
  "from spatialdata import SpatialData\n",
51
- "import squidpy as sq\n",
52
- "import scanpy as sc\n",
53
50
  "\n",
54
- "plt.rcParams['figure.figsize'] = (20, 20)"
51
+ "from napari_spatialdata import Interactive\n",
52
+ "\n",
53
+ "plt.rcParams[\"figure.figsize\"] = (20, 20)"
55
54
  ]
56
55
  },
57
56
  {
@@ -205,7 +204,7 @@
205
204
  ],
206
205
  "source": [
207
206
  "plt.imshow(interactive.screenshot())\n",
208
- "plt.axis('off')"
207
+ "plt.axis(\"off\")"
209
208
  ]
210
209
  },
211
210
  {
@@ -254,7 +253,7 @@
254
253
  ],
255
254
  "source": [
256
255
  "plt.imshow(interactive.screenshot())\n",
257
- "plt.axis('off')"
256
+ "plt.axis(\"off\")"
258
257
  ]
259
258
  },
260
259
  {
@@ -295,7 +294,7 @@
295
294
  ],
296
295
  "source": [
297
296
  "plt.imshow(interactive.screenshot())\n",
298
- "plt.axis('off')"
297
+ "plt.axis(\"off\")"
299
298
  ]
300
299
  },
301
300
  {
@@ -347,7 +346,7 @@
347
346
  ],
348
347
  "source": [
349
348
  "plt.imshow(interactive.screenshot())\n",
350
- "plt.axis('off')"
349
+ "plt.axis(\"off\")"
351
350
  ]
352
351
  },
353
352
  {
@@ -398,7 +397,7 @@
398
397
  ],
399
398
  "source": [
400
399
  "plt.imshow(interactive.screenshot())\n",
401
- "plt.axis('off')"
400
+ "plt.axis(\"off\")"
402
401
  ]
403
402
  },
404
403
  {
@@ -439,7 +438,7 @@
439
438
  ],
440
439
  "source": [
441
440
  "plt.imshow(interactive.screenshot())\n",
442
- "plt.axis('off')"
441
+ "plt.axis(\"off\")"
443
442
  ]
444
443
  },
445
444
  {
@@ -480,7 +479,7 @@
480
479
  ],
481
480
  "source": [
482
481
  "plt.imshow(interactive.screenshot())\n",
483
- "plt.axis('off')"
482
+ "plt.axis(\"off\")"
484
483
  ]
485
484
  }
486
485
  ],
@@ -46,12 +46,12 @@
46
46
  "source": [
47
47
  "%matplotlib inline\n",
48
48
  "import matplotlib.pyplot as plt\n",
49
- "from napari_spatialdata import Interactive\n",
50
- "from spatialdata import SpatialData\n",
51
- "import squidpy as sq\n",
52
49
  "import scanpy as sc\n",
50
+ "from spatialdata import SpatialData\n",
51
+ "\n",
52
+ "from napari_spatialdata import Interactive\n",
53
53
  "\n",
54
- "plt.rcParams['figure.figsize'] = (20, 20)"
54
+ "plt.rcParams[\"figure.figsize\"] = (20, 20)"
55
55
  ]
56
56
  },
57
57
  {
@@ -278,7 +278,7 @@
278
278
  ],
279
279
  "source": [
280
280
  "plt.imshow(interactive.screenshot())\n",
281
- "plt.axis('off')"
281
+ "plt.axis(\"off\")"
282
282
  ]
283
283
  },
284
284
  {
@@ -327,7 +327,7 @@
327
327
  ],
328
328
  "source": [
329
329
  "plt.imshow(interactive.screenshot())\n",
330
- "plt.axis('off')"
330
+ "plt.axis(\"off\")"
331
331
  ]
332
332
  },
333
333
  {
@@ -390,7 +390,7 @@
390
390
  ],
391
391
  "source": [
392
392
  "plt.imshow(interactive.screenshot())\n",
393
- "plt.axis('off')"
393
+ "plt.axis(\"off\")"
394
394
  ]
395
395
  },
396
396
  {
@@ -431,7 +431,7 @@
431
431
  ],
432
432
  "source": [
433
433
  "plt.imshow(interactive.screenshot())\n",
434
- "plt.axis('off')"
434
+ "plt.axis(\"off\")"
435
435
  ]
436
436
  },
437
437
  {
@@ -483,7 +483,7 @@
483
483
  ],
484
484
  "source": [
485
485
  "plt.imshow(interactive.screenshot())\n",
486
- "plt.axis('off')"
486
+ "plt.axis(\"off\")"
487
487
  ]
488
488
  },
489
489
  {
@@ -572,7 +572,7 @@
572
572
  ],
573
573
  "source": [
574
574
  "plt.imshow(interactive.screenshot())\n",
575
- "plt.axis('off')"
575
+ "plt.axis(\"off\")"
576
576
  ]
577
577
  },
578
578
  {
@@ -613,7 +613,7 @@
613
613
  ],
614
614
  "source": [
615
615
  "plt.imshow(interactive.screenshot())\n",
616
- "plt.axis('off')"
616
+ "plt.axis(\"off\")"
617
617
  ]
618
618
  }
619
619
  ],
@@ -41,12 +41,13 @@
41
41
  "cell_type": "code",
42
42
  "execution_count": 10,
43
43
  "metadata": {},
44
+ "outputs": [],
44
45
  "source": [
45
- "from napari_spatialdata import QtAdataScatterWidget\n",
46
+ "import matplotlib.pyplot as plt\n",
46
47
  "import squidpy as sq\n",
47
- "import matplotlib.pyplot as plt"
48
- ],
49
- "outputs": []
48
+ "\n",
49
+ "from napari_spatialdata import QtAdataScatterWidget"
50
+ ]
50
51
  },
51
52
  {
52
53
  "attachments": {},
@@ -60,10 +61,10 @@
60
61
  "cell_type": "code",
61
62
  "execution_count": 11,
62
63
  "metadata": {},
64
+ "outputs": [],
63
65
  "source": [
64
66
  "adata = sq.datasets.visium_hne_adata()"
65
- ],
66
- "outputs": []
67
+ ]
67
68
  },
68
69
  {
69
70
  "attachments": {},
@@ -77,10 +78,10 @@
77
78
  "cell_type": "code",
78
79
  "execution_count": 13,
79
80
  "metadata": {},
81
+ "outputs": [],
80
82
  "source": [
81
83
  "%gui qt5"
82
- ],
83
- "outputs": []
84
+ ]
84
85
  },
85
86
  {
86
87
  "attachments": {},
@@ -94,11 +95,11 @@
94
95
  "cell_type": "code",
95
96
  "execution_count": 14,
96
97
  "metadata": {},
98
+ "outputs": [],
97
99
  "source": [
98
100
  "widget = QtAdataScatterWidget(adata)\n",
99
101
  "widget.show()"
100
- ],
101
- "outputs": []
102
+ ]
102
103
  },
103
104
  {
104
105
  "attachments": {},
@@ -112,11 +113,11 @@
112
113
  "cell_type": "code",
113
114
  "execution_count": 15,
114
115
  "metadata": {},
116
+ "outputs": [],
115
117
  "source": [
116
118
  "plt.imshow(widget.screenshot())\n",
117
- "plt.axis('off')"
118
- ],
119
- "outputs": []
119
+ "plt.axis(\"off\")"
120
+ ]
120
121
  },
121
122
  {
122
123
  "attachments": {},
@@ -130,21 +131,21 @@
130
131
  "cell_type": "code",
131
132
  "execution_count": 19,
132
133
  "metadata": {},
134
+ "outputs": [],
133
135
  "source": [
134
136
  "plt.imshow(widget.screenshot())\n",
135
- "plt.axis('off')"
136
- ],
137
- "outputs": []
137
+ "plt.axis(\"off\")"
138
+ ]
138
139
  },
139
140
  {
140
141
  "cell_type": "code",
141
142
  "execution_count": 21,
142
143
  "metadata": {},
144
+ "outputs": [],
143
145
  "source": [
144
146
  "plt.imshow(widget.screenshot())\n",
145
- "plt.axis('off')"
146
- ],
147
- "outputs": []
147
+ "plt.axis(\"off\")"
148
+ ]
148
149
  }
149
150
  ],
150
151
  "metadata": {
@@ -66,10 +66,11 @@
66
66
  "source": [
67
67
  "%matplotlib inline\n",
68
68
  "import matplotlib.pyplot as plt\n",
69
- "from napari_spatialdata import Interactive\n",
70
69
  "from spatialdata import SpatialData\n",
71
70
  "\n",
72
- "plt.rcParams['figure.figsize'] = (20, 20)\n",
71
+ "from napari_spatialdata import Interactive\n",
72
+ "\n",
73
+ "plt.rcParams[\"figure.figsize\"] = (20, 20)\n",
73
74
  "\n",
74
75
  "FILE_PATH = \"../../../data/cosmx/data.zarr\" # Change this\n",
75
76
  "sdata = SpatialData.read(FILE_PATH)"
@@ -156,7 +157,7 @@
156
157
  ],
157
158
  "source": [
158
159
  "plt.imshow(interactive.screenshot())\n",
159
- "plt.axis('off')"
160
+ "plt.axis(\"off\")"
160
161
  ]
161
162
  },
162
163
  {
@@ -246,7 +247,7 @@
246
247
  ],
247
248
  "source": [
248
249
  "plt.imshow(interactive.screenshot())\n",
249
- "plt.axis('off')"
250
+ "plt.axis(\"off\")"
250
251
  ]
251
252
  },
252
253
  {
@@ -299,7 +300,7 @@
299
300
  ],
300
301
  "source": [
301
302
  "plt.imshow(interactive.screenshot())\n",
302
- "plt.axis('off')"
303
+ "plt.axis(\"off\")"
303
304
  ]
304
305
  },
305
306
  {
@@ -358,7 +359,7 @@
358
359
  ],
359
360
  "source": [
360
361
  "plt.imshow(interactive.screenshot())\n",
361
- "plt.axis('off')"
362
+ "plt.axis(\"off\")"
362
363
  ]
363
364
  },
364
365
  {
@@ -401,7 +402,7 @@
401
402
  ],
402
403
  "source": [
403
404
  "plt.imshow(interactive.screenshot())\n",
404
- "plt.axis('off')"
405
+ "plt.axis(\"off\")"
405
406
  ]
406
407
  },
407
408
  {
@@ -459,7 +460,7 @@
459
460
  ],
460
461
  "source": [
461
462
  "plt.imshow(interactive.screenshot())\n",
462
- "plt.axis('off')"
463
+ "plt.axis(\"off\")"
463
464
  ]
464
465
  },
465
466
  {
@@ -502,7 +503,7 @@
502
503
  ],
503
504
  "source": [
504
505
  "plt.imshow(interactive.screenshot())\n",
505
- "plt.axis('off')"
506
+ "plt.axis(\"off\")"
506
507
  ]
507
508
  },
508
509
  {
@@ -543,7 +544,7 @@
543
544
  ],
544
545
  "source": [
545
546
  "plt.imshow(interactive.screenshot())\n",
546
- "plt.axis('off')"
547
+ "plt.axis(\"off\")"
547
548
  ]
548
549
  },
549
550
  {
@@ -584,7 +585,7 @@
584
585
  ],
585
586
  "source": [
586
587
  "plt.imshow(interactive.screenshot())\n",
587
- "plt.axis('off')"
588
+ "plt.axis(\"off\")"
588
589
  ]
589
590
  }
590
591
  ],
@@ -3,9 +3,10 @@
3
3
 
4
4
  # The dataset can be downloaded from https://spatialdata.scverse.org/en/latest/tutorials/notebooks/datasets/README.html
5
5
 
6
- from napari_spatialdata import Interactive
7
6
  from spatialdata import SpatialData
8
7
 
8
+ from napari_spatialdata import Interactive
9
+
9
10
  if __name__ == "__main__":
10
11
  sdata = SpatialData.read("../data/visium/data.zarr") # Change this path!
11
12
  i = Interactive(sdata)
@@ -7,7 +7,7 @@ write_to = "src/napari_spatialdata/_version.py"
7
7
 
8
8
  [tool.black]
9
9
  line-length = 120
10
- target-version = ['py39']
10
+ target-version = ['py310']
11
11
  include = '\.pyi?$'
12
12
  exclude = '''
13
13
  (
@@ -38,7 +38,7 @@ exclude = [
38
38
  "setup.py",
39
39
  ]
40
40
  line-length = 120
41
- target-version = "py39"
41
+ target-version = "py310"
42
42
  [tool.ruff.lint]
43
43
  ignore = [
44
44
  # Do not assign a lambda expression, use a def -> lambda expression assignments are convenient
@@ -19,15 +19,16 @@ classifiers =
19
19
  Topic :: Software Development :: Testing
20
20
  Programming Language :: Python
21
21
  Programming Language :: Python :: 3
22
- Programming Language :: Python :: 3.9
23
22
  Programming Language :: Python :: 3.10
23
+ Programming Language :: Python :: 3.11
24
+ Programming Language :: Python :: 3.12
24
25
  Operating System :: OS Independent
25
26
  License :: OSI Approved :: BSD License
26
27
 
27
28
  [options]
28
29
  packages = find:
29
30
  include_package_data = True
30
- python_requires = >=3.9.2
31
+ python_requires = >=3.10
31
32
  setup_requires = setuptools_scm
32
33
  install_requires =
33
34
  anndata
@@ -3,11 +3,12 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Any
4
4
 
5
5
  import napari
6
+ from napari.layers import Image, Labels, Points, Shapes
6
7
  from napari.utils.events import EventedList
8
+ from spatialdata._types import ArrayLike
7
9
 
8
10
  from napari_spatialdata._sdata_widgets import SdataWidget
9
11
  from napari_spatialdata.utils._utils import (
10
- NDArrayA,
11
12
  get_duplicate_element_names,
12
13
  get_elements_meta_mapping,
13
14
  get_itemindex_by_text,
@@ -97,6 +98,30 @@ class Interactive:
97
98
  """Run the napari application."""
98
99
  napari.run()
99
100
 
100
- def screenshot(self) -> NDArrayA | Any:
101
+ def screenshot(self) -> ArrayLike | Any:
101
102
  """Take a screenshot of the viewer in its current state."""
102
103
  return self._viewer.screenshot(canvas_only=False)
104
+
105
+ def get_layer(self, layer_name: str) -> Image | Labels | Points | Shapes | None:
106
+ """Get a layer by name."""
107
+ try:
108
+ return self._viewer.layers[layer_name]
109
+ except KeyError:
110
+ return None
111
+
112
+ def add_text_to_polygons(self, layer_name: str, text_annotations: list[str]) -> None:
113
+ """Add text annotations to a polygon layer."""
114
+ polygon_layer = self.get_layer(layer_name)
115
+ if not polygon_layer:
116
+ raise ValueError(f"Polygon layer '{layer_name}' not found.")
117
+ if len(text_annotations) != len(polygon_layer.data):
118
+ raise ValueError(
119
+ f"The number of text annotations must match the number of polygons. "
120
+ f"Polygons: {len(polygon_layer.data)}, Text: {len(text_annotations)}."
121
+ )
122
+ polygon_layer.text = {
123
+ "string": text_annotations,
124
+ "size": 10,
125
+ "color": "red",
126
+ "anchor": "center",
127
+ }