From 1d953b3a40cf950765d8b204665f9dd9237da2eb Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 7 Oct 2026 02:23:53 +0000 Subject: [PATCH] test: migrate `stats/incr/nanprod` to ULP-based assertions Migrate the test cases for `stats/incr/nanprod` from relative tolerance assertions to ULP-based assertions using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened to the minimum passing integer value: `1` for both the transient overflow and transient underflow test cases. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012q26xGJXEMSDYX3oukdEbc --- 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/nanprod/test/test.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/incr/nanprod/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanprod/test/test.js index a275b34031cf..cde5e80f4749 100644 --- a/lib/node_modules/@stdlib/stats/incr/nanprod/test/test.js +++ b/lib/node_modules/@stdlib/stats/incr/nanprod/test/test.js @@ -23,11 +23,10 @@ var tape = require( 'tape' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPSILON = require( '@stdlib/constants/float64/eps' ); var normal = require( '@stdlib/random/base/normal' ); var ldexp = require( '@stdlib/math/base/special/ldexp' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnan = require( '@stdlib/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isEven = require( '@stdlib/math/base/assert/is-even' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); @@ -135,8 +134,6 @@ tape( 'the accumulator function can return a result which overflows', function t tape( 'overflow may be transient', function test( t ) { var expected; - var delta; - var tol; var acc; var x; var y; @@ -155,10 +152,7 @@ tape( 'overflow may be transient', function test( t ) { acc( y ); acc( z ); - delta = abs( expected - acc() ); - tol = EPSILON * abs( expected ); - - t.strictEqual( delta <= tol, true, 'within tolerance. Expected: '+expected+'. Actual: '+acc()+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( acc(), expected, 1 ), true, 'returns expected value' ); t.end(); }); @@ -175,8 +169,6 @@ tape( 'the accumulator function can return a result which underflows', function tape( 'underflow may be transient', function test( t ) { var expected; - var delta; - var tol; var acc; var x; var y; @@ -198,10 +190,7 @@ tape( 'underflow may be transient', function test( t ) { acc( z ); - delta = abs( acc() - expected ); - tol = EPSILON * abs( expected ); - - t.strictEqual( delta <= tol, true, 'within tolerance. Expected: '+expected+'. Actual: '+acc()+'. Delta: '+delta+'. Tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( acc(), expected, 1 ), true, 'returns expected value' ); t.end(); });