Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Awkward array "view" attribute does not get removed on save. #1721

Open
2 of 3 tasks
grst opened this issue Oct 20, 2024 · 0 comments
Open
2 of 3 tasks

Awkward array "view" attribute does not get removed on save. #1721

grst opened this issue Oct 20, 2024 · 0 comments

Comments

@grst
Copy link
Contributor

grst commented Oct 20, 2024

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of anndata.
  • (optional) I have confirmed this bug exists on the master branch of anndata.

Report

Saving a view of anndata turns it into a copy. However, the "view" attributes of an awkward array do not get removed on save, which leads to some side effects described in these discourse posts:
https://discourse.scverse.org/t/notimplementederror-cannot-create-a-view-of-an-awkward-array-with-array-parameter/3305
https://discourse.scverse.org/t/ir-tl-chain-qc-adata-error-message-with-scirpy-0-18-0/3304/4

Code:

import scirpy as ir
import anndata as ad
adata = ir.datasets.wu2020_3k()["airr"]
v = adata[:200]
v.obsm["airr"]

This awkward array now has the "_view_args" added as intended:

[...]
}, parameters={"_view_args": ["target-137048116381552", "obsm", ["airr"]], "__list__": "AwkwardArrayView"}]
v.write_h5ad("/tmp/airr.h5ad")
v2 = ad.read_h5ad("/tmp/airr.h5ad')
v2.obsm["airr"]

Now v2 is not a view anymore, but the awkward array still has the same parameters (and target-137048116381552 is a weakref to an object that does not exist anymore)

[...]
}, parameters={"_view_args": ["target-137048116381552", "obsm", ["airr"]], "__list__": "AwkwardArrayView"}]

Possible fix:

On save, send the awkward array through ak.without_parameters().

Versions

anndata             0.10.8
scirpy              0.18.1.dev7+g2157800c
session_info        1.0.0
-----
Levenshtein         0.26.0
PIL                 11.0.0
adjustText          1.2.0
asciitree           NA
asttokens           NA
awkward             2.6.9
awkward_cpp         NA
cairo               1.27.0
charset_normalizer  3.4.0
comm                0.2.2
cycler              0.12.1
cython_runtime      NA
dateutil            2.9.0.post0
debugpy             1.8.7
decorator           5.1.1
defusedxml          0.7.1
distutils           3.12.7
executing           2.1.0
fsspec              2024.9.0
h5py                3.12.1
...
Python 3.12.7 | packaged by conda-forge | (main, Oct  4 2024, 16:05:46) [GCC 13.3.0]
Linux-6.11.4-arch1-1-x86_64-with-glibc2.40
-----
Session information updated at 2024-10-20 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant