refactor: order validation checks by parameter position in stats/base/dists/cauchy/*#11942
refactor: order validation checks by parameter position in stats/base/dists/cauchy/*#11942Planeshifter wants to merge 14 commits intodevelopfrom
stats/base/dists/cauchy/*#11942Conversation
…h namespace majority Reorder NaN guards in the public quantile so that `isnan( gamma )` precedes `isnan( x0 )`, matching the contiguous validation pattern present in 7 of the 9 sibling packages in `@stdlib/stats/base/dists/cauchy/*` (78% conformance). Behavior is unchanged: any matching branch returns `NaN`.
Coverage Report
The above coverage report was generated for the changes in this PR. |
Planeshifter
left a comment
There was a problem hiding this comment.
We should instead change all the other packages since the order of the checks should follow the parameter order.
…ts/cauchy/cdf` Reorder NaN guards so checks follow declaration order `(x, x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/logcdf` Reorder NaN guards so checks follow declaration order `(x, x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/logpdf` Reorder NaN guards so checks follow declaration order `(x, x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/pdf` Reorder NaN guards so checks follow declaration order `(x, x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/entropy` Reorder NaN guards so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/median` Reorder NaN guards so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/mode` Reorder NaN guards so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `NaN`.
…ts/cauchy/quantile` Move `isnan( p )` to the front so the validation prologue follows declaration order `(p, x0, gamma)`. Supersedes the prior majority-vote ordering on this branch. Behavior unchanged: any matching branch returns `NaN`.
stats/base/dists/cauchy/quantile validation prologue with namespace majoritystats/base/dists/cauchy/*
|
Done — pushed eight follow-up commits, one per package, reordering the NaN guards to match parameter declaration order in Updated the PR title and body to reflect the new direction. Note: Generated by Claude Code |
Let's address this too. |
…ts/cauchy/cdf/lib/factory.js` Reorder NaN guards in the factory so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `constantFunction( NaN )`.
…ts/cauchy/logcdf/lib/factory.js` Reorder NaN guards in the factory so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `constantFunction( NaN )`.
…ts/cauchy/logpdf/lib/factory.js` Reorder NaN guards in the factory so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `constantFunction( NaN )`.
…ts/cauchy/pdf/lib/factory.js` Reorder NaN guards in the factory so checks follow declaration order `(x0, gamma)`. Behavior unchanged: any matching branch returns `constantFunction( NaN )`.
…se/dists/cauchy/quantile/lib/factory.js` Match the float-literal style used by the four sibling factories (cdf, logcdf, logpdf, pdf). Behavior unchanged.
|
Folded the
Behavior is unchanged in all five files. Generated by Claude Code |
stats/base/dists/cauchy/*stats/base/dists/cauchy/*
Aligning validation prologues across
stats/base/dists/cauchy/*to follow parameter declaration order, per @Planeshifter's review feedback on this PR. Originally surfaced by a cross-package API drift sweep over the namespace; the routine identifiedquantileas the lone outlier under a majority-vote model, but parameter-order is the correct convention and applies in the opposite direction (everything butctorneeds the swap).Description
Eight commits, one per outlier package, each a 1-line guard reorder. Behavior is unchanged in every case — every branch in the disjunction returns
NaN, so swapping the order of the operands does not affect any observable result.cdf(x, x0, gamma)x, gamma, x0x, x0, gammalogcdf(x, x0, gamma)x, gamma, x0x, x0, gammalogpdf(x, x0, gamma)x, gamma, x0x, x0, gammapdf(x, x0, gamma)x, gamma, x0x, x0, gammaentropy(x0, gamma)gamma, x0x0, gammamedian(x0, gamma)gamma, x0x0, gammamode(x0, gamma)gamma, x0x0, gammaquantile(p, x0, gamma)gamma, x0, …, pp, x0, gamma, …ctoris untouched — it's a class constructor that throwsTypeErrorviaformatrather than returningNaN, and its existing checks already follow(x0, gamma)order.Related Issues
None.
Questions
None.
Other
Validation
NaN; observable behavior is unchanged.quantiletest suite (test/test.js,test/test.factory.js,test/test.native.js) only assertsisnan(result) === trueon invalid inputs and never inspects which check fired. Same is true for the other seven test suites — they exercise NaN inputs but assert only on the result, not on ordering.ctor/lib/main.jsvalidatesx0/gammaitself before forwarding to the numeric siblings, so it is unaffected by the internal prologue order in those siblings.Out of scope
lib/factory.jsfiles incdf,logcdf,logpdf,pdf,quantileshow the same parameter-order convention drift (andquantile/lib/factory.jsadditionally usesgamma <= 0instead ofgamma <= 0.0). Logged as a follow-up — happy to fold them into this PR if preferred.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code. The initial commit (a709d01) was produced by an automated cross-package API drift sweep over the
stats/base/dists/cauchynamespace using a 75% majority-vote model. After @Planeshifter's review feedback that validation order should follow parameter declaration order, eight follow-up commits were authored mechanically to apply that convention across the seven sibling packages and to redirect thequantilereorder accordingly.@stdlib-js/reviewers