Skip to content

test: migrate stats/base/dists/halfnormal/stdev to ULP-based assertions - #14084

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-halfnormal-stdev
Aug 9, 2026
Merged

test: migrate stats/base/dists/halfnormal/stdev to ULP-based assertions#14084
kgryte merged 1 commit into
developfrom
kgryte/ulp-halfnormal-stdev

Conversation

@kgryte

@kgryte kgryte commented Aug 9, 2026

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

Both test/test.js and test/test.native.js are converted. In each, the if ( y === expected[i] ) { ... } else { delta/tol ... } block in the fixture loop is replaced by a single

t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );

and the now-unused abs/EPS requires and delta/tol declarations are removed. This mirrors the idiom already used in this family (e.g., #14069 for stats/base/dists/lognormal/variance).

ULP bound: 1 in both test/test.js and test/test.native.js.

Measured minimum: 1. Over the full 50-value Julia fixture set (test/fixtures/julia/data.json), the per-fixture minimum ULP requirement was computed by searching upward from 0; the maximum requirement across all fixtures was 1 (worst case: sigma = 2.577081059735365, y = 1.5534909422882428, expected = 1.553490942288243). At N = 0, 6 of 50 fixtures fail, so 1 is tight and cannot be lowered further. test/test.js was run twice at the final bound with identical results (55/55 assertions passing both times).

The JavaScript implementation computes sigma * sqrt( 1 - 2/pi ) and the C implementation computes sigma * SQRT1M2PI with SQRT1M2PI = 0.6028102749890869. Those two scale constants are bit-identical, and each implementation performs a single multiplication, so the same 1 ULP bound applies to both and there is no FMA-contraction exposure.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

The native addon could not be compiled in the environment used to prepare this change, so test/test.native.js was skipped locally (0 assertions run). The 1 ULP bound for the native tests was established analytically, as described above, rather than by execution. Please confirm the native tests pass in CI.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

make install-node-modules failed in the environment used to prepare this change (the available npm registry snapshot has no es-object-atoms@^1.1.2, a transitive dependency), so the project's own lint tooling could not be run in full. Compensating checks that were run:

  • test/test.js executed with a locally installed tape: 55/55 assertions passing, twice.
  • ESLint run against the project's rule sets (programmer_errors, best_practices, strict, variables, nodejs, style, es2015) plus the .eslintrc.tests.js overrides: clean. The custom stdlib/* plugin rules could not be loaded (they pull in the remark toolchain), so require-order, vars-order, require-spaces, uppercase-required-constants, and no-empty-lines-between-requires were verified by inspection against the rule definitions in etc/eslint/rules/stdlib.js.
  • EditorConfig conformance (LF, UTF-8, tab indentation, no trailing whitespace, final newline) verified by inspection; editorconfig-checker downloads its binary at runtime and could not fetch it.

CI should be treated as the authoritative lint run. Only the two test files are changed; no source, docs, or package.json changes are included.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance.

This PR was written by Claude Code running as an unattended scheduled task. It selected the package, studied previously merged conversions for the established idiom, applied the test changes, and measured the ULP bound empirically over the fixture set.


@stdlib-js/reviewers


Generated by Claude Code

…ions

Replaces EPS-scaled relative tolerance comparisons with
`@stdlib/assert/is-almost-same-value` in `test/test.js` and
`test/test.native.js`. The ULP bound was tightened to the measured
minimum of 1 ULP over the full Julia fixture set.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4ixBCT9ohYozkw8JZVWxV
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 9, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! 👋

We've noticed that you've been opening a number of PRs addressing good first issues. Thank you for your interest and enthusiasm!

Now that you've made a few contributions, we suggest no longer working on good first issues. Instead, we encourage you to prioritize cleaning up any PRs which have yet to be merged and then proceed to work on more involved tasks.

Not only does this ensure that other new contributors can work on things and get ramped up on all things stdlib, it also ensures that you can spend your time on more challenging problems. 🚀

For ideas for future PRs, feel free to search the codebase for TODOs and FIXMEs and be sure to check out other open issues on the issue tracker. Cheers!

@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/halfnormal/stdev $\\color{green}168/168$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}168/168$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 9, 2026
@kgryte
kgryte marked this pull request as ready for review August 9, 2026 06:31
@kgryte
kgryte requested a review from a team August 9, 2026 06:31
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 9, 2026
@kgryte
kgryte merged commit 12769a7 into develop Aug 9, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-halfnormal-stdev branch August 9, 2026 06:32
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants