Skip to content

test: migrate stats/base/dists/signrank/pdf to ULP-based assertions - #15899

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-signrank-pdf
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-signrank-pdf

Conversation

@kgryte

@kgryte kgryte commented Oct 4, 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/signrank/pdf from relative tolerance assertions to ULP-based assertions, replacing the delta/tol computation (delta = abs( y - expected[ i ] ), tol = 20.0 * EPS * abs( expected[ i ] )) with isAlmostSameValue( y, expected[ i ], 5 ) via @stdlib/assert/is-almost-same-value.
  • drops the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the delta and tol variable declarations.
  • updates the affected assertion messages to 'returns expected value'.

Files changed (test files only):

  • test/test.pdf.js
  • test/test.factory.js
  • test/test.native.js

Final ULP constant: 5 (used in all three test files).

This was tightened from an initial bound of 64. The maximum measured ULP difference over the 100-element fixture set is exactly 5, and is identical for the JavaScript and C implementations:

test.pdf.js      (JS)       -> max ulpDifference = 5
test.factory.js  (JS)       -> max ulpDifference = 5
test.native.js   (native C) -> max ulpDifference = 5

worst case: x = 51, n = 23
  actual   = 0.0003389120101928709
  expected = 0.00033891201019287115

The JavaScript and C implementations returned bit-identical results for all 100 fixture cases. A bound of 4 ULP fails in all three files (one failing assertion each), confirming 5 is the minimum.

Note that the previous bound in test.native.js was looser than the JavaScript files (80.0 * EPS vs. 20.0 * EPS); since the measured ULP difference is the same for both implementations, all three files now use the same bound.

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 test suite was run twice at the final bound of 5 ULP to confirm determinism; the native add-on was built locally (node-gyp rebuild) so that the test.native.js assertions were actually exercised rather than skipped. All four test files pass (342 assertions, 0 failures) on both runs.
  • Linting is clean for the changed files using the project's test ESLint configuration (make eslint-tests TESTS_FILTER=".*/stats/base/dists/signrank/pdf/.*").
  • The editorconfig-checker step could not run in this environment because its binary is downloaded from a GitHub release that outbound network policy blocked. EditorConfig compliance was instead verified manually for the changed files: LF line endings, UTF-8 (ASCII), tab indentation, no trailing whitespace, and a final newline.

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

This PR was written primarily by Claude Code, following the idiom established by previously merged conversions in the same family (e.g. stats/base/dists/hypergeometric/cdf, stats/base/dists/beta/logpdf). The ULP bound was measured empirically rather than guessed.


@stdlib-js/reviewers


Generated by Claude Code

Replaces relative tolerance assertions with ULP difference assertions
via `@stdlib/assert/is-almost-same-value`. The measured maximum ULP
difference over the fixture set is `5` for both the JavaScript and C
implementations, so assertions use a bound of `5` ULP.

Ref: #11352

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

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/signrank/pdf $\\color{red}359/361$
$\\color{green}+99.45\\%$
$\\color{red}36/37$
$\\color{green}+97.30\\%$
$\\color{green}5/5$
$\\color{green}+100.00\\%$
$\\color{red}359/361$
$\\color{green}+99.45\\%$

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.

2 participants