From 5a8b5165b55d871efd0bef2c7da5d465b582c2fd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 19 Sep 2026 14:14:45 +0000 Subject: [PATCH] test: migrate `stats/base/dists/cauchy/pdf` to ULP-based assertions Migrate the relative-tolerance assertions in the `factory` tests to ULP-difference assertions using `@stdlib/assert/is-almost-same-value`. All 3000 fixture values (1000 each across the `large_gamma`, `negative_median`, and `positive_median` fixtures) match the expected values bit-for-bit, so the minimum required ULP bound is 0. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_012hgqZuiCHtonPPHkqjUiTE --- 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 --- --- .../dists/cauchy/pdf/test/test.factory.js | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.factory.js index 87a331805e3d..cdc7b3fdec1a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/cauchy/pdf/test/test.factory.js @@ -22,10 +22,9 @@ 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 PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var factory = require( './../lib/factory.js' ); @@ -138,10 +137,8 @@ tape( 'if provided a nonpositive `gamma`, the created function always returns `N tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (large gamma)', function test( t ) { var expected; - var delta; var gamma; var pdf; - var tol; var x0; var x; var y; @@ -154,23 +151,15 @@ tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (la for ( i = 0; i < x.length; i++ ) { pdf = factory( x0[i], gamma[i] ); y = pdf( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', x0: '+x0[i]+', gamma: '+gamma[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. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (`x0 < 0`)', function test( t ) { var expected; - var delta; var gamma; var pdf; - var tol; var x0; var x; var y; @@ -183,23 +172,15 @@ tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (`x for ( i = 0; i < x.length; i++ ) { pdf = factory( x0[i], gamma[i] ); y = pdf( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', x0: '+x0[i]+', gamma: '+gamma[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. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); }); tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (`x0 > 0`)', function test( t ) { var expected; - var delta; var gamma; var pdf; - var tol; var x0; var x; var y; @@ -212,13 +193,7 @@ tape( 'the created function evaluates the pdf for `x` given `x0` and `gamma` (`x for ( i = 0; i < x.length; i++ ) { pdf = factory( x0[i], gamma[i] ); y = pdf( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', x0: '+x0[i]+', gamma: '+gamma[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. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ); } t.end(); });