Skip to content

Commit 38c5262

Browse files
LucaMarconatoclaude
andcommitted
Fix spatialdata_attrs lost after transform on points with duplicate index
dd.from_delayed starts with empty attrs, so spatialdata_attrs (feature_key, instance_key) was silently dropped. Copy all non-transform attrs from the original element to restore the previous behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 68e314e commit 38c5262

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/spatialdata/_core/operations/transform.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ def _(
480480
offsets = np.cumsum([0] + lengths)
481481
delayed_parts = [dask.delayed(transformed_pd.iloc[offsets[i] : offsets[i + 1]]) for i in range(len(lengths))]
482482
transformed = dd.from_delayed(delayed_parts, meta=transformed_pd.iloc[:0])
483+
# Preserve spatialdata_attrs (feature_key, instance_key, …) from the original element;
484+
# dd.from_delayed starts with empty attrs so we must copy them explicitly.
485+
for k, v in data.attrs.items():
486+
if k != TRANSFORM_KEY:
487+
transformed.attrs[k] = v
483488
# dummy transformation that will be replaced by _adjust_transformation()
484489
default_cs = {DEFAULT_COORDINATE_SYSTEM: Identity()}
485490
transformed.attrs[TRANSFORM_KEY] = default_cs

0 commit comments

Comments
 (0)