From 767fad1e8f2665feff4847cfcf003716325bf138 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 09:26:29 +0000 Subject: [PATCH] test: migrate `math/base/special/bessely0` to ULP-based assertions Ref: https://github.com/stdlib-js/stdlib/issues/11352 --- 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: passed - 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/bessely0/test/test.js | 92 ++---------------- .../base/special/bessely0/test/test.native.js | 96 ++----------------- 2 files changed, 20 insertions(+), 168 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js b/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js index c96d7a646cd1..15dcb2a27fb9 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/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 y0 = 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 zero order (Y_0) (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 zero ord x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 680.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 ], 1127 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (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 zero ord x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 2400.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 ], 3716 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (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 zero ord x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 850.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 ], 1626 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (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 zero ord x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 1000.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 ], 1510 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates Bessel function of the second kind of zero order (Y_0) (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 zero order ( x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 ], 7 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (tiny positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -178,21 +136,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 10.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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (subnormal positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -201,21 +151,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = subnormal.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 5000.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 ], 8678 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (huge positive values)', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -224,21 +166,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 ], 4053 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of order zero (Y_0) for positive x over a wide range of magnitudes', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -247,13 +181,7 @@ tape( 'the function evaluates the Bessel function of the second kind of order ze x = positiveGamut.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 ], 25 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.native.js index e42f9c03b6a3..1f1a4a038321 100644 --- a/lib/node_modules/@stdlib/math/base/special/bessely0/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/bessely0/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 zero order (Y_0) (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 zero ord x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 680.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 ], 1127 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (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 zero ord x = largePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 2400.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 ], 3716 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (medium positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -118,23 +100,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2774#discussion_r1712904184 - tol = 885.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 ], 1626 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (small positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -143,21 +115,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 1000.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 ], 1510 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates Bessel function of the second kind of zero order (Y_0) (smaller positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -166,21 +130,13 @@ tape( 'the function evaluates Bessel function of the second kind of zero order ( x = smaller.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 ], 7 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (tiny positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -189,21 +145,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 10.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 ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (subnormal positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -212,21 +160,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = subnormal.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 = 5000.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 ], 8678 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of zero order (Y_0) (huge positive values)', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -235,21 +175,13 @@ tape( 'the function evaluates the Bessel function of the second kind of zero ord x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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 ], 4053 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the Bessel function of the second kind of order zero (Y_0) 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; @@ -258,15 +190,7 @@ tape( 'the function evaluates the Bessel function of the second kind of order ze x = positiveGamut.x; for ( i = 0; i < x.length; i++ ) { y = y0( 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] ); - - // NOTE: the tolerance here is larger than for the JavaScript implementation due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2774#discussion_r1712904184 - tol = 130.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 ], 25 ), true, 'returns expected value' ); } t.end(); });