Skip to content

test: migrate stats/incr/mmaape to ULP-based assertions - #16197

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

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-mmaape

Conversation

@kgryte

@kgryte kgryte commented Oct 16, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Specifically, in test/test.js:

  • replaces the computed relative tolerance (delta = abs( expected[i] - actual ), tol = 1.0 * EPS * abs( expected[i] )) with isAlmostSameValue( actual, expected[i], 1 ).
  • adds the @stdlib/assert/is-almost-same-value require and removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.
  • normalizes the assertion message to 'returns expected value'.

ULP bound: 1 ULP (one call site).

The bound is the measured minimum. The maximum observed ULP difference over the full fixture set is 1, occurring at windows 4 and 5:

window actual expected ULP diff
0 0.3217505543966422 0.3217505543966422 0
1 0.7144496360953663 0.7144496360953663 0
2 0.8038976651460206 0.8038976651460206 0
3 0.6966474803471399 0.6966474803471399 0
4 0.5311732292121792 0.5311732292121791 1
5 0.26937384141302984 0.2693738414130298 1

Tightening to 0 ULP fails exactly those two assertions, confirming 1 is the minimum. The suite was run twice at the final bound to confirm determinism (98 passing, 0 failing both times):

$ make test TESTS_FILTER=".*/stats/incr/mmaape/.*"
  total:     98
  passing:   98

The test fixtures are hardcoded, so the result is independent of any PRNG state.

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.

Only test/test.js is modified; no source, documentation, or benchmark files are touched. The package has no test.native.js, so there is no JS vs. C discrepancy to account for here.

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. The migration was performed mechanically against the idiom established by previously merged stats/incr conversions, and the ULP bound was determined empirically via @stdlib/number/float64/base/ulp-difference rather than guessed.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01Dtg5oB6tbJnvp5MUwBBMeT


Generated by Claude Code

Ref: #11352

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

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

Copy link
Copy Markdown
Contributor

Coverage Report

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

3 participants