From 1ff026516353d1f9cfd1f8bf500774621f11c2ed Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 10 Aug 2026 09:21:07 +0000 Subject: [PATCH 1/2] test: migrate `math/base/special/cceiln` to ULP-based assertions Resolves a part of #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: 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/cceiln/test/test.js | 21 ++++++------------- .../base/special/cceiln/test/test.native.js | 21 ++++++------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js index d29088a9e4b3..8c69eb877ff7 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js @@ -21,14 +21,13 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); @@ -270,13 +269,14 @@ tape( 'if `n > 308` and a component is less than zero, the function returns `-0` tape( 'the function supports rounding very small numbers (including subnormals)', function test( t ) { var expected; - var delta; - var tol; + var ULP; var x; var n; var v; var i; + ULP = 1; + x = 3.1468234343023397 * pow( 10.0, -308 ); n = []; @@ -305,17 +305,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cceiln( new Complex128( x, x ), n[i] ); - if ( real( v ) === expected[i] ) { - t.strictEqual( real( v ), expected[i], 'returns '+expected[i]+' when provided re='+x+', im='+x+', and n='+n[i]+'.' ); - } else { - delta = abs( real( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 're: '+x+'. n: '+n[i]+'. v: '+v[0]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - - delta = abs( imag( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'im: '+x+'. n: '+n[i]+'. v: '+v[1]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( real( v ), expected[i], ULP ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], ULP ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js index e253f0c15503..e16d7d0ed068 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js @@ -22,14 +22,13 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); -var abs = require( '@stdlib/math/base/special/abs' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); @@ -261,13 +260,14 @@ tape( 'if `n > 308` and a component is less than zero, the function returns `-0` tape( 'the function supports rounding very small numbers (including subnormals)', opts, function test( t ) { var expected; - var delta; - var tol; + var ULP; var x; var n; var v; var i; + ULP = 1; + x = 3.1468234343023397 * pow( 10.0, -308 ); n = []; @@ -296,17 +296,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cceiln( new Complex128( x, x ), n[i] ); - if ( real( v ) === expected[i] ) { - t.strictEqual( real( v ), expected[i], 'returns '+expected[i]+' when provided re='+x+', im='+x+', and n='+n[i]+'.' ); - } else { - delta = abs( real( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 're: '+x+'. n: '+n[i]+'. v: '+v[0]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - - delta = abs( imag( v ) - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'im: '+x+'. n: '+n[i]+'. v: '+v[1]+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( real( v ), expected[i], ULP ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], ULP ), true, 'returns expected value' ); } t.end(); }); From cc2836793c87388fa73b16a64771bdc46c2d8c5e Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 10 Aug 2026 05:25:49 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/math/base/special/cceiln/test/test.js | 7 ++----- .../@stdlib/math/base/special/cceiln/test/test.native.js | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js index 8c69eb877ff7..9b8bfb39bef1 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.js @@ -269,14 +269,11 @@ tape( 'if `n > 308` and a component is less than zero, the function returns `-0` tape( 'the function supports rounding very small numbers (including subnormals)', function test( t ) { var expected; - var ULP; var x; var n; var v; var i; - ULP = 1; - x = 3.1468234343023397 * pow( 10.0, -308 ); n = []; @@ -305,8 +302,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cceiln( new Complex128( x, x ), n[i] ); - t.strictEqual( isAlmostSameValue( real( v ), expected[i], ULP ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imag( v ), expected[i], ULP ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( real( v ), expected[i], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js index e16d7d0ed068..37afe7170d9a 100644 --- a/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cceiln/test/test.native.js @@ -260,14 +260,11 @@ tape( 'if `n > 308` and a component is less than zero, the function returns `-0` tape( 'the function supports rounding very small numbers (including subnormals)', opts, function test( t ) { var expected; - var ULP; var x; var n; var v; var i; - ULP = 1; - x = 3.1468234343023397 * pow( 10.0, -308 ); n = []; @@ -296,8 +293,8 @@ tape( 'the function supports rounding very small numbers (including subnormals)' for ( i = 0; i < n.length; i++ ) { v = cceiln( new Complex128( x, x ), n[i] ); - t.strictEqual( isAlmostSameValue( real( v ), expected[i], ULP ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imag( v ), expected[i], ULP ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( real( v ), expected[i], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imag( v ), expected[i], 1 ), true, 'returns expected value' ); } t.end(); });