Skip to content

test: migrate stats/base/dists/normal/entropy to ULP-based assertions - #14227

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-normal-entropy
Aug 14, 2026
Merged

test: migrate stats/base/dists/normal/entropy to ULP-based assertions#14227
kgryte merged 1 commit into
developfrom
kgryte/ulp-normal-entropy

Conversation

@kgryte

@kgryte kgryte commented Aug 13, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/normal/entropy from relative tolerance assertions to ULP-based assertions.
  • replaces the delta/tol computations in test/test.js and test/test.native.js with isAlmostSameValue( y, expected[ i ], N ) and adds the corresponding @stdlib/assert/is-almost-same-value require, removing the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

ULP bounds

Both files use a bound of 1 ULP, which is the measured minimum for the full Julia fixture set:

File Previous tolerance ULP bound Measured minimum
test/test.js 1.0 * EPS * abs( expected[ i ] ) 1 1
test/test.native.js 1.0 * EPS * abs( expected[ i ] ) 1 1

The bound was tightened by starting high and lowering to the smallest passing integer. At 1 the suite is green; at 0 six assertions fail, so 1 is the minimum. The JS and C implementations evaluate the identical expression (0.5 * ln( TWO_PI * E * sigma * sigma ) using stdlib's own ln), and the native add-on was built locally and measured independently, also yielding a maximum of 1 ULP over the fixtures, hence the same bound in both files.

Verification:

  • make test TESTS_FILTER=".*/stats/base/dists/normal/entropy/.*" passes (20 assertions for test.js; 21 for test.native.js with the add-on built), run three times with identical results, so the bound is not sensitive to FMA/arch variation.
  • ESLint is clean for both files under etc/eslint/.eslintrc.tests.js.
  • Only the two test files are changed.

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?

No.

Other

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

The conversion mirrors the idiom used in previously merged conversions in the same family, most closely stats/base/dists/logistic/entropy (#14218).

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 helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored by Claude Code, which studied previously merged ULP migrations in this repository, applied the same idiom, and empirically determined the minimum ULP bound by running the test suite.


@stdlib-js/reviewers


Generated by Claude Code

@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 13, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/normal/entropy $\\color{green}178/178$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}178/178$
$\\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 14, 2026
@kgryte
kgryte marked this pull request as ready for review August 14, 2026 00:11
@kgryte
kgryte requested a review from a team August 14, 2026 00:11
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 14, 2026
@kgryte
kgryte merged commit 27d30be into develop Aug 14, 2026
66 of 67 checks passed
@kgryte
kgryte deleted the kgryte/ulp-normal-entropy branch August 14, 2026 00:11
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 14, 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