From edf699598fd2e79ce1d7b4a63b30938b3f7fcc4e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 17 Aug 2026 18:18:53 +0000 Subject: [PATCH] test: migrate `math/base/special/gammaln` to ULP-based assertions Replaces relative-tolerance comparisons with `isAlmostSameValue` in both the JavaScript and native test suites. The ULP bounds were measured over the full fixture sets and tightened to the minimum passing values: 2 ULP for the positive-integer fixtures and 15 ULP for the decimal-value fixtures. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014Ae9H3xMMYKcipgJot7h18 --- .../math/base/special/gammaln/test/test.js | 23 +++---------------- .../base/special/gammaln/test/test.native.js | 23 +++---------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.js b/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.js index b709027ea84b..da1a0d050fb0 100644 --- a/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/gammaln/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 abs = require( '@stdlib/math/base/special/abs' ); var ln = require( '@stdlib/math/base/special/ln' ); var pow = require( '@stdlib/math/base/special/pow' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var gammaln = require( './../lib' ); @@ -88,8 +87,6 @@ tape( 'the function returns `-ln(x)` for very small x', function test( t ) { tape( 'the function evaluates the natural logarithm of the gamma function (positive integers)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -99,21 +96,13 @@ tape( 'the function evaluates the natural logarithm of the gamma function (posit for ( i = 0; i < x.length; i++ ) { y = gammaln( x[ i ] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 21.2 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the natural logarithm of the gamma function (decimal values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -123,13 +112,7 @@ tape( 'the function evaluates the natural logarithm of the gamma function (decim for ( i = 0; i < x.length; i++ ) { y = gammaln( 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.1e4 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 15 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.native.js index bef227c0baa5..28715da7eca7 100644 --- a/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/gammaln/test/test.native.js @@ -22,13 +22,12 @@ 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 abs = require( '@stdlib/math/base/special/abs' ); var ln = require( '@stdlib/math/base/special/ln' ); var pow = require( '@stdlib/math/base/special/pow' ); 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' ); @@ -97,8 +96,6 @@ tape( 'the function returns `-ln(x)` for very small x', opts, function test( t ) tape( 'the function evaluates the natural logarithm of the gamma function (positive integers)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -108,21 +105,13 @@ tape( 'the function evaluates the natural logarithm of the gamma function (posit for ( i = 0; i < x.length; i++ ) { y = gammaln( x[ i ] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'x: '+x[i]+'. Expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 21.2 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the natural logarithm of the gamma function (decimal values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -132,13 +121,7 @@ tape( 'the function evaluates the natural logarithm of the gamma function (decim for ( i = 0; i < x.length; i++ ) { y = gammaln( 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.1e4 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 15 ), true, 'returns expected value' ); } t.end(); });