Skip to content

fix inplaces for log1p and scale#719

Merged
Intron7 merged 2 commits into
mainfrom
fix-meta-inconsitancies
Jul 6, 2026
Merged

fix inplaces for log1p and scale#719
Intron7 merged 2 commits into
mainfrom
fix-meta-inconsitancies

Conversation

@Intron7

@Intron7 Intron7 commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • log1p now preserves input data correctly when run without in-place updates, and no longer writes unnecessary metadata.
    • Scaling embeddings no longer adds summary statistics to feature metadata when the operation targets embedding data.
    • scale now updates feature statistics only when scaling the main matrix or a layer, improving consistency across data locations.

Signed-off-by: Intron7 <severin.dicks@icloud.com>
@Intron7 Intron7 enabled auto-merge (squash) July 6, 2026 11:11
@codecov-commenter

codecov-commenter commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.31%. Comparing base (481c60c) to head (a2981ca).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #719   +/-   ##
=======================================
  Coverage   90.31%   90.31%           
=======================================
  Files         106      106           
  Lines        9581     9582    +1     
=======================================
+ Hits         8653     8654    +1     
  Misses        928      928           
Files with missing lines Coverage Δ
src/rapids_singlecell/preprocessing/_normalize.py 89.03% <100.00%> (ø)
src/rapids_singlecell/preprocessing/_scale.py 91.66% <100.00%> (+0.04%) ⬆️

@Intron7 Intron7 disabled auto-merge July 6, 2026 12:19
@Intron7 Intron7 merged commit 908e02b into main Jul 6, 2026
6 of 7 checks passed
@Intron7 Intron7 deleted the fix-meta-inconsitancies branch July 6, 2026 12:19
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ee4d206-0108-4224-aaad-e553e7be6287

📥 Commits

Reviewing files that changed from the base of the PR and between bd53304 and 30f4b24.

📒 Files selected for processing (5)
  • docs/release-notes/0.16.0.md
  • src/rapids_singlecell/preprocessing/_normalize.py
  • src/rapids_singlecell/preprocessing/_scale.py
  • tests/test_normalization.py
  • tests/test_scaling.py

📝 Walkthrough

Walkthrough

This PR fixes two bugs in preprocessing functions: log1p now writes the transformed matrix to adata before setting adata.uns["log1p"] metadata, and scale now only writes mean/std to adata.var when obsm is not provided. Tests and release notes are added accordingly.

Changes

Preprocessing metadata fixes

Layer / File(s) Summary
log1p side-effect ordering
src/rapids_singlecell/preprocessing/_normalize.py, tests/test_normalization.py
log1p now calls _set_obs_rep before setting adata.uns["log1p"] when inplace=True; a new test confirms inplace=False doesn't mutate adata or write uns["log1p"].
scale obsm var-statistics guard
src/rapids_singlecell/preprocessing/_scale.py, tests/test_scaling.py, docs/release-notes/0.16.0.md
scale only writes mean/std into adata.var when obsm is None; a new test verifies adata.var is untouched when scaling obsm, and release notes document the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant log1p
  participant AnnData

  Caller->>log1p: log1p(adata, inplace=True)
  log1p->>AnnData: _set_obs_rep(transformed matrix)
  log1p->>AnnData: uns["log1p"] = {base}
  log1p-->>Caller: return
Loading

Possibly related PRs

  • scverse/rapids-singlecell#699: Modifies the same log1p and scale functions, changing how/when metadata like adata.uns["log1p"] and adata.var["mean"/"std"] are written back to AnnData.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-meta-inconsitancies

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants