style: align outliers in stats/base/dists/chi with namespace majority patterns#11722
Closed
Planeshifter wants to merge 2 commits intodevelopfrom
Closed
style: align outliers in stats/base/dists/chi with namespace majority patterns#11722Planeshifter wants to merge 2 commits intodevelopfrom
stats/base/dists/chi with namespace majority patterns#11722Planeshifter wants to merge 2 commits intodevelopfrom
Conversation
…vention Add explicit `isnan(k) || k < 0.0` guard at the top of `lib/main.js`, matching the validation prologue used by `mean` and `variance` in the same namespace (validation prologue present in 10/12 chi siblings, 83%). The guard preserves observable behavior — NaN and negative `k` already returned NaN via delegation to `variance()` — but makes the contract explicit and consistent with the rest of `stats/base/dists/chi`.
Restructure `README.md` so C APIs live in their own `<section class="c">` with a top-level `## C APIs` heading (present in 10/12 chi siblings, 83%), and so the JS `## Examples` section precedes the C APIs section rather than following it. Promote the C subsection heading from `#### Usage` to `### Usage` to match the level-3/level-3 pairing used by `pdf/README.md` and `logpdf/README.md`. No prose or code-block content is modified.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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.
Description
Aligning outliers in
stats/base/dists/chiwith namespace majority patterns (random namespace pick, seed2026-04-22-drift).Namespace summary
@stdlib/stats/base/dists/chicdf,ctor,entropy,kurtosis,logpdf,mean,mode,pdf,quantile,skewness,stdev,variance)package.jsonshape, README section layout,manifest.jsonshape, test/benchmark/examples naming, public signature, validation prologue, error construction, JSDoc shape,@stdlib/*dependenciesbinding.gyp,manifest.json,include/,src/,lib/native.js,benchmark/benchmark.native.js,test/test.native.js,examples/c/), top-level## C APIsREADME section, validation prologue at top oflib/main.js, Julia fixture layout undertest/fixtures/julia/lib/factory.js(only present for functions taking a shape-parameter closure — 4/12) and relatedtest.factory.js; these are structurally optional and excluded from drift detectionstats/base/dists/chi/stdevAdds an explicit NaN / negative-
kvalidation prologue tolib/main.js, aligningstdevwith the convention followed by 10 of the 12 siblings in@stdlib/stats/base/dists/chi(~83% conformance). Previously, the guard was implicit — invalid inputs propagated through thevariancedelegation and happened to returnNaNby accident rather than by contract. Observable behavior is unchanged; this is a correctness-by-construction fix that makes the invariant explicit at the call site.stats/base/dists/chi/cdfRestructures
cdf/README.mdto match the canonical section layout shared by 10 of 12 packages in the@stdlib/stats/base/dists/chinamespace (~83% conformance; reference:pdf/README.md,logpdf/README.md). The C APIs block is extracted from inside<section class="usage">, promoted to a top-level<section class="c">wrapper, and its headings are raised one level (## C APIs,### Usage). Section order is corrected to JS Usage → JS Examples → C APIs. No prose or code-block content is changed.Related Issues
No.
Questions
No.
Other
Validation
package.json/ README inspection across all 12 members.@stdlib/*dependencies) extracted per-package fromlib/main.js.Deliberately excluded from this PR
quantile/lacks native C entirely (missingbinding.gyp,manifest.json,include/,src/,lib/native.js, C benchmark/examples,test/test.native.js) — out of scope: adding native support requires authoring a C implementation, not a mechanical drift fix.quantile/lib/main.jslacks the majority validation prologue — cross-reference verdict wasconfirmed-drift, but the semantic-review agent flagged it asintentional-deviationbecausequantileis a one-liner that delegates togammaQuantile(which performs NaN propagation and its own domain checks). Per the routine, anyintentional-deviationverdict from any agent drops the correction.stdev/test/fixtures/uses Python fixtures while 11/11 siblings (excludingctor) use Julia fixtures — out of scope: regenerating fixtures from a different reference implementation is a cascading change that would require re-verifying tolerance against the existing test data.ctor/outliers on virtually every structural feature — intentional deviation:ctoris a distribution constructor, not a scalar function, and has a genuinely different shape.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by an automated cross-package drift-detection routine driven by Claude Code. The routine (1) selected
stats/base/dists/chiat random (seed2026-04-22-drift) from eligible stdlib namespaces (≥8 non-autogenerated members), (2) extracted structural and semantic features from every member, (3) computed majority patterns with a 75% conformance threshold, (4) ran three independent validation agents to confirm each outlier finding as mechanical, non-semantic drift, and (5) applied only corrections that preserved observable behavior and did not require cascading changes. Every edit and commit message was produced by the routine; a human maintainer should audit before promoting this PR out of draft.@stdlib-js/reviewers