scverse / scverse/anndata

del view.attr[key] is not working quite right

Open
#577 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale topic: views 👀
Dominant language
Python
Stars
773
Forks
209
Avg merge
19h 41m
Merged PRs (30d)
32

Description

a = ad.AnnData(
    np.ones((5, 5)),
    obs=pd.DataFrame({"key": list("abcde")}, index=[f"cell{i}" for i in range(5)]),
    obsm={"key": np.ones((5, 10))},
    uns={"key": "value"},
)
a
AnnData object with n_obs × n_vars = 5 × 5
    obs: 'key'
    uns: 'key'
    obsm: 'key'
  • Should do something for uns, but does nothing

     v = a[:3]
     del v.uns["key"]
     display(v)
    
     View of AnnData object with n_obs × n_vars = 3 × 5
         obs: 'key'
         uns: 'key'
         obsm: 'key'
    
  • Should we actualize the view for .obs?

     v = a[:3]
     del v.obs["key"]
     display(v)
    
     View of AnnData object with n_obs × n_vars = 3 × 5
         uns: 'key'
         obsm: 'key'
    
  • Should we warn about going from view to actual for obsm?

     v = a[:3]
     del v.obsm["key"]
     display(v)
    
     AnnData object with n_obs × n_vars = 3 × 5
         uns: 'key'
    

Should be relatively straightforward fixes to the views.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the three view-deletion examples in the issue with AnnData, focusing on uns, obs, and obsm. Trace the existing view behavior from those operations and determine the intended result for each case, including whether obsm deletion warns about actualizing the view. Done means the three examples behave consistently with the resolved expectations and have regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.