Skip to content

test: migrate stats/base/dists/geometric/logcdf to ULP-based assertions - #15327

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-geometric-logcdf
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-geometric-logcdf

Conversation

@kgryte

@kgryte kgryte commented Sep 18, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Only test files are changed (test/test.logcdf.js, test/test.factory.js, test/test.native.js); test/test.js contains no tolerance-based assertions and is left untouched. The implementation is unchanged.

Per fixture set, the ULP constants were tightened to the measured minimum over the full 1000-element fixtures:

Fixture Previous tolerance ULP constant Measured minimum
small_p.json 20.0 * EPS * abs( expected[i] ) 15 15 (fails at 14)
large_p.json 30.0 * EPS * abs( expected[i] ) 42 42 (fails at 41)

The same constants are used in all three test files. The main export, the factory-generated function, and the native add-on all produce identical ULP profiles.

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?

One, concerning test/test.native.js.

The previous native tolerances were identical to the JavaScript ones (20.0 / 30.0 times EPS), and this pull request likewise applies the same constants to both. To confirm rather than assume this, the add-on was built locally and the native implementation was compared against the JavaScript implementation across all 2000 fixture entries: the two agree bit-for-bit on every entry (0 differing values), and the native ULP profile reproduces the JavaScript one exactly — 15 / 42.

Note that, for large_p.json, the ULP constant (42) is numerically larger than the previous relative-tolerance multiplier (30.0 * EPS). This is expected rather than a loosening: the old bound scaled with abs( expected[i] ), which, within a binade, can be up to twice the spacing at that magnitude, so a bound of 30 * EPS * abs( expected[i] ) admits up to ~60 ULP in the worst case. 42 is the measured maximum over the fixture set and the assertion fails at 41.

A reviewer on a different platform/compiler may wish to confirm the native constants before merge; hence the draft status.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Verification performed:

  • All four test files pass: test.logcdf.js (2012 assertions), test.factory.js (2016), test.native.js (2012, executed rather than skipped since the add-on was built locally), and test.js (3).
  • The suite was run twice at the final constants with identical results, to rule out FMA/architecture-dependent flakiness.
  • Minimality was confirmed programmatically against the fixtures for the main export, the factory-generated function, and the native add-on: each constant is the maximum observed ULP difference, and the worst-case entry fails at N-1.
  • ESLint is clean for the changed files under etc/eslint/.eslintrc.tests.js (run via make JAVASCRIPT_LINTER=eslint ESLINT_CONF=... lint-javascript-files).

Two notes on tooling, both environmental and unrelated to the diff:

  • The lint-editorconfig-files pre-commit step could not run, as it downloads the editorconfig-checker binary from GitHub and that request was blocked. The changed files were therefore checked manually and are compliant (LF endings, UTF-8, tab indentation, final newline, no trailing whitespace).
  • The check-licenses-production pre-push step could not run either. In this environment, make install-node-modules fails outright (the available npm registry snapshot does not carry es-object-atoms@^1.1.2, which a transitive dependency requires), so the development dependencies had to be installed piecemeal and the license tooling crashes on the resulting incomplete dependency tree. This pull request adds no dependencies.

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 selected the package, mirrored the conversion idiom from already-migrated packages (e.g., stats/base/dists/triangular/logcdf and stats/base/dists/logistic/logcdf), measured the minimum ULP bounds against the fixtures for both the JavaScript and the locally built native implementation, and ran the verification described above.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01F16PRh9EwFCQffzr6sRWrN


Generated by Claude Code

…ions

Migrate the package tests from relative tolerance testing to ULP
difference testing. The ULP constants are the measured minimums over
the full fixtures: 15 for `small_p.json` and 42 for `large_p.json`.

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

---
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 Sep 18, 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/geometric/logcdf $\\color{green}295/295$
$\\color{green}+100.00\\%$
$\\color{green}27/27$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}295/295$
$\\color{green}+100.00\\%$

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

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