From 317a4e6ca12423dfd146527d4ad6768d625690ae Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 05:01:36 +0000 Subject: [PATCH] test: migrate math/base/special/coth to ULP-based testing Replaces the EPS-based relative-tolerance comparisons in test.js and test.native.js with @stdlib/assert/is-almost-same-value, using the minimum required ULP values verified against the fixtures. Resolves a part of #11352. --- .../math/base/special/coth/test/test.js | 53 +++---------------- .../base/special/coth/test/test.native.js | 53 +++---------------- 2 files changed, 12 insertions(+), 94 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/coth/test/test.js b/lib/node_modules/@stdlib/math/base/special/coth/test/test.js index 1b6f2d3b0d2d..2284b0b8f786 100644 --- a/lib/node_modules/@stdlib/math/base/special/coth/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/coth/test/test.js @@ -26,8 +26,7 @@ var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -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 coth = require( './../lib' ); @@ -50,8 +49,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function computes the hyperbolic cotangent', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -64,21 +61,13 @@ tape( 'the function computes the hyperbolic cotangent', function test( t ) { continue; } y = coth( 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.75 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (tiny negative)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -88,21 +77,13 @@ tape( 'the function computes the hyperbolic cotangent (tiny negative)', function for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (tiny positive)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -112,21 +93,13 @@ tape( 'the function computes the hyperbolic cotangent (tiny positive)', function for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (large negative)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -136,21 +109,13 @@ tape( 'the function computes the hyperbolic cotangent (large negative)', functio for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (large positive)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -160,13 +125,7 @@ tape( 'the function computes the hyperbolic cotangent (large positive)', functio for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/coth/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/coth/test/test.native.js index 3ea327fda9db..56c4789c64ad 100644 --- a/lib/node_modules/@stdlib/math/base/special/coth/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/coth/test/test.native.js @@ -28,8 +28,7 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); // VARIABLES // @@ -59,8 +58,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function computes the hyperbolic cotangent', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -73,21 +70,13 @@ tape( 'the function computes the hyperbolic cotangent', opts, function test( t ) continue; } y = coth( 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.75 * EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (tiny negative)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -97,21 +86,13 @@ tape( 'the function computes the hyperbolic cotangent (tiny negative)', opts, fu for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (tiny positive)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -121,21 +102,13 @@ tape( 'the function computes the hyperbolic cotangent (tiny positive)', opts, fu for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (large negative)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -145,21 +118,13 @@ tape( 'the function computes the hyperbolic cotangent (large negative)', opts, f for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); }); tape( 'the function computes the hyperbolic cotangent (large positive)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -169,13 +134,7 @@ tape( 'the function computes the hyperbolic cotangent (large positive)', opts, f for ( i = 0; i < x.length; i++ ) { y = coth( x[i] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. Value: '+y+'. Expected: '+expected[i]+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( y, expected[ i ], 'returns expected value' ); } t.end(); });