Commit 78d0fe6
Migrate supported Python to 3.12, 3.13, 3.14 (#1151)
* Migrate supported Python to 3.12, 3.13, 3.14
Drop Python 3.11 (anndata>=0.12 already requires >=3.12, so 3.11 was
effectively broken) and add 3.14.
- pyproject.toml: requires-python ">=3.12", ruff target-version py312
- .mypy.ini: python_version 3.12
- test.yaml: matrix 3.12/3.13/3.14; repoint bleeding-edge deps job to
3.14 and drop the obsolete requires-python sed hack
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Adopt PEP 695 type aliases for py312 (ruff UP040)
The target-version bump to py312 enables ruff UP040. Rewrite the four
explicit TypeAlias declarations to the `type` keyword and drop the now
unused TypeAlias imports. Annotation-only aliases (the repo uses
`from __future__ import annotations`), so no runtime behavior change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Fix infinite recursion in dataloader.__getattr__
The module __getattr__ fell through to `getattr(spatialdata.dataloader,
attr_name)` for any unknown name, re-entering itself indefinitely
(RecursionError) instead of raising AttributeError per PEP 562.
This was latent until the docs build hit it: the PEP 695 `type` aliases
live in private modules, so sphinx-autodoc-typehints probes every
`spatialdata.*` submodule with getattr() looking for a public re-export,
tripping the recursion and failing the RTD build.
Raise AttributeError for unknown names; drop the now-unused
`import spatialdata` and tighten the return type to type[ImageTilesDataset].
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Pin ome_zarr<0.18.0
ome_zarr 0.18 switched to the NGFF 0.5 layout: channel metadata moved
out of the `omero` block, so overwrite_channel_names() in
_io/_utils.py gets None and crashes (~48 IO test failures). This breaks
main independently of the Python bump. Pin as a stopgap until NGFF 0.5
is supported.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Support ome_zarr 0.18 by writing omero channel metadata ourselves
ome_zarr 0.18 refactored the functional write_image/write_multiscale
entrypoints (ome/ome-zarr-py#515) to read omero from the top-level
metadata dict; spatialdata passes it nested under metadata["metadata"],
so 0.18 silently dropped it. Effects: write_channel_names() crashed
(omero block absent) and plain write->read lost channel names entirely
(["r","g","b"] came back as [0,1,2]).
Instead of depending on ome-zarr-py to emit omero, write it ourselves:
- _write_raster() now calls overwrite_channel_names() after every image
write, so the omero block is always present (idempotent on 0.17).
- overwrite_channel_names() defaults to an empty omero block when none
exists yet.
Pin ome_zarr>=0.18 so CI resolves the same version a fresh install gets
(uv otherwise lands on 0.17, hiding 0.18 regressions). Verified: full
tests/io suite (227) passes on 0.18.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Clean up: drop redundant omero metadata build, lean comments
overwrite_channel_names() now writes the omero channel block on every
image write, so building the same metadata to pass into the ome-zarr-py
writer (which 0.18 ignores anyway) was dead duplication. Remove it along
with the now-unused get_channel_names import, and tighten comments.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Require integer (or bool) dtype for labels
ome_zarr 0.18's label writer auto-parses unique label values and
validates each `label-value` as an integer (via ome-zarr-models), which
rejected spatialdata's float-dtype labels. Float labels are meaningless
for segmentation masks and inconsistent with the rest of the codebase
(fixtures, rasterize, relabel_sequential all assume integers), so the
correct fix is to enforce it: Labels{2,3}DModel.parse now rejects
non-integer/bool data with a clear error.
Tests that fed float data to label models (reusing image-style
generators) now use integers; test_rasterize_bins_invalid casts a parsed
integer label to float to still exercise rasterize_bins' own guard.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Relax ome_zarr pin to >=0.16
Our omero self-write and integer-label fixes work across 0.16/0.17/0.18
(verified), so keep the wider lower bound for ecosystem co-installability
rather than forcing >=0.18.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* improve labels validation logic
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Luca Marconato <m.lucalmer@gmail.com>1 parent af51100 commit 78d0fe6
15 files changed
Lines changed: 55 additions & 66 deletions
File tree
- .github/workflows
- src/spatialdata
- _core
- operations
- query
- _io
- dataloader
- models
- tests
- core
- operations
- query
- models
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
100 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
| 157 | + | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | 304 | | |
312 | 305 | | |
313 | 306 | | |
| |||
334 | 327 | | |
335 | 328 | | |
336 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
337 | 333 | | |
338 | 334 | | |
339 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
19 | 17 | | |
20 | 18 | | |
21 | | - | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments