Skip to content

feat: pp.scale allow selecting correction#4220

Open
AxelMcKenna wants to merge 3 commits into
scverse:mainfrom
AxelMcKenna:feat/scale-ddof
Open

feat: pp.scale allow selecting correction#4220
AxelMcKenna wants to merge 3 commits into
scverse:mainfrom
AxelMcKenna:feat/scale-ddof

Conversation

@AxelMcKenna

@AxelMcKenna AxelMcKenna commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #4196.

This adds a selectable correction parameter to sc.pp.scale. The default remains correction=1, so existing behaviour is unchanged.

The parameter is propagated through array, masked-array, sparse, and AnnData scaling paths. The documentation now explains how the variance divisor is calculated.

  • Tests included for correction=0 and correction=1, covering dense, CSR, and CSC inputs; direct arrays and AnnData; masked and unmasked observations; and centered and non-centered scaling.
  • Tests included or not required because:

@AxelMcKenna AxelMcKenna changed the title feat(pp.scale): allow selecting ddof feat: pp.scale allow selecting ddof Jul 16, 2026
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.93%. Comparing base (8673b4d) to head (9af49aa).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4220   +/-   ##
=======================================
  Coverage   79.92%   79.93%           
=======================================
  Files         121      121           
  Lines       12958    12958           
=======================================
+ Hits        10357    10358    +1     
+ Misses       2601     2600    -1     
Flag Coverage Δ
hatch-test.low-vers 79.05% <100.00%> (+<0.01%) ⬆️
hatch-test.pre 79.89% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
src/scanpy/preprocessing/_scale.py 89.58% <100.00%> (ø)

... and 1 file with indirect coverage changes

@flying-sheep

Copy link
Copy Markdown
Member

Please change to the standard name, correction: https://data-apis.org/array-api/latest/API_specification/generated/array_api.std.html

@AxelMcKenna AxelMcKenna changed the title feat: pp.scale allow selecting ddof feat: pp.scale allow selecting correction Jul 17, 2026
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