Skip to content

feat: make use_rep accept anndata.acc - #4315

Open
flying-sheep wants to merge 1 commit into
mainfrom
use-rep-future
Open

feat: make use_rep accept anndata.acc#4315
flying-sheep wants to merge 1 commit into
mainfrom
use-rep-future

Conversation

@flying-sheep

Copy link
Copy Markdown
Member

@flying-sheep flying-sheep added this to the 1.13.0 milestone Aug 21, 2026
Comment thread src/scanpy/get/get.py
Comment on lines +832 to +833
# `A.to_json` only serializes vectors, so we add a dummy index
return [json.dumps(A.to_json(rep[:, :] if isinstance(rep, LayerAcc) else rep[0]))]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

[:,:] works, but [0] is bad … maybe we should implement this in anndata first …

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread src/scanpy/get/get.py
Comment on lines +845 to +846
[data] = rep # a 1-element list/array (see `_rep_to_json`)
return _resolve_rep(A.from_json(json.loads(data)).acc)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we should make this forward compatible and both handle from_json already returning a RepAcc and rep being a heterogeneous list.

Comment on lines +13 to +23
Use the indicated representation:
a :class:`~anndata.acc.LayerAcc` (e.g. `A.X`, `A.layers[...]`) or
:class:`~anndata.acc.MultiAcc` (e.g. `A.obsm[...]`, `A.varm[...]`).
A :class:`str` is :meth:`~anndata.acc.AdAcc.resolve`\ d to one of those
if :attr:`scanpy.settings.preset` is :attr:`~scanpy.Preset.ScanpyV2Preview`,
otherwise interpreted as `'X'` or a key of `.obsm`.
If `None`, the representation is chosen automatically:
For `.n_vars` < :attr:`~scanpy.settings.N_PCS` (default: 50), `.X` is used, otherwise 'X_pca' is used.
If 'X_pca' is not present, it’s computed with default parameters or `n_pcs` if present.\
"""
For `.n_vars` < :attr:`~scanpy.settings.N_PCS` (default: 50), `.X` is used, otherwise the PCA
representation (`.obsm['X_pca']`, or `.obsm['pca']` if it was computed under
:attr:`~scanpy.Preset.ScanpyV2Preview`).
If it is not present, it’s computed with default parameters or `n_pcs` if present."""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

plenty complicated 😢

@flying-sheep
flying-sheep requested a review from ilan-gold August 21, 2026 15:20
@flying-sheep flying-sheep mentioned this pull request Aug 21, 2026
@flying-sheep flying-sheep changed the title feat: use_rep accepts anndata.acc feat: make use_rep accept anndata.acc Aug 21, 2026
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.92683% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.10%. Comparing base (e6269f5) to head (a9947d3).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/scanpy/tools/_ingest.py 61.53% 5 Missing ⚠️
src/scanpy/tools/_utils.py 80.76% 5 Missing ⚠️
src/scanpy/get/get.py 86.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4315      +/-   ##
==========================================
+ Coverage   80.08%   80.10%   +0.02%     
==========================================
  Files         133      133              
  Lines       13424    13475      +51     
==========================================
+ Hits        10750    10794      +44     
- Misses       2674     2681       +7     
Flag Coverage Δ
hatch-test.low-vers 77.94% <65.85%> (-0.08%) ⬇️
hatch-test.pre 79.97% <82.92%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/neighbors/__init__.py 81.54% <100.00%> (+0.05%) ⬆️
src/scanpy/neighbors/_doc.py 100.00% <100.00%> (ø)
src/scanpy/neighbors/_types.py 100.00% <100.00%> (ø)
src/scanpy/tools/_dendrogram.py 82.97% <100.00%> (+0.37%) ⬆️
src/scanpy/tools/_tsne.py 75.55% <100.00%> (+0.55%) ⬆️
src/scanpy/tools/_umap.py 86.53% <100.00%> (+0.26%) ⬆️
src/scanpy/get/get.py 89.21% <86.66%> (-0.25%) ⬇️
src/scanpy/tools/_ingest.py 80.93% <61.53%> (-0.10%) ⬇️
src/scanpy/tools/_utils.py 86.58% <80.76%> (-0.38%) ⬇️

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.

Have use_rep accept anndata.acc acessors

1 participant