From 6c4449bd1abcd5c43ebe3cb92b0f5daac2e0ea1d Mon Sep 17 00:00:00 2001 From: kgryte Date: Tue, 11 Aug 2026 18:19:31 +0000 Subject: [PATCH] test: migrate `stats/base/dists/beta/median` to ULP-based assertions Replaces the computed relative tolerance (`15.0 * EPS * abs( expected )`) in the fixture loop with an ULP-based assertion using `@stdlib/assert/is-almost-same-value`. The ULP bound was tightened to the measured minimum over the full fixture set (15 ULP; 14 fails). Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01WT1k4EJXMZQLG6FfPXP8kR --- .../stats/base/dists/beta/median/test/test.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/beta/median/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/beta/median/test/test.js index 7d1a3b496c00..c9312eaf683b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/beta/median/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/beta/median/test/test.js @@ -21,11 +21,10 @@ // 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 PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var median = require( './../lib' ); @@ -96,10 +95,8 @@ tape( 'if provided `beta <= 0`, the function returns `NaN`', function test( t ) tape( 'the function returns the median of a beta 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 median of a beta distribution', function test( t beta = data.beta; for ( i = 0; i < expected.length; i++ ) { y = median( 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 = 15.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 ], 15 ), true, 'returns expected value' ); } t.end(); });