From a115abe07f342555abbc2e5e0ef9ba831f9166dd Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 06:46:53 +0000 Subject: [PATCH] test: migrate `math/base/special/bessely1` to ULP-based assertions Migrates the tests for `math/base/special/bessely1` from relative tolerance testing to ULP difference testing. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_016QXf8qgJE6oxk7kYtn5zQZ --- 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 --- --- .../math/base/special/bessely1/test/test.js | 82 ++----------------- .../base/special/bessely1/test/test.native.js | 82 ++----------------- 2 files changed, 18 insertions(+), 146 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js index 2e33f3c9d0fa..d6a301af532f 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.js @@ -21,12 +21,12 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var randu = require( '@stdlib/random/base/randu' ); 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 y1 = require( './../lib' ); @@ -53,8 +53,6 @@ tape( 'main export is a function', function test( t ) { tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (very large positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -63,21 +61,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 300.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 254 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (large positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -86,21 +76,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 600.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 689 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (medium positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -109,21 +91,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 300.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 395 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (small positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -132,21 +106,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1800.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2338 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates Bessel function of the second kind of one order (Y_1) (smaller positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -155,21 +121,13 @@ tape( 'the function evaluates Bessel function of the second kind of one order (Y x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 4.5 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 5 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (tiny positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -178,13 +136,7 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 8.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -204,8 +156,6 @@ tape( 'The Bessel function of the second kind of one order (Y_1) (subnormal valu tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (huge positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -214,21 +164,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 4500.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1200 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of order one (Y_1) for positive x over a wide range of magnitudes', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -237,13 +179,7 @@ tape( 'the function evaluates the Bessel function of the second kind of order on x = positiveGamut.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 16.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 27 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.native.js index 4e5b0c901c67..695a09cd3cc5 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely1/test/test.native.js @@ -22,12 +22,12 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var randu = require( '@stdlib/random/base/randu' ); 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 tryRequire = require( '@stdlib/utils/try-require' ); @@ -62,8 +62,6 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (very large positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -72,21 +70,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 300.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 254 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (large positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -95,21 +85,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 600.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 689 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (medium positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -118,21 +100,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 300.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 395 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (small positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -141,21 +115,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 1800.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2338 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates Bessel function of the second kind of one order (Y_1) (smaller positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -164,21 +130,13 @@ tape( 'the function evaluates Bessel function of the second kind of one order (Y x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 4.5 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 5 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (tiny positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -187,13 +145,7 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 8.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -213,8 +165,6 @@ tape( 'The Bessel function of the second kind of one order (Y_1) (subnormal valu tape( 'the function evaluates the Bessel function of the second kind of one order (Y_1) (huge positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -223,21 +173,13 @@ tape( 'the function evaluates the Bessel function of the second kind of one orde x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 4500.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1200 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of order one (Y_1) for positive x over a wide range of magnitudes', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -246,13 +188,7 @@ tape( 'the function evaluates the Bessel function of the second kind of order on x = positiveGamut.x; for ( i = 0; i < x.length; i++ ) { y = y1( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = 16.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 27 ), true, 'returns expected value' ); } t.end(); });