feat: make use_rep accept anndata.acc - #4315
Open
flying-sheep wants to merge 1 commit into
Open
Conversation
flying-sheep
commented
Aug 21, 2026
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]))] |
Member
Author
There was a problem hiding this comment.
[:,:] works, but [0] is bad … maybe we should implement this in anndata first …
Member
Author
There was a problem hiding this comment.
flying-sheep
commented
Aug 21, 2026
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) |
Member
Author
There was a problem hiding this comment.
we should make this forward compatible and both handle from_json already returning a RepAcc and rep being a heterogeneous list.
flying-sheep
commented
Aug 21, 2026
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.""" |
Member
Author
There was a problem hiding this comment.
plenty complicated 😢
use_rep accepts anndata.accuse_rep accept anndata.acc
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
use_repacceptanndata.accacessors #4314