Closed aeisenbarth closed 9 months ago
Thanks for reporting, I will look into this and continue from your PR.
Closing because the IO apis changed in main
with https://github.com/scverse/spatialdata/pull/329 (please note that the PR is not in the current version v0.0.15).
I have opened a separate issue to track the other points https://github.com/scverse/spatialdata/issues/446.
When saving labels to a SpatialData that has already been written to disk (with or without
overwrite=True
), there are multiple exceptions.Example code
1. UnboundLocalError: local variable 'elem_group' referenced before assignment
A variable is accessed (L415) which is only conditionally declared. It would be safer either to assign a default value, or to access it only in the same conditional branch.
I don't understand the reasoning of the comment, but to me it seems a fix would be to remove the condition above L411.
https://github.com/scverse/spatialdata/blob/4dd525002f12381858251df9cd304a7108a21886/src/spatialdata/_core/spatialdata.py#L409-L416
2. AssertionError on type of dims
For backed labels,
xdata
is not aDataArray
(wheredims
is("y", "x")
) but aDataTree
wheredims
isFrozen({"y": 1633, "x": 1290})
.https://github.com/scverse/spatialdata/blob/4dd525002f12381858251df9cd304a7108a21886/src/spatialdata/models/_utils.py#L151-L153
This works with:
or converting the dictionary to tuple:
3. DataTree has no attribute
shape
https://github.com/scverse/spatialdata/blob/4dd525002f12381858251df9cd304a7108a21886/src/spatialdata/transformations/_utils.py#L118-L119
Also here: