Skip to content

test: migrate stats/incr/nanrss to ULP-based assertions - #16284

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-nanrss
Oct 23, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-nanrss

Conversation

@kgryte

@kgryte kgryte commented Oct 21, 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 stats/incr/nanrss unit tests from a computed tolerance check to ULP-based assertions.

Previously, test/test.js required @stdlib/number/float64/base/ulp-difference and hand-rolled the comparison as an if ( actual === expected ) { ... } else { diff = ulpdiff( actual, expected ); t.strictEqual( diff <= 1, ... ) } branch. This replaces that with a single t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' ) assertion backed by @stdlib/assert/is-almost-same-value, matching the idiom already used in the sibling package stats/incr/rss.

Final ULP constant: 0 (both assertion sites).

The bound was tightened empirically rather than assumed. Starting from 64, the full test suite was re-run while lowering the bound (64 → 32 → 16 → 8 → 4 → 2 → 1 → 0); all 13 assertions pass at every value down to and including 0, so 0 is the measured minimum. This is expected to be exact and platform-independent: the accumulator sums squares of integer-valued residuals, so every intermediate value is exactly representable in double precision. The suite was run twice at the final bound to confirm determinism (13/13 passing both times).

Only test code is touched; no behavior, documentation, or benchmark changes are included.

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?

The previous assertion allowed a 1 ULP difference, while the measured minimum here is 0. This PR uses 0 per the "minimum required ULP value" guidance in #11352 and for consistency with stats/incr/rss, but happy to relax it back to 1 if reviewers would prefer to retain a margin.

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/incr/nanrss/.*" → 13/13 passing (run twice).
  • ESLint clean against etc/eslint/.eslintrc.tests.js.
  • make lint-editorconfig-files could not be run in this environment because the editorconfig-checker binary download is blocked by the sandbox network policy. The file was checked manually instead: LF line endings, UTF-8, tab indentation, final newline present, and no trailing-whitespace changes relative to develop.

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 primarily by Claude Code, including locating the candidate package, mirroring the conversion idiom from the already-converted stats/incr/rss, and empirically tightening the ULP bound.


@stdlib-js/reviewers


Generated by Claude Code

Replace the hand-rolled ULP tolerance check in the `stats/incr/nanrss`
unit tests with `@stdlib/assert/is-almost-same-value`, mirroring the
idiom already used in `stats/incr/rss`.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qgtt3BxHNqCDE6TW4DgEeV
@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 23, 2026
@kgryte
kgryte marked this pull request as ready for review October 23, 2026 18:28
@kgryte
kgryte requested a review from a team October 23, 2026 18:28
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Oct 23, 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!

@kgryte
kgryte merged commit 8d33774 into develop Oct 23, 2026
81 of 85 checks passed
@kgryte
kgryte deleted the kgryte/ulp-nanrss branch October 23, 2026 18:30
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Oct 23, 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.

3 participants