Skip to content

feat!: CoW X by default when setting i.e., subset.X = ... does not update parent of subset#2338

Merged
ilan-gold merged 10 commits into
mainfrom
ig/remove_old_X_behavior
Feb 12, 2026
Merged

feat!: CoW X by default when setting i.e., subset.X = ... does not update parent of subset#2338
ilan-gold merged 10 commits into
mainfrom
ig/remove_old_X_behavior

Conversation

@ilan-gold

@ilan-gold ilan-gold commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.78%. Comparing base (6a25200) to head (653998f).
⚠️ Report is 54 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2338      +/-   ##
==========================================
- Coverage   86.95%   86.78%   -0.17%     
==========================================
  Files          46       46              
  Lines        7390     7364      -26     
==========================================
- Hits         6426     6391      -35     
- Misses        964      973       +9     
Files with missing lines Coverage Δ
src/anndata/_core/anndata.py 81.98% <100.00%> (-1.71%) ⬇️

@ilan-gold ilan-gold added this to the 0.13.0 milestone Feb 10, 2026
@ilan-gold ilan-gold marked this pull request as ready for review February 10, 2026 15:07
@ilan-gold

Copy link
Copy Markdown
Contributor Author

@Intron7 Can you run this branch in your tests perhaps? I could see you explicitly or implicitly relying on some sort of behavior here that we are not accounting for.

@ilan-gold ilan-gold changed the title feat: CoW X by default breaking: CoW X by default Feb 10, 2026
@ilan-gold ilan-gold changed the title breaking: CoW X by default feature!: CoW X by default Feb 10, 2026

@flying-sheep flying-sheep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Important

Can we get rid of ArrayView in this PR?

Comment thread tests/test_views.py
assert adata[:, 0].X.tolist() == np.reshape([0, 0, 7], (3, 1)).tolist()
assert adata[:, 0].X.tolist() == np.reshape([1, 4, 7], (3, 1)).tolist()

adata_subset = adata[:2, [0, 1]]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

check here that the view has the changed values?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But it's checked below? The oprevious lines I changed i.e., assert adata[:, 0].X.tolist() == np.reshape([1, 4, 7], (3, 1)).tolist() are specifically checking that the parent didn't change despite the update

@flying-sheep flying-sheep Feb 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean that adata[:2, 0].X = [0, 0] creates a view, then actualizes it and sets the new non-view AnnData’s values. But I guess that’s tested elsewhere already.

maybe at least check that that line specifically raises the “view as actual” warning

Comment thread tests/test_x.py Outdated
@ilan-gold

Copy link
Copy Markdown
Contributor Author

Can we get rid of ArrayView in this PR?

No, I should clarify that this is only making CoW subset.X = ... which previously would have updated the actual anndata. This is distinct from X = subset.X and then X[another_subset] = ... which is CoW. I will update hte PR title. My zulip freakout was about "do we need views at all", which has to do with the later point.

@ilan-gold ilan-gold changed the title feature!: CoW X by default feature!: CoW X by default when setting i.e., subset.X = ... does not update parent of subset Feb 11, 2026
@ilan-gold ilan-gold changed the title feature!: CoW X by default when setting i.e., subset.X = ... does not update parent of subset feat!: CoW X by default when setting i.e., subset.X = ... does not update parent of subset Feb 11, 2026
@ilan-gold ilan-gold enabled auto-merge (squash) February 12, 2026 13:24
@ilan-gold ilan-gold merged commit 33cfe09 into main Feb 12, 2026
25 of 27 checks passed
@ilan-gold ilan-gold deleted the ig/remove_old_X_behavior branch February 12, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants