Skip to content

feat: custom in-memory indexes#2379

Merged
ilan-gold merged 25 commits into
mainfrom
ig/custom_index_objects
May 19, 2026
Merged

feat: custom in-memory indexes#2379
ilan-gold merged 25 commits into
mainfrom
ig/custom_index_objects

Conversation

@ilan-gold
Copy link
Copy Markdown
Contributor

@ilan-gold ilan-gold commented Mar 31, 2026

From the proteomics hackathon, we definitely need to define some parameters and work out kinks:

  1. Writeability: feat: AnnData.unwriteable based on AnnData._reduce + iter_outer + refactorings of other relevant functions #2372 + Lenient write #2373 + Handle new zarr dtypes (both custom and datetime) #2238. Conretely, feat: AnnData.unwriteable based on AnnData._reduce + iter_outer + refactorings of other relevant functions #2372 needs to go in first to prevent people from even trying to write these i.e., when there is a MultiIndex
  2. What exactly are we changing? In other words, what does this setting do exactly? I think the two tests are clear about this, but there is some subtle stuff like you used to be able to do adata.obs_names = non_string_index and this evidently worked? This will be essential for documentation
  3. Do we need any guardrails? No arrow integer types? What sort of filtering can/should we do here?
  4. In the case of no index provided on declaration, should we make new decisions? https://github.com/scverse/pandas-uuid maybe?
  • Release note not necessary because:

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.60%. Comparing base (9f2fa25) to head (ae1c935).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2379      +/-   ##
==========================================
+ Coverage   85.57%   85.60%   +0.02%     
==========================================
  Files          49       49              
  Lines        7669     7671       +2     
==========================================
+ Hits         6563     6567       +4     
+ Misses       1106     1104       -2     
Files with missing lines Coverage Δ
src/anndata/_core/aligned_df.py 96.72% <100.00%> (+0.05%) ⬆️
src/anndata/_core/anndata.py 86.81% <100.00%> (ø)
src/anndata/_core/index.py 95.23% <100.00%> (+0.69%) ⬆️
src/anndata/_io/read.py 52.79% <100.00%> (+0.24%) ⬆️
src/anndata/_settings.py 100.00% <100.00%> (ø)
src/anndata/tests/helpers.py 83.88% <100.00%> (ø)

@ilan-gold ilan-gold requested a review from flying-sheep May 18, 2026 13:15
@ilan-gold
Copy link
Copy Markdown
Contributor Author

Just looking for preliminary thoughts here @flying-sheep

Copy link
Copy Markdown
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

direction looks great!

Comment thread src/anndata/_core/aligned_df.py Outdated
Comment thread src/anndata/_settings.py Outdated
Comment thread src/anndata/_core/index.py Outdated
Comment thread tests/test_annot.py Outdated
Comment thread src/anndata/_core/index.py
@ilan-gold ilan-gold added this to the 0.13.0 milestone May 19, 2026
@ilan-gold ilan-gold marked this pull request as ready for review May 19, 2026 13:34
@ilan-gold ilan-gold requested a review from flying-sheep May 19, 2026 13:35
@ilan-gold
Copy link
Copy Markdown
Contributor Author

ilan-gold commented May 19, 2026

What exactly are we changing? In other words, what does this setting do exactly? I think the two tests are clear about this, but there is some subtle stuff like you used to be able to do adata.obs_names = non_string_index and this evidently worked? This will be essential for documentation

This is still an outstanding question to me but on second thought, nothing seems to have actually changed. This was always allowed before, but maybe this PR should disallow it if the restriction setting is on? There's a warning about this but that's it. So maybe a test would be good

UPDATE: Ok I thought of that and https://github.com/scverse/anndata/pull/2379/changes#diff-93807bfddb872b9cf4ea7586b7ee8feb73bb9cab28969a82b4b6974001ff3462R749-R753 is what we do i.e., leave the old mechanism in place, which is probably the least disruptive thing to do

Comment thread src/anndata/_settings.py
Comment thread docs/release-notes/2379.feat.md Outdated
Copy link
Copy Markdown
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Very nice to see so few changes necessary, we really improved this codebase!

/edit: GitHub however did not, I had to delete and recreate the comment below, since GitHub inexplicably moved it to a different line, breaking the diff.

Comment thread src/anndata/_settings.py Outdated
Co-authored-by: Philipp A. <flying-sheep@web.de>
@ilan-gold ilan-gold enabled auto-merge (squash) May 19, 2026 14:22
@ilan-gold ilan-gold merged commit 829abb6 into main May 19, 2026
24 checks passed
@ilan-gold ilan-gold deleted the ig/custom_index_objects branch May 19, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants