Skip to content

test: migrate stats/base/dists/discrete-uniform/logpmf to ULP-based assertions - #15883

Draft
kgryte wants to merge 1 commit into
developfrom
claude/great-brahmagupta-dxj28x
Draft

kgryte wants to merge 1 commit into
developfrom
claude/great-brahmagupta-dxj28x

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/discrete-uniform/logpmf from relative tolerance testing to ULP difference testing, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • Replaces the delta/tol relative error computations (previously tol = 1.0 * EPS * abs( expected[ i ] )) with isAlmostSameValue( y, expected[ i ], 1 ) assertions from @stdlib/assert/is-almost-same-value, and drops the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps imports.
  • Updates test/test.logpmf.js, test/test.factory.js, and test/test.native.js. test/test.js is unchanged, as it contains no tolerance-based assertions.

Final ULP constant: 1 ULP, used uniformly across all three test files and all three fixture sets (small_range, medium_range, large_range).

Measured minimum. The bound was tightened agentically rather than guessed. Starting from a high bound and lowering it, the minimum ULP difference required to pass the full fixture set (3 × 1000 cases) is 1 for every implementation:

Fixture set lib/main.js lib/factory.js lib/native.js
small_range 1 1 1
medium_range 1 1 1
large_range 1 1 1

1 is the tightest integer bound that holds: re-running the suite with 0 ULP produces 607 failures, so the bound cannot be lowered further.

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.

Verification performed:

  • make test TESTS_FILTER=".*/stats/base/dists/discrete-uniform/logpmf/.*" is green: 3017 (test.factory.js) + 3011 (test.logpmf.js) + 3 (test.js) + 3006 (test.native.js) assertions passing, 0 failing.
  • The native add-on was built locally (make install-node-addons NODE_ADDONS_PATTERN="discrete-uniform/logpmf") so that test.native.js was actually exercised at 1 ULP rather than skipped.
  • The suite was run twice at the final bound with identical results, to rule out FMA/architecture-dependent flakiness.
  • make lint-javascript-files with etc/eslint/.eslintrc.tests.js is clean, and the full pre-commit static analysis report passes.
  • Only the three test files are changed.

One note on local tooling: the lint_editorconfig pre-commit task could not run in this environment, because editorconfig-checker downloads its binary from GitHub releases and the network egress available here blocks that fetch. The applicable EditorConfig rules for *.js were instead verified directly on the changed files (LF endings, UTF-8, tab indentation, no trailing whitespace, final newline present); CI will run the real check.

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 running as an unattended scheduled task. It studied previously merged conversions in the same family (notably stats/base/dists/discrete-uniform/logcdf) to match the established idiom, applied the mechanical substitution, and then determined the minimum ULP bound empirically by running the test suite across candidate bounds.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01FJKn4dpTUjRm6CFGRXBkdh


Generated by Claude Code

… assertions

Replace relative tolerance assertions with ULP-based assertions using
`@stdlib/assert/is-almost-same-value`. The ULP bound was tightened to the
measured minimum of 1 ULP across all fixture sets for the main, factory,
and native implementations.

Ref: #11352

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

---
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/discrete-uniform/logpmf $\\color{green}291/291$
$\\color{green}+100.00\\%$
$\\color{green}31/31$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}291/291$
$\\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.

2 participants