Skip to content

test: migrate stats/base/dists/cosine/stdev to ULP-based assertions - #14211

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-cosine-stdev
Aug 12, 2026
Merged

test: migrate stats/base/dists/cosine/stdev to ULP-based assertions#14211
kgryte merged 1 commit into
developfrom
kgryte/ulp-cosine-stdev

Conversation

@kgryte

@kgryte kgryte commented Aug 12, 2026

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

Specifically, in both test/test.js and test/test.native.js, the fixture loop's delta/tol computation is replaced with

t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );

adding a @stdlib/assert/is-almost-same-value require and dropping the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Final ULP constant: 1 (both test.js and test.native.js).

The bound was tightened empirically rather than assumed. Starting from 64, the minimum passing integer over the full fixture set (100 non-null cases) is 1:

  • at N = 0: 36 of 110 assertions fail;
  • at N = 1: 110/110 pass.

The maximum observed ULP difference across the fixtures is exactly 1 ULP.

test.js was run twice at the final N with identical results. The native test is skipped locally (the addon is not built in this environment), but the same bound is safe by construction: src/main.c and lib/main.js both compute s * 0.36151205519132795 using the identical constant. A single IEEE-754 double multiplication is correctly rounded and admits no FMA contraction, so the native result is bit-identical to the JavaScript result and the measured 1 ULP bound carries over.

Only the two test files are modified; no implementation, fixture, or documentation changes.

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 full project toolchain could not be installed in the authoring environment: make install-node-modules fails with ETARGET: No matching version found for es-object-atoms@^1.1.2 (the registry reachable from that environment publishes only up to 1.1.1), so make init and the project eslint configuration could not be run. As a workaround, tape was installed in an isolated scratch directory to execute the package's test suite, and the changed files were linted against core rules (no-unused-vars, no-undef, no-trailing-spaces, no-mixed-spaces-and-tabs, one-var, vars-on-top, semi, eqeqeq, no-irregular-whitespace), which report clean. The diff otherwise mirrors the idiom of previously merged conversions (e.g. #14163, #14155) verbatim. Leaving this as a draft so CI can confirm the full lint and native builds.

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 running as an unattended scheduled task. It surveyed prior merged conversions to match the established idiom, applied the test changes, and determined the minimum ULP bound empirically by bisecting the constant against the full fixture set.


@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 12, 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/cosine/stdev $\\color{green}180/180$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}180/180$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 12, 2026
@kgryte
kgryte marked this pull request as ready for review August 12, 2026 22:56
@kgryte
kgryte requested a review from a team August 12, 2026 22:56
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 12, 2026
@kgryte
kgryte merged commit 83e21db into develop Aug 12, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-cosine-stdev branch August 12, 2026 22:56
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 12, 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.

2 participants