Skip to content

test: migrate stats/base/dists/halfnormal/logpdf to ULP-based assertions - #14756

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-halfnormal-logpdf
Aug 28, 2026
Merged

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

Conversation

@kgryte

@kgryte kgryte commented Aug 28, 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/halfnormal/logpdf from relative tolerance testing to ULP difference testing.

Specifically, test/test.logpdf.js, test/test.factory.js, and test/test.native.js are updated to replace the delta/tol computation (previously 40.0 * EPS * abs( expected[ i ] )) with @stdlib/assert/is-almost-same-value, and the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires are removed.

The ULP constant used in all three files is 4, which is the measured minimum over the full 1000-case Julia fixture set:

  • main.js (JavaScript): maximum observed ULP difference is 4.
  • factory.js (JavaScript): maximum observed ULP difference is 4.
  • native.js (C): maximum observed ULP difference is 4.

The bound was tightened from a high starting value down to the smallest integer which still passes; at 3 all three files fail two assertions (the worst case being x = 0.2430826624208926, sigma = 0.1403330726611418, where the expected value is 0.23771503646137082 and the returned value is 0.2377150364613707). The full suite was run twice at 4 to confirm the result is deterministic, once with the native add-on built locally so that test.native.js was exercised rather than skipped.

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.

Only test files are modified; no source, documentation, or benchmark files are touched.

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 as part of an automated conversion task. The migration mirrors the idiom established in previously merged conversions (e.g. stats/base/dists/laplace/logpdf), and the ULP bound was determined empirically by measuring the per-fixture ULP difference and verifying that the next smaller bound fails.


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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/halfnormal/logpdf $\\color{red}305/307$
$\\color{green}+99.35\\%$
$\\color{red}19/20$
$\\color{green}+95.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{red}305/307$
$\\color{green}+99.35\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 28, 2026
@kgryte
kgryte marked this pull request as ready for review August 28, 2026 23:01
@kgryte
kgryte requested a review from a team August 28, 2026 23:01
@kgryte
kgryte merged commit 122bfa7 into develop Aug 28, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-halfnormal-logpdf branch August 28, 2026 23:02
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Aug 28, 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