From a8285952d7ca1908ff13920221611bc56a85bf7f Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Fri, 18 Sep 2026 11:20:55 -0700 Subject: [PATCH 1/2] test: migrate stats/base/dists/bradford/stdev to ULP-based assertions --- .../base/dists/bradford/stdev/test/test.js | 37 +++++-------------- .../dists/bradford/stdev/test/test.native.js | 37 +++++-------------- 2 files changed, 20 insertions(+), 54 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.js index 940094f25914..8fbdd0f9645b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.js @@ -22,9 +22,8 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var stdev = require( './../lib' ); @@ -65,8 +64,6 @@ tape( 'if provided `c <= 0`, the function returns `NaN`', function test( t ) { tape( 'the function returns the standard deviation of a Bradford distribution given small parameter `c`', function test( t ) { var expected; - var delta; - var tol; var i; var c; var y; @@ -75,28 +72,20 @@ tape( 'the function returns the standard deviation of a Bradford distribution gi c = smallC.c; for ( i = 0; i < expected.length; i++ ) { y = stdev( c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - - /* - * NOTE: the tolerance is set high in this case due to: - * - * 1. The shape parameter being very small which causes differences in the `ln` calculations when compared to the test fixtures by SciPy. - * 2. The expected values being very small. - */ - tol = 322.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + + /* + * NOTE: the tolerance is set high in this case due to: + * + * 1. The shape parameter being very small which causes differences in the `ln` calculations when compared to the test fixtures by SciPy. + * 2. The expected values being very small. + */ + t.strictEqual( isAlmostSameValue( y, expected[ i ], 371 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns the standard deviation of a Bradford distribution given large parameter `c`', function test( t ) { var expected; - var delta; - var tol; var i; var c; var y; @@ -105,13 +94,7 @@ tape( 'the function returns the standard deviation of a Bradford distribution gi c = largeC.c; for ( i = 0; i < expected.length; i++ ) { y = stdev( c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 8.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 9 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js index 6849ca37ff80..0d50fd5368a5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js @@ -23,9 +23,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -74,8 +73,6 @@ tape( 'if provided `c <= 0`, the function returns `NaN`', opts, function test( t tape( 'the function returns the standard deviation of a Bradford distribution given small parameter `c`', opts, function test( t ) { var expected; - var delta; - var tol; var i; var c; var y; @@ -84,28 +81,20 @@ tape( 'the function returns the standard deviation of a Bradford distribution gi c = smallC.c; for ( i = 0; i < expected.length; i++ ) { y = stdev( c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - - /* - * NOTE: the tolerance is set high in this case due to: - * - * 1. The shape parameter being very small which causes differences in the `ln` calculations when compared to the test fixtures by SciPy. - * 2. The expected values being very small. - */ - tol = 322.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + + /* + * NOTE: the tolerance is set high in this case due to: + * + * 1. The shape parameter being very small which causes differences in the `ln` calculations when compared to the test fixtures by SciPy. + * 2. The expected values being very small. + */ + t.strictEqual( isAlmostSameValue( y, expected[ i ], 371 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns the standard deviation of a Bradford distribution given large parameter `c`', opts, function test( t ) { var expected; - var delta; - var tol; var i; var c; var y; @@ -114,13 +103,7 @@ tape( 'the function returns the standard deviation of a Bradford distribution gi c = largeC.c; for ( i = 0; i < expected.length; i++ ) { y = stdev( c[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'c: '+c[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 10.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 371 ), true, 'returns expected value' ); } t.end(); }); From 46a11ebb528241580c1c12265d21758febc5039c Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 22 Sep 2026 12:30:44 -0700 Subject: [PATCH 2/2] test: fix ULP value for large_c block in test.native.js --- .../@stdlib/stats/base/dists/bradford/stdev/test/test.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js index 0d50fd5368a5..ccb34eaceb69 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/bradford/stdev/test/test.native.js @@ -103,7 +103,7 @@ tape( 'the function returns the standard deviation of a Bradford distribution gi c = largeC.c; for ( i = 0; i < expected.length; i++ ) { y = stdev( c[i] ); - t.strictEqual( isAlmostSameValue( y, expected[ i ], 371 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 9 ), true, 'returns expected value' ); } t.end(); });