scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
571 stars 152 forks source link

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

Open ivirshup opened 3 years ago

ivirshup commented 3 years ago
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"},
)
display(a)
AnnData object with n_obs × n_vars = 5 × 5
    obs: 'key'
    uns: 'key'
    obsm: 'key'
v = a[:3]
display(v)
View of AnnData object with n_obs × n_vars = 3 × 5
    obs: 'key'
    uns: 'key'
    obsm: 'key'

No-op for uns

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

Does not actualize the view for .obs

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

Does not warn about going from view to actual for obsm

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.

Koncopd commented 3 years ago

I can look into the views after i finish the AnnDataSet pr.