From 1f6330ea428da160b0caba0fd5cf4e933ce228ec Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Aug 2026 06:42:19 +0000 Subject: [PATCH] test: migrate `math/base/special/fast/acosh` to ULP-based assertions Replaces computed relative tolerance comparisons with `isAlmostSameValue` ULP difference assertions. The ULP bounds are the measured minimums over the full fixture sets for both the JavaScript and native implementations. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01UViLFYQZDZTmUPew8Kdh85 --- .../math/base/special/fast/acosh/test/test.js | 42 +++---------------- .../special/fast/acosh/test/test.native.js | 42 +++---------------- 2 files changed, 10 insertions(+), 74 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.js b/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.js index 34e3759fe43a..155a9429960c 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.js @@ -24,7 +24,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var acosh = require( './../lib' ); @@ -46,8 +46,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the hyperbolic arccosine on the interval `[1.0,3.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -57,21 +55,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[1.0,3.0] for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 6.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 8 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine on the interval `[3.0,28.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -81,21 +71,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[3.0,28.0 for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine on the interval `[28.0,100.0]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -105,21 +87,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[28.0,100 for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine for huge values', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -129,13 +103,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', function for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.native.js index c60fe036eb12..aecd82660c79 100644 --- a/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/fast/acosh/test/test.native.js @@ -25,7 +25,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var randu = require( '@stdlib/random/base/randu' ); var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -55,8 +55,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the hyperbolic arccosine on the interval `[1.0,3.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -66,21 +64,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[1.0,3.0] for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 6.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 8 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine on the interval `[3.0,28.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -90,21 +80,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[3.0,28.0 for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine on the interval `[28.0,100.0]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -114,21 +96,13 @@ tape( 'the function computes the hyperbolic arccosine on the interval `[28.0,100 for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic arccosine for huge values', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -138,13 +112,7 @@ tape( 'the function computes the hyperbolic arccosine for huge values', opts, fu for ( i = 0; i < x.length; i++ ) { y = acosh( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1.0 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Delta: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });