You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Traceback (most recent call last):
File "<ipython-input-6-6d9e217edb59>", line 1, in <module>
sdata.add_labels(name="my_label", labels=labels, overwrite=True)
File "…/spatialdata/_core/spatialdata.py", line 779, in add_labels
elem_group = self._init_add_element(name=name, element_type="labels", overwrite=overwrite)
File "…/spatialdata/_core/spatialdata.py", line 415, in _init_add_element
if name in elem_group:
UnboundLocalError: local variable 'elem_group' referenced before assignment
2. AssertionError on type of dims
For backed labels, xdata is not a DataArray (where dims is ("y", "x")) but a DataTree where dims is Frozen({"y": 1633, "x": 1290}).
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.
spatialdata/src/spatialdata/_core/spatialdata.py
Lines 409 to 416 in 4dd5250
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})
.spatialdata/src/spatialdata/models/_utils.py
Lines 151 to 153 in 4dd5250
This works with:
or converting the dictionary to tuple:
3. DataTree has no attribute
shape
spatialdata/src/spatialdata/transformations/_utils.py
Lines 118 to 119 in 4dd5250
Also here:
The text was updated successfully, but these errors were encountered: