From 8b0f8134da46425b94019b5391ad82b536689d72 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Wed, 22 Jul 2026 12:02:31 +0530 Subject: [PATCH 1/3] test: migrate \math/base/special/sqrtpi\ to ULP-based testing --- .../math/base/special/sqrtpi/test/test.js | 55 ++++--------------- .../base/special/sqrtpi/test/test.native.js | 55 ++++--------------- 2 files changed, 22 insertions(+), 88 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js index 1d5ac950ef04..d1bcca841e92 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js @@ -21,13 +21,12 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/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 sqrtpi = require( './../lib' ); @@ -53,8 +52,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function evaluates the principal square root when `x` is on the interval `[50,500]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -66,9 +63,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -76,8 +71,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[20,50]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -89,9 +82,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -99,8 +90,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[3,20]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -112,9 +101,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -122,8 +109,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[0.8,3]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -135,9 +120,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -145,8 +128,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates principal square root when `x` is on the interval `[0.0,0.8]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -158,9 +139,7 @@ tape( 'the function evaluates principal square root when `x` is on the interval if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -168,8 +147,6 @@ tape( 'the function evaluates principal square root when `x` is on the interval tape( 'the function evaluates the principal square root when `x` is on the interval `[1e-300,1e-308]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -181,9 +158,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -191,8 +166,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is subnormal', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -204,9 +177,7 @@ tape( 'the function evaluates the principal square root when `x` is subnormal', if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -214,8 +185,6 @@ tape( 'the function evaluates the principal square root when `x` is subnormal', tape( 'the function evaluates the principal square root for huge positive numbers', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -227,9 +196,7 @@ tape( 'the function evaluates the principal square root for huge positive number if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js index 8c390c0cc9db..59e5d2563271 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js @@ -22,14 +22,13 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/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 tryRequire = require( '@stdlib/utils/try-require' ); -var abs = require( '@stdlib/math/base/special/abs' ); // FIXTURES // @@ -62,8 +61,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the principal square root when `x` is on the interval `[50,500]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -75,9 +72,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -85,8 +80,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[20,50]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -98,9 +91,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -108,8 +99,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[3,20]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -121,9 +110,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -131,8 +118,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is on the interval `[0.8,3]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -144,9 +129,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -154,8 +137,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates principal square root when `x` is on the interval `[0.0,0.8]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -167,9 +148,7 @@ tape( 'the function evaluates principal square root when `x` is on the interval if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -177,8 +156,6 @@ tape( 'the function evaluates principal square root when `x` is on the interval tape( 'the function evaluates the principal square root when `x` is on the interval `[1e-300,1e-308]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -190,9 +167,7 @@ tape( 'the function evaluates the principal square root when `x` is on the inter if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -200,8 +175,6 @@ tape( 'the function evaluates the principal square root when `x` is on the inter tape( 'the function evaluates the principal square root when `x` is subnormal', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -213,9 +186,7 @@ tape( 'the function evaluates the principal square root when `x` is subnormal', if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); @@ -223,8 +194,6 @@ tape( 'the function evaluates the principal square root when `x` is subnormal', tape( 'the function evaluates the principal square root for huge positive numbers', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -236,9 +205,7 @@ tape( 'the function evaluates the principal square root for huge positive number if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + t.strictEqual( isAlmostSameValue( y, expected[i], 1 ), true, 'returns expected value' ); } } t.end(); From c31c8ee86d7a61e531bf413ec21982038ec700f2 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Wed, 22 Jul 2026 12:26:30 +0530 Subject: [PATCH 2/3] trigger CI From 180aff742a22b7117d853eb7684bffe0e7d6b38c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 22 Jul 2026 04:21:22 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/math/base/special/sqrtpi/test/test.js | 4 ++-- .../@stdlib/math/base/special/sqrtpi/test/test.native.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js index d1bcca841e92..0407fa0a4f0c 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.js @@ -23,8 +23,8 @@ var tape = require( 'tape' ); var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); -var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); +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 sqrtpi = require( './../lib' ); diff --git a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js index 59e5d2563271..deeb8e611a22 100644 --- a/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/sqrtpi/test/test.native.js @@ -24,8 +24,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ); -var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ); +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 tryRequire = require( '@stdlib/utils/try-require' );