From 63fb720a216e1041517cbd702c800da455a231f7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 11 Sep 2026 09:22:31 +0000 Subject: [PATCH] test: migrate stats/base/dists/rayleigh/entropy to ULP-based assertions Replaces the relative-tolerance (EPS/delta/tol) comparison in the fixture-driven test with `@stdlib/assert/is-almost-same-value`, matching the idiom used in previously converted sibling packages (e.g., stats/base/dists/rayleigh/pdf, rayleigh/cdf). Applies to both test/test.js and test/test.native.js. The minimum required ULP bound was measured empirically by computing the ULP distance between actual and expected values across the full fixture set for both the JavaScript and native implementations: max observed diff is 1 ULP for both. Verified that a bound of 0 fails (6 assertions) and 1 passes deterministically across repeated runs. Resolves a part of #11352. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HPZpFvV75WUR79qSe8Katc --- 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: passed - 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 --- --- .../stats/base/dists/rayleigh/entropy/test/test.js | 13 ++----------- .../base/dists/rayleigh/entropy/test/test.native.js | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.js index f64090e7590e..8ec7ee4ef027 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.js @@ -21,10 +21,9 @@ // 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 NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var entropy = require( './../lib' ); @@ -65,8 +64,6 @@ tape( 'if provided a scale `sigma` that is not a positive number, the function r tape( 'the function returns the differential entropy of a Rayleigh distribution', function test( t ) { var expected; var sigma; - var delta; - var tol; var i; var y; @@ -74,13 +71,7 @@ tape( 'the function returns the differential entropy of a Rayleigh distribution' sigma = data.sigma; for ( i = 0; i < expected.length; i++ ) { y = entropy( sigma[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'sigma:'+sigma[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 40.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. sigma: '+sigma[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/rayleigh/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.native.js index 2579ea16f980..0a81bbe3bb6c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/rayleigh/entropy/test/test.native.js @@ -22,11 +22,10 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); // VARIABLES // @@ -74,8 +73,6 @@ tape( 'if provided a scale `sigma` that is not a positive number, the function r tape( 'the function returns the differential entropy of a Rayleigh distribution', opts, function test( t ) { var expected; var sigma; - var delta; - var tol; var i; var y; @@ -83,13 +80,7 @@ tape( 'the function returns the differential entropy of a Rayleigh distribution' sigma = data.sigma; for ( i = 0; i < expected.length; i++ ) { y = entropy( sigma[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'sigma:'+sigma[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[ i ] ); - tol = 40.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. sigma: '+sigma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });