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

AnnData.__sizeof__ error on subsetted AnnData object #1127

Closed
2 of 3 tasks
wwang-chcn opened this issue Sep 8, 2023 · 2 comments
Closed
2 of 3 tasks

AnnData.__sizeof__ error on subsetted AnnData object #1127

wwang-chcn opened this issue Sep 8, 2023 · 2 comments

Comments

@wwang-chcn
Copy link

wwang-chcn commented Sep 8, 2023

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

Code:

import numpy as np
import pandas as pd
import anndata as ad
from scipy.sparse import csr_matrix

counts = csr_matrix(np.random.poisson(1, size=(100, 2000)), dtype=np.float32)
adata = ad.AnnData(counts)
ct = np.random.choice(["B", "T", "Monocyte"], size=(adata.n_obs,))
adata.obs["cell_type"] = pd.Categorical(ct)

bdata = adata[adata.obs.cell_type == "B"]

import sys
sys.getsizeof(bdata)

Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/XXX/conda-env/envs/XXX/lib/python3.10/site-packages/anndata/_core/anndata.py", line 549, in __sizeof__
    s = get_size(getattr(self, attr))
AttributeError: 'AnnData' object has no attribute '_X'. Did you mean: 'X'?

Versions

-----
anndata             0.9.2
numpy               1.24.3
pandas              2.0.3
scipy               1.10.1
session_info        1.0.0
-----
cython_runtime      NA
dateutil            2.8.2
h5py                3.9.0
mpl_toolkits        NA
natsort             8.4.0
packaging           23.1
pytz                2023.3
six                 1.16.0
zoneinfo            NA
-----
Python 3.10.11 | packaged by conda-forge | (main, May 10 2023, 18:58:44) [GCC 11.3.0]
Linux-3.10.0-1160.45.1.el7.x86_64-x86_64-with-glibc2.17
-----
Session information updated at 2023-09-08 15:26
Copy link

github-actions bot commented Nov 8, 2023

This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Nov 8, 2023
@flying-sheep
Copy link
Member

__sizeof__ is being worked on in #1230, so I’ll close this as a duplicate of #1222

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

2 participants