From ad782492728bcb47222729a3d27d93947f1631ca Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 2 Oct 2026 06:27:22 +0000 Subject: [PATCH] test: migrate `stats/base/dists/planck/variance` to ULP-based assertions Migrates unit tests from relative tolerance checks (`delta <= tol`) to ULP-based assertions using `@stdlib/assert/is-almost-same-value`. The measured maximum ULP difference over the 1000-element Python fixture set is 1, so the assertions use a bound of 1 ULP, which is the tightest integer bound which passes (a bound of 0 fails 103 of the 1000 cases). Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_017VFfQViBwsnjm37sqzyMF6 --- .../stats/base/dists/planck/variance/test/test.js | 13 ++----------- .../base/dists/planck/variance/test/test.native.js | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.js index 58ea9f4caede..95ba96879d52 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.js @@ -21,9 +21,8 @@ // 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 EPS = require( '@stdlib/constants/float64/eps' ); var variance = require( './../lib' ); @@ -60,8 +59,6 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the function tape( 'the function returns the variance of a Planck distribution', function test( t ) { var expected; var lambda; - var delta; - var tol; var i; var y; @@ -69,13 +66,7 @@ tape( 'the function returns the variance of a Planck distribution', function tes lambda = data.lambda; for ( i = 0; i < expected.length; i++ ) { y = variance( lambda[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. lambda: '+lambda[ 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/stats/base/dists/planck/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.native.js index 8b4207032eb3..7bdab4c934b9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/variance/test/test.native.js @@ -22,9 +22,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 abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -69,8 +68,6 @@ tape( 'if provided a shape parameter `lambda` which is nonpositive, the function tape( 'the function returns the variance of a Planck distribution', opts, function test( t ) { var expected; var lambda; - var delta; - var tol; var i; var y; @@ -78,13 +75,7 @@ tape( 'the function returns the variance of a Planck distribution', opts, functi lambda = data.lambda; for ( i = 0; i < expected.length; i++ ) { y = variance( lambda[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'lambda: '+lambda[ i ]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 1.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. lambda: '+lambda[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });