Skip to content

test: migrate stats/incr/nanmprod to ULP-based assertions - #15140

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

test: migrate stats/incr/nanmprod to ULP-based assertions#15140
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-nanmprod

Conversation

@kgryte

@kgryte kgryte commented Sep 10, 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/incr/nanmprod from computed relative-tolerance comparisons (delta = abs( expected - acc() ) / tol = EPSILON * abs( expected ), asserted via t.strictEqual( delta <= tol, ... )) to ULP-difference assertions using @stdlib/assert/is-almost-same-value.
  • applies the migration to the two tolerance-based assertion sites in test/test.js (the overflow may be transient and underflow may be transient tests). The package has no test/test.native.js, and the remaining assertions in the file are exact comparisons against null, NaN, +-infinity, signed zeros, and exactly representable values, which are correct as-is and are left unchanged.
  • removes the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires, along with the delta and tol variable declarations, introducing an actual variable at each site to match the migrated idiom used elsewhere in stats/incr.

Only a test file is changed; no implementation, fixture, or documentation changes are included.

ULP bounds

Assertion Previous tolerance ULP bound
overflow may be transient EPSILON * abs( expected ) 1
underflow may be transient EPSILON * abs( expected ) 1

These are the minimum integer bounds N such that isAlmostSameValue( actual, expected, N ) holds at each site. They were measured independently of the test harness by driving the accumulator directly and searching upward from 0 for the smallest bound satisfied at each site, starting from a high bound (64, which passes) and tightening:

  • Overflow site: the accumulator returns 1.0715086071862675e+299 against an expected value of ldexp( 0.01, 1000 ) = 1.0715086071862673e+299, a difference of exactly 1 ULP.
  • Underflow site: the accumulator returns 9.33263618503219e-304 against an expected value of ldexp( 0.01, -1000 ) = 9.332636185032189e-304, a difference of exactly 1 ULP.

Tightening either site by one ULP was verified to fail: at N = 0, 2 of 483 assertions fail (one per site), confirming both bounds are minimal rather than merely sufficient. Both sites are fully deterministic — they use fixed ldexp inputs with no random data.

make test TESTS_FILTER=".*/stats/incr/nanmprod/.*" was run twice at the final bounds with identical results: 483/483 passing on both runs, no failures, ruling out FMA/architecture-dependent flakiness on this platform. make eslint-tests TESTS_FILTER=".*/stats/incr/nanmprod/.*" is clean.

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 resulting diff mirrors the already-merged migrations for the sibling packages stats/incr/nanmhmean (#15125) and stats/incr/nanmstdev (#15072), which have the same accumulator test structure.

One environment note, which did not affect verification: make install-node-modules initially failed with ETARGET for es-object-atoms@^1.1.2. As previously observed in #15116 and #15125, this is a stale local npm packument cache rather than a repository or registry problem (the registry does serve 1.1.2); npm cache clean --force followed by make install-node-modules and make init succeeded, and the full toolchain was available for this PR. Separately, the lint-editorconfig-files pre-commit step could not download the editorconfig-checker binary in this sandbox and was skipped via SKIP_LINT_EDITORCONFIG; the changed lines were checked manually for LF line endings, tab indentation, no trailing whitespace, and a final newline. All other pre-commit lint steps ran normally.

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, running as an unattended scheduled task. It selected the package, studied previously migrated packages in the same family to match the established idiom, performed the migration, and determined the minimum passing ULP bound empirically at each assertion site.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_019Fdzvd3XioK2mzPYas59Hf


Generated by Claude Code

Migrate the two relative-tolerance assertion sites in the tests for
`stats/incr/nanmprod` to ULP-difference assertions using
`@stdlib/assert/is-almost-same-value`. Both sites require a minimum
bound of 1 ULP.

Ref: #11352

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

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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/incr/nanmprod $\\color{green}145/145$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}145/145$
$\\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