From 1e9c9993e7f969a42b538b34da7e0f5bd6b55e1c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 24 Sep 2026 14:26:35 +0000 Subject: [PATCH] test: migrate `stats/base/dists/invgamma/mode` to ULP-based assertions Replace the computed relative-tolerance comparisons in `test/test.js` and `test/test.native.js` with ULP difference assertions using `@stdlib/assert/is-almost-same-value`. The measured maximum ULP difference over the full Julia fixture set is `0` for both the JavaScript and C implementations, so the tests now assert bitwise equality with the reference values. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LRbc6joCcUqZmp2X4Va3wh --- .../stats/base/dists/invgamma/mode/test/test.js | 13 ++----------- .../base/dists/invgamma/mode/test/test.native.js | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.js index 23182b6e74ed..4f0c62ceb099 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.js @@ -21,11 +21,10 @@ // MODULES // var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var mode = require( './../lib' ); @@ -96,10 +95,8 @@ tape( 'if provided `beta <= 0`, the function returns `NaN`', function test( t ) tape( 'the function returns the mode of an inverse gamma distribution', function test( t ) { var expected; - var delta; var alpha; var beta; - var tol; var i; var y; @@ -108,13 +105,7 @@ tape( 'the function returns the mode of an inverse gamma distribution', function beta = data.beta; for ( i = 0; i < expected.length; i++ ) { y = mode( alpha[ i ], beta[ i ] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'alpha: '+alpha[ i ]+', beta: '+beta[ i ]+', y: '+y+', expected: '+expected[ i ] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. alpha: '+alpha[ i ]+'. beta: '+beta[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.native.js index b36db614b3d6..82bdee605ee8 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/invgamma/mode/test/test.native.js @@ -23,11 +23,10 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var tryRequire = require( '@stdlib/utils/try-require' ); +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 PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); // FIXTURES // @@ -105,10 +104,8 @@ tape( 'if provided `beta <= 0`, the function returns `NaN`', opts, function test tape( 'the function returns the mode of an inverse gamma distribution', opts, function test( t ) { var expected; - var delta; var alpha; var beta; - var tol; var i; var y; @@ -117,13 +114,7 @@ tape( 'the function returns the mode of an inverse gamma distribution', opts, fu beta = data.beta; for ( i = 0; i < expected.length; i++ ) { y = mode( alpha[ i ], beta[ i ] ); - if ( y === expected[ i ] ) { - t.strictEqual( y, expected[ i ], 'alpha: '+alpha[ i ]+', beta: '+beta[ i ]+', y: '+y+', expected: '+expected[ i ] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 2.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. alpha: '+alpha[ i ]+'. beta: '+beta[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); });