From 58173fc3a9e16dcf137bd62e790ab6d4f27e96dc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Aug 2026 09:17:25 +0000 Subject: [PATCH] test: migrate `math/base/special/cphase` to ULP-based assertions Replaces the computed EPS-tolerance idiom (delta/tol) in the fixture-loop assertions with `@stdlib/assert/is-almost-same-value`, using the minimum ULP bound that passes across the full fixture set for each test group. 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: 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/cphase/test/test.js | 21 ++++--------------- .../base/special/cphase/test/test.native.js | 21 ++++--------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cphase/test/test.js b/lib/node_modules/@stdlib/math/base/special/cphase/test/test.js index 6750759bbfcb..085708e272ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/cphase/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cphase/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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); @@ -161,8 +160,6 @@ tape( 'the function returns `-PI/2` if provided a negative `im` and `re=0`', fun tape( 'the function computes the argument of a complex number (when `re` and `im` are positive)', function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -172,9 +169,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im expected = positivePositive.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -182,8 +177,6 @@ tape( 'the function computes the argument of a complex number (when `re` and `im tape( 'the function computes the argument of a complex number (when `re` is negative and `im` is positive)', function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -193,9 +186,7 @@ tape( 'the function computes the argument of a complex number (when `re` is nega expected = negativePositive.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = 2.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); @@ -203,8 +194,6 @@ tape( 'the function computes the argument of a complex number (when `re` is nega tape( 'the function computes the argument of a complex number (when `re` and `im` are negative)', function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -214,9 +203,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im expected = negativeNegative.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = 2.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cphase/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cphase/test/test.native.js index f24dfc8325c0..f4a53dc71a93 100644 --- a/lib/node_modules/@stdlib/math/base/special/cphase/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cphase/test/test.native.js @@ -22,10 +22,9 @@ 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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); var PI = require( '@stdlib/constants/float64/pi' ); @@ -170,8 +169,6 @@ tape( 'the function returns `-PI/2` if provided a negative `im` and `re=0`', opt tape( 'the function computes the argument of a complex number (when `re` and `im` are positive)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -181,9 +178,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im expected = positivePositive.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -191,8 +186,6 @@ tape( 'the function computes the argument of a complex number (when `re` and `im tape( 'the function computes the argument of a complex number (when `re` is negative and `im` is positive)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -202,9 +195,7 @@ tape( 'the function computes the argument of a complex number (when `re` is nega expected = negativePositive.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = 2.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); @@ -212,8 +203,6 @@ tape( 'the function computes the argument of a complex number (when `re` is nega tape( 'the function computes the argument of a complex number (when `re` and `im` are negative)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var re; var im; var i; @@ -223,9 +212,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im expected = negativeNegative.expected; for ( i = 0; i < re.length; i++ ) { actual = cphase( new Complex128( re[i], im[i] ) ); - delta = abs( actual - expected[i] ); - tol = 2.0 * EPS * abs( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. re: '+re[i]+'. im: '+im[i]+'. Actual: '+actual+'. Expected: '+expected[i]+'. tol: '+tol+'. delta: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); });