refactor: replace isProbability with inline range check in stats/base/dists/geometric/mgf#13386
Draft
Planeshifter wants to merge 1 commit into
Draft
refactor: replace isProbability with inline range check in stats/base/dists/geometric/mgf#13386Planeshifter wants to merge 1 commit into
isProbability with inline range check in stats/base/dists/geometric/mgf#13386Planeshifter wants to merge 1 commit into
Conversation
…ase/dists/geometric/mgf` Normalizes the probability-range validation in `@stdlib/stats/base/dists/geometric/mgf` (both `lib/main.js` and `lib/factory.js`) from `!isProbability( p )` to the inline form `isnan( p ) || p < 0.0 || p > 1.0` used by every other JS member of the `stats/base/dists/geometric` namespace, and removes the now-unused `@stdlib/math/base/assert/is-probability` require from both files. `isProbability( x )` is defined as `!isnan( x ) && x >= 0.0 && x <= 1.0`, so the two forms agree on NaN, +/-Infinity, and all finite inputs; observable behavior is preserved (boundary cases `p = 0`, `p = 1`, `p = NaN`, `p = +/-Infinity`, `p = -0.5`, `p = 2.0` all continue to return `NaN` or their prior finite value). Namespace conformance: 13 of 14 non-`ctor` sibling packages use the inline `isnan( p ) || p <op> 0.0 || p <op> 1.0` prologue (92.9%); `mgf` was the sole outlier using the predicate form. Mirrors the identical normalization applied to `stats/base/dists/bernoulli/mgf` in merged PR #12292, which flagged this package as the natural follow-up.
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
Normalizes the probability-range validation in
@stdlib/stats/base/dists/geometric/mgf(bothlib/main.jsandlib/factory.js) from!isProbability( p )to the inline formisnan( p ) || p < 0.0 || p > 1.0used by every other JS member of thestats/base/dists/geometricnamespace, and removes the now-unused@stdlib/math/base/assert/is-probabilityrequire from both files.Mirrors the identical fix applied to
stats/base/dists/bernoulli/mgfin merged PR #12292, which called out this package as the direct follow-up: "stats/base/dists/geometric/mgfcarries the identicalisProbabilitydrift ... and is a clear follow-up candidate."stats/base/dists/geometric/mgfReplaces
!isProbability( p )with the inlineisnan( p ) || p < 0.0 || p > 1.0check in bothlib/main.jsandlib/factory.js, and drops the unused@stdlib/math/base/assert/is-probabilityimport from each file. The inline form is what the other 13 non-ctorgeometric siblings use (92.9% conformance);mgfwas the sole outlier.isProbability( x )is defined as!isnan( x ) && x >= 0.0 && x <= 1.0, so the two forms agree on NaN, ±Infinity, and all finite inputs; every boundary case exercised bytest/test.mgf.jsandtest/test.factory.js(NaN, ±Infinity,-0.5,2.0,0.0,1.0forp) returns the same value as before. Verified by pre-/post-diff spot check from a Node REPL.Related Issues
No.
Questions
No.
Other
Total diff: 2 files, 2 insertions, 4 deletions. Cross-run dedup against open PRs and the last 14 days of merged PRs targeting
stats/base/dists/geometricconfirms no overlap.Sub-signal drift observed and deliberately not applied in this PR (logged for a future maintenance pass):
mgf/manifest.jsonuses 4-space JSON indentation vs the 2-space indentation used by the 13 othermanifest.jsonfiles in the namespace and mandated by the root.editorconfig([*.{json,json.txt}] indent_style = space, indent_size = 2). Whitespace-only; would muddy the semantic focus of this PR.stdevpackage usestest/fixtures/python/instead of the namespace-standardtest/fixtures/julia/. Cascading — would require regenerating Julia fixtures and rewriting thetapeloader intest/test.jsandtest/test.native.js; out of scope for a mechanical drift PR.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code via the cross-package drift-detection routine. Structural and semantic features were extracted from every member of
stats/base/dists/geometric, the majority pattern was computed at a 75% conformance threshold, and three independent validation passes (semantic-review, cross-reference, structural-review) confirmed the single surviving correction was high-signal mechanical drift before any file was edited. The precedent set by merged PR #12292 (identical fix in the siblingbernoulli/mgfpackage) was cross-referenced and the same normalization applied here. A maintainer should audit and promote out of draft.@stdlib-js/reviewers
Generated by Claude Code