docs: correct core transforms/profiling docstrings to match code (v0.22.1) - #102
Open
kgdunn wants to merge 1 commit into
Open
docs: correct core transforms/profiling docstrings to match code (v0.22.1)#102kgdunn wants to merge 1 commit into
kgdunn wants to merge 1 commit into
Conversation
Two computational-function docstring drifts caught by an audit pass: 1. apply_transform (core/transforms.py): the Notes section documented the POWER transform as sign(x) * abs(x) ** c1 with default c1 = 0.5. But the signature default is c1 = 0.0, and _transform_values uses 'exponent = c1 if c1 != 0.0 else 0.5'. Passing c1=0.0 therefore produces the signed square root, not sign(x) * abs(x) ** 0 = sign(x) as the stated formula would imply. Rewrite the formula to match the guard. 2. suggest_transform (core/profiling.py): the docstring said 'a milder skew suggests a signed power (root)', but both LOG and POWER gate on the same strongly_skewed = summary.skewness > 1.0 threshold. POWER is returned when the variable is strongly skewed but fails LOG's positivity or wide-range preconditions, not when the skew is milder. Values with skewness <= 1.0 return NONE, never POWER. Bump version to 0.22.1 (PATCH: docs-only, no behavioural change). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CtFYvCesNLLVKrxoUk2M8r
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.
Summary
A docstring audit across the computational and user-facing functions in
src/scorepilot/found two clear drifts between docstrings and code. Both are incore/, the numerical engine, so users reading the API docs would be actively misled.1.
apply_transform—src/scorepilot/core/transforms.pyThe Notes section documented the POWER transform as:
Two problems:
c1: float = 0.0, not0.5._transform_valuesusesexponent = c1 if c1 != 0.0 else 0.5, so passingc1=0.0(the default) produces the signed square root, notsign(x) * abs(x) ** 0 = sign(x)as the stated formula would imply.Rewritten to match the actual guard, so both the formula and the default line up with what the code does.
2.
suggest_transform—src/scorepilot/core/profiling.pyThe docstring said:
But both LOG and POWER gate on the same
strongly_skewed = summary.skewness > 1.0threshold. POWER is returned when a variable is strongly skewed but fails LOG's positivity or wide-range preconditions — not when the skew is milder. Values withskewness <= 1.0returnNONE, neverPOWER.Rewritten to describe the actual branching.
Files touched
src/scorepilot/core/transforms.py— docstring only (line 51).src/scorepilot/core/profiling.py— docstring only (lines 143–147).pyproject.toml— version bump to0.22.1(PATCH).uv.lock— refreshed to match the new version (perCLAUDE.md's "refresh the lockfile in the same PR" rule).No behavioural change; docs-only correctness fix.
Test plan
pyproject.tomlversion bumped;uv.lockrefreshed souv sync --frozenstill resolves.uv run pytest,ruff,pyright) is green on the PR.The audit did not flag any other real docstring/code inconsistencies in
core/,api/,db/,dataset_store.py,samples.py,config.py,schemas.py, ormain.py(cross-validation defaults,quality_reporttolerance semantics,fit_model/observation_contributions/fit_pca/cross_validatereturn shapes, andapply_spec/_center_scalebehaviour all matched their docstrings).Generated by Claude Code