Drop `region` (`region_key` and `instance_key` are enough)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 394
- Forks
- 95
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 7
Description
Motivation
The region metadata field was introduced at the storage format level to be able to tell which elements a table is annotating, without the need to examine the data in the table.
In memory the region metadata is redundant, as region can be computed on-the-fly looking at
adata = sdata.tables['my_table']
region_key = adata.uns['spatialdata_attrs']['region_key']
region = adata.obs[region_key].cat.categories
(the above assumes that the region_key column is categorical, which is already a requirement for certain plotting functions and operations (such as rasterize_bins())).
Dropping region will simplify the syntax when dealing with tables. For instance now when calling set_table_annotates_spatialelement(), the user needs to adjust the region metadata manually.
Plan
With this issue we propose (@melonora and I) to:
- drop the
regionmetadata in-memory - when writing, compute the metadata as above
- when reading, ignoring the
regionmetadata - provide a property computed as above for convenience (since the above code is verbose).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing table metadata through the in-memory model and its read/write paths, including set_table_annotates_spatialelement(). Check how region_key, instance_key, and region are currently handled. Done means region is absent in memory, computed when writing, ignored when reading, and exposed through a convenience property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100