From a44892f5e256d7c01b38b7606aa0cc677e931152 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 25 Sep 2026 10:23:15 +0000 Subject: [PATCH] test: migrate `stats/base/dists/kumaraswamy/stdev` to ULP-based assertions Replaces the computed relative-tolerance assertions in `test/test.js` and `test/test.native.js` with `@stdlib/assert/is-almost-same-value`. The ULP bound (10564) is the measured minimum over the full 1000-point Julia fixture set for both the JavaScript and native implementations. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01K4KbwigC41ecFnMXdUkDQM --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: skipped - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/dists/kumaraswamy/stdev/test/test.js | 27 +++++++------------ .../kumaraswamy/stdev/test/test.native.js | 27 +++++++------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.js index 8e180bc8291f..af3e5ce64b5b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/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 PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); var stdev = require( './../lib' ); @@ -105,8 +104,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bounded distribution', function test( t ) { var expected; - var delta; - var tol; var a; var b; var i; @@ -115,22 +112,16 @@ tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bo expected = data.expected; a = data.a; b = data.b; + + /* + * High tolerance needed due to compounding errors in σ = √(m₂ - m₁²): + * - Two beta function evaluations with different parameters + * - Subtraction precision loss when m₂ ≈ m₁² + * - Square root operation amplifying small errors + */ for ( i = 0; i < expected.length; i++ ) { y = stdev( a[i], b[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - - /* - * High tolerance needed due to compounding errors in σ = √(m₂ - m₁²): - * - Two beta function evaluations with different parameters - * - Subtraction precision loss when m₂ ≈ m₁² - * - Square root operation amplifying small errors - */ - tol = 10000 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 10564 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.native.js index c452bf9bd924..1b0e8a7c7c56 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/stdev/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 PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); // FIXTURES // @@ -117,8 +116,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bounded distribution', opts, function test( t ) { var expected; - var delta; - var tol; var a; var b; var i; @@ -127,22 +124,16 @@ tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bo expected = data.expected; a = data.a; b = data.b; + + /* + * High tolerance needed due to compounding errors in σ = √(m₂ - m₁²): + * - Two beta function evaluations with different parameters + * - Subtraction precision loss when m₂ ≈ m₁² + * - Square root operation amplifying small errors + */ for ( i = 0; i < expected.length; i++ ) { y = stdev( a[i], b[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - - /* - * High tolerance needed due to compounding errors in σ = √(m₂ - m₁²): - * - Two beta function evaluations with different parameters - * - Subtraction precision loss when m₂ ≈ m₁² - * - Square root operation amplifying small errors - */ - tol = 18500 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 10564 ), true, 'returns expected value' ); } t.end(); });