refactor: add explicit NaN guard to stats/base/dists/arcsine/median native source#12896
Closed
Planeshifter wants to merge 1 commit into
Closed
refactor: add explicit NaN guard to stats/base/dists/arcsine/median native source#12896Planeshifter wants to merge 1 commit into
stats/base/dists/arcsine/median native source#12896Planeshifter wants to merge 1 commit into
Conversation
…g packages Adds the explicit `stdlib_base_is_nan` guard (and corresponding `is_nan.h` include + manifest dependency) so the native median implementation matches the validation prologue used by 6/8 sibling 2-arg distribution functions in `stats/base/dists/arcsine` (`mean`, `stdev`, `entropy`, `kurtosis`, `mode`, `skewness`) and by 23/25 (92%) sibling `*/median/src/main.c` files across `stats/base/dists`. Behavior is unchanged: NaN inputs continue to propagate to a NaN return via the arithmetic path; this only makes the early-return explicit.
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
This pull request:
stats/base/dists/arcsine/medianimplementation with the validation prologue used by 6 of 8 sibling 2-argument distribution functions in the same namespace and by 23 of 25 (92%)*/median/src/main.cfiles acrossstats/base/dists.Namespace summary
@stdlib/stats/base/dists/arcsine(14 members)package.json/manifest.jsonkeys, README structure, JS validation prologue and JSDoc shape, presence of native/Julia/factory artifacts[Usage, Examples, C APIs, Usage, Examples](11/14),stdlib_base_is_nanguard in 2-arg C sources (6/8)isnanguard (4/8 for 2-arg, 9/13 across non-ctor),lib/factory.jspresence (5/14)stats/base/dists/arcsine/medianmedian/src/main.cpreviously guarded withif ( a >= b )only, where the sibling C sourcesmean,stdev,entropy,kurtosis,mode, andskewnessall open withif ( stdlib_base_is_nan( a ) || stdlib_base_is_nan( b ) || a >= b ). Behavior is unchanged — NaN inputs already propagate to a NaN return via the arithmetic path; this only makes the early-return explicit and matches the namespace convention. Adds the corresponding#include "stdlib/math/base/assert/is_nan.h"and registers@stdlib/math/base/assert/is-nanunderbuild,benchmark, andexamplesinmanifest.jsonso the native build resolves the header.Related Issues
None.
Questions
No.
Other
Validation
Structural features were extracted by reading the file tree and
package.json/manifest.json/README.mdof each of the 14 namespace members. Semantic features (JS public signature, validation prologue, JSDoc shape) were extracted directly fromlib/main.jsof every member; native-source content was inspected manually as a follow-on once structural analysis showed near-uniform native-file presence (12/14). Each surviving outlier was put through three independent validation agents (semantic review, cross-reference, structural review) before any patch was applied — the cross-reference agent caught that the original patch sketch was incomplete (manifest.jsonalso needed theis-nandependency or the build would break), and the patch was extended before commit.Deliberately excluded from this PR:
stats/base/dists/arcsine/logcdf— open-PR collision with feat: add C implementation forstats/base/dists/arcsine/logcdf#3389 and feat: add C implementation for stats/base/dists/arcsine/logcdf #10739stats/base/dists/arcsine/ctor—ctoris a constructor class, not a scalar function; the native skeleton is not applicablekurtosisandskewness— both return mathematical constants (-1.5and0.0respectively), so reference values would be uninformativeisnanguard inmean,median,stdev,variance— 4-of-8 split in the 2-arg JS sources, below the 75% threshold for declaring a majority patternstats/base/dists/arcsine/variance/src/main.cNaN guard — ecosystem-wide presence for*/variance/src/main.cis 78%, below the 90% threshold for treating absence as driftChecklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of the automated cross-package drift detection routine. Candidate-outlier enumeration and within-namespace majority computation ran locally; each surviving candidate was validated by three independent agents (semantic review, cross-reference against tests / docs / consumers, structural review including manifest implications) before the patch was applied. A human maintainer should verify the patch before promoting this PR out of draft.
@stdlib-js/reviewers
Generated by Claude Code