Skip to content

Fix import of removed scanpy _get_obs_rep/_set_obs_rep - #1050

Merged
Zethson merged 2 commits into
mainfrom
fix/guide-rna-obs-rep-import
Jul 25, 2026
Merged

Fix import of removed scanpy _get_obs_rep/_set_obs_rep#1050
Zethson merged 2 commits into
mainfrom
fix/guide-rna-obs-rep-import

Conversation

@Zethson

@Zethson Zethson commented Jul 25, 2026

Copy link
Copy Markdown
Member

Description

scanpy 1.13.0a1 removed the private helpers scanpy.get._get_obs_rep and scanpy.get._set_obs_rep, which broke import pertpy with:

ImportError: cannot import name '_get_obs_rep' from 'scanpy.get'

These helpers only resolved X vs a named layer, which AnnData handles directly (and plot_heatmap in the same file already did inline).
This replaces the imports with direct adata.X / adata.layers[...] access.

Fixes #1049

Testing

tests/preprocessing/test_grna_assignment.py passes (23 passed).

scanpy 1.13.0a1 removed the private helpers scanpy.get._get_obs_rep and
scanpy.get._set_obs_rep, breaking `import pertpy`. These helpers only
resolved X vs a named layer, which AnnData now handles directly, so
replace them with direct adata.X / adata.layers access.

Fixes #1049

Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>
@codecov-commenter

codecov-commenter commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.77%. Comparing base (6152d32) to head (3cae3fb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1050   +/-   ##
=======================================
  Coverage   78.76%   78.77%           
=======================================
  Files          51       51           
  Lines        7167     7170    +3     
=======================================
+ Hits         5645     5648    +3     
  Misses       1522     1522           
Files with missing lines Coverage Δ
pertpy/data/_dataloader.py 100.00% <100.00%> (ø)
pertpy/preprocessing/_guide_rna.py 88.02% <100.00%> (-0.07%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The pooch migration (#980) dropped the retry-with-backoff loop that the
previous _download had, leaving max_retries/retry_delay as dead params.
Transient failures such as 'Connection reset by peer' (URLError, an
OSError subclass) or a requests ConnectionError therefore aborted the
download immediately, causing flaky test failures on CI.

Reinstate the retry loop around pooch.retrieve, retrying on OSError and
requests.exceptions.RequestException with a delay between attempts, and
add unit tests covering the retry, exhaustion, and non-transient paths.

Signed-off-by: Lukas Heumos <lukas.heumos@posteo.net>
@Zethson
Zethson merged commit 388063c into main Jul 25, 2026
19 checks passed
@Zethson
Zethson deleted the fix/guide-rna-obs-rep-import branch July 25, 2026 21:28
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.

_get_obs_rep removed from scanpy.get

2 participants