Document apply_transform POWER c1=0.0 fallback in docstring - #98
Open
kgdunn wants to merge 1 commit into
Open
Conversation
The Notes section for ``power`` claimed the default was ``c1 = 0.5``, but the signature is ``c1: float = 0.0`` with a silent body-side substitution to ``0.5`` when ``c1 == 0.0``. Rewrite that bullet so it matches what the code actually does (no behaviour change). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ocQ71UFry6rkJnBNLeQKg
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
src/scorepilot/core/transforms.py::apply_transformdocumented itspowerdefault asc1 = 0.5, but the signature isc1: float = 0.0with a silent body-side substitution to0.5when the caller passes (or leaves)c1 == 0.0. The docstring bullet contradicted the signature. This PR rewrites that one bullet so the Notes section describes what the code actually does — no behaviour change.Fixes
src/scorepilot/core/transforms.py(apply_transform, Notes →powerbullet): replacedwith a bullet that spells out both facts:
A reader looking only at the signature would previously have assumed
c1=0.0producedsign(x) * abs(x)**0 = sign(x)(a piecewise constant); the doc now surfaces the fallback (exponent = c1 if c1 != 0.0 else 0.5in_transform_values).pyproject.toml: PATCH bump0.22.0→0.22.1for the docs-only change.Ruff check + format both pass on the touched file.
Bugs flagged for maintainer
The docstring is now honest, but the underlying API shape is still misleading and worth a follow-up:
apply_transform(..., c1: float = 0.0)with_transform_valuesdoingexponent = c1 if c1 != 0.0 else 0.5is a "signature default that lies". For every transform kind other thanPOWER,c1=0.0behaves as documented; forPOWERit silently rewrites to0.5. A caller who reasons purely fromhelp(apply_transform)(or an IDE tooltip) will build a mental model that disagrees with runtime behaviour. This is exactly the kind of foot-gun that gets caught later in a preview when a user thinks they asked forx**0and gotsqrt(|x|).c1: float = 0.5and drop theif c1 != 0.0 else 0.5fallback. Cleanest; makes signature and behaviour agree. Requires auditing every caller that passesPOWERwith the default to confirm none of them rely on the0.0sentinel being reinterpreted.0.0-as-sentinel semantics but make it explicit:c1: float | None = None, thenexponent = 0.5 if c1 is None else c1. Removes the "silently rewrites a valid float" surprise and lets a caller who genuinely wantsx**0pass0.0and get it.POWERoff from the sharedc1param entirely (e.g. a dedicatedpower_exponent: float = 0.5).Option 1 or 2 is the sensible next step; picking between them depends on whether any preprocessing-spec serializer out there is relying on
c1=0.0round-tripping throughPOWER.Generated by Claude Code