Skip to content

test: migrate stats/base/dists/erlang/entropy to ULP-based assertions - #14438

Merged
kgryte merged 1 commit into
developfrom
philipp/ulp-stats-base-dists-erlang-entropy
Aug 20, 2026
Merged

kgryte merged 1 commit into
developfrom
philipp/ulp-stats-base-dists-erlang-entropy

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates stats/base/dists/erlang/entropy test fixtures from the old computed EPS-based tolerance idiom (delta/tol/abs( delta ) <= tol) to ULP-based assertions using @stdlib/assert/is-almost-same-value, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • applies the change to both test/test.js and test/test.native.js.
  • the minimum ULP bound was determined empirically by running the JavaScript implementation against the full 200-value fixture set and measuring the exact ULP difference (via @stdlib/number/float64/base/ulp-difference) between each computed and expected value. The tightest passing bound is 22528 ULPs, driven by a handful of fixture entries where the expected entropy value is extremely close to zero (e.g. k: 14, lambda: 15.118382880503544, expected: -0.0016827325793946635), causing catastrophic cancellation in the entropy formula and correspondingly large ULP differences despite tiny absolute error. This is consistent with the original test's already-generous 15000 * EPS relative tolerance, which was evidently chosen for the same reason. Verified deterministic by running the suite twice at this bound, and confirmed tight by observing 1 failure at 22527.
  • test/test.native.js could not be exercised in the conversion environment (no compiled native add-on was available, so those tests are skipped via tryRequire), so the same 22528 bound was applied there for consistency with test/test.js, mirroring the convention observed in other already-converted packages with native counterparts (e.g. math/base/special/acos).

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.

No.

Checklist

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

  • Read, understood, and followed the [contributing guidelines][contributing].

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 generated by an automated Claude Code routine that discovers packages still using the old EPS-tolerance test idiom, converts them to isAlmostSameValue-based ULP assertions mirroring prior art from already-merged conversions in the same package family, and empirically determines the tightest passing ULP bound. Opened as a draft for maintainer review given the unusually large (though empirically verified and precedented) ULP bound.


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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/erlang/entropy $\\color{green}202/202$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}202/202$
$\\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 20, 2026
@kgryte
kgryte marked this pull request as ready for review August 20, 2026 10:23
@kgryte
kgryte requested a review from a team August 20, 2026 10:23
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 20, 2026
@kgryte
kgryte merged commit 0527c5a into develop Aug 20, 2026
82 checks passed
@kgryte
kgryte deleted the philipp/ulp-stats-base-dists-erlang-entropy branch August 20, 2026 10:24
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 20, 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.

4 participants