From 44d2739edb9e2f24fcef068dfb1d2247b8398c9b Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Wed, 26 Aug 2026 14:31:07 -0700 Subject: [PATCH 1/3] test: migrate math/base/special/kernel-cos to ULP-based assertions --- .../special/kernel-cos/test/test.native.js | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js index 85c767842ccf..eb8519e17bfd 100644 --- a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js @@ -23,8 +23,7 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var rempio2 = require( '@stdlib/math/base/special/rempio2' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -84,8 +83,6 @@ tape( 'the function evaluates the cosine for input values on the interval `[-pi/ tape( 'the function can be used to compute the cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (positive)', opts, function test( t ) { var expected; var values; - var delta; - var tol; var out; var x; var y; @@ -105,15 +102,9 @@ tape( 'the function can be used to compute the cosine for input values outside o break; case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; default: break; @@ -125,8 +116,6 @@ tape( 'the function can be used to compute the cosine for input values outside o tape( 'the function can be used to compute the cosine for input values outside of `[-pi/4, pi/4]` after argument reduction via `rempio2` (negative)', opts, function test( t ) { var expected; var values; - var delta; - var tol; var out; var x; var y; @@ -146,15 +135,9 @@ tape( 'the function can be used to compute the cosine for input values outside o break; case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - if ( out === expected[ i ] ) { - t.strictEqual( out, expected[ i ], 'returns expected value' ); - } else { - delta = abs( out - expected[ i ] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 - tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x+'. out: '+out+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 + t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; default: break; From bea8c77b88e595eab740c642b6a2e8682f51953f Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Wed, 26 Aug 2026 14:48:51 -0700 Subject: [PATCH 2/3] test: migrate math/base/special/kernel-cos to ULP-based assertions --- .../math/base/special/kernel-cos/test/test.native.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js index eb8519e17bfd..8abd6d869dcb 100644 --- a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js @@ -102,7 +102,8 @@ tape( 'the function can be used to compute the cosine for input values outside o break; case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; @@ -135,7 +136,8 @@ tape( 'the function can be used to compute the cosine for input values outside o break; case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - + + // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; From 96c85fd192c654e3303ad80c4d464371fa63fedb Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Wed, 26 Aug 2026 14:55:55 -0700 Subject: [PATCH 3/3] test: migrate math/base/special/kernel-cos to ULP-based assertions --- .../@stdlib/math/base/special/kernel-cos/test/test.native.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js index 8abd6d869dcb..aaae44230d07 100644 --- a/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/kernel-cos/test/test.native.js @@ -103,7 +103,6 @@ tape( 'the function can be used to compute the cosine for input values outside o case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break; @@ -137,7 +136,6 @@ tape( 'the function can be used to compute the cosine for input values outside o case 2: out = -kernelCos( y[ 0 ], y[ 1 ] ); - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 t.strictEqual( isAlmostSameValue( out, expected[ i ], 1 ), true, 'returns expected value' ); break;