Skip to content

test: migrate stats/base/dists/rayleigh/median to ULP-based assertions - #15971

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-base-dists-rayleigh-median
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-base-dists-rayleigh-median

Conversation

@kgryte

@kgryte kgryte commented Oct 8, 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 unit tests for stats/base/dists/rayleigh/median from relative tolerance assertions to ULP difference assertions, as proposed in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol computation and corresponding t.ok( delta <= tol, ... ) assertion in test/test.native.js with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );.
  • replaces the equivalent fixture-loop assertion in test/test.js with the same ULP-based assertion, so that both test files share a single accuracy budget.
  • adds a @stdlib/assert/is-almost-same-value require and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires from test/test.native.js.

Only test/test.js and test/test.native.js are modified; no implementation, documentation, benchmark, or fixture files are touched. The existing NaN and invalid-parameter assertions are left as-is, as exact comparisons remain correct for those cases.

The ULP bound below is the measured minimum: 0 is both the floor of the ULP scale and the measured maximum ULP difference over the fixture set, i.e. every fixture value is reproduced exactly, so no nonzero budget is required.

Test file Previous tolerance ULP bound (measured minimum)
test/test.js exact (t.strictEqual) 0
test/test.native.js 1.0 * EPS 0

Measured by computing number/float64/base/ulp-difference against test/fixtures/julia/data.json for every assertion: all 50 fixture values match exactly (ULP difference 0) for both the JavaScript and C implementations.

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.

  • make test TESTS_FILTER=".*/stats/base/dists/rayleigh/median/.*" passes (55/55).
  • The native add-on was compiled locally (node-gyp rebuild) so that test/test.native.js was actually exercised rather than skipped; it passes (55/55) against the compiled C implementation.
  • Both suites were run twice at the final ULP value to confirm the results are deterministic (no FMA/architecture-dependent variation).
  • make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/rayleigh/median/.*" is clean.

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 written by Claude Code, mirroring the migration idiom established by previously merged conversions in this family (e.g., stats/base/dists/lognormal/median, stats/base/dists/gumbel/median, stats/base/dists/normal/median). The ULP bound was measured empirically rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

Migrate the unit tests for `stats/base/dists/rayleigh/median` from
relative tolerance assertions to ULP difference assertions.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QMso5LvKAfjzZrpbNHmA8

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@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 Oct 8, 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/rayleigh/median $\\color{green}166/166$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}166/166$
$\\color{green}+100.00\\%$

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

This branch has not been deployed

No deployments
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants