From b66950c56ee7a4a8e7439bc1d6040dbbb8a3f093 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 26 Sep 2026 14:31:44 +0000 Subject: [PATCH] test: migrate `stats/incr/nanmmape` to ULP-based assertions Migrate the test suite from relative-tolerance (`EPS * abs(...)`) comparisons to ULP-difference assertions using `@stdlib/assert/is-almost-same-value`, tightening the converted assertion to the minimum ULP bound which still passes. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Pz66GGnki7M6Z74TNLByVD --- 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/stats/incr/nanmmape/test/test.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanmmape/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmmape/test/test.js index 40934d9eabd5..26359df6984a 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanmmape/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanmmape/test/test.js @@ -21,9 +21,9 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var incrnanmmape = require( './../lib' ); @@ -73,10 +73,8 @@ tape( 'the function returns an accumulator function', function test( t ) { tape( 'the accumulator function computes a moving mean absolute percentage error incrementally', function test( t ) { var expected; var actual; - var delta; var data; var acc; - var tol; var N; var i; @@ -103,13 +101,7 @@ tape( 'the accumulator function computes a moving mean absolute percentage error ]; for ( i = 0; i < N; i++ ) { actual = acc( data[i][0], data[i][1] ); - if ( actual === expected[i] ) { - t.strictEqual( actual, expected[i], 'returns expected value' ); - } else { - delta = abs( expected[i] - actual ); - tol = 1.5 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. Actual: '+actual+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); });