From 55cee43c244e37c1a9ee89e558ec227aec4cce07 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Aug 2026 22:21:49 +0000 Subject: [PATCH] test: migrate `math/base/special/cphasef` to ULP-based assertions Replaces relative tolerance comparisons in the `cphasef` fixture loops with ULP difference assertions via `@stdlib/number/float32/base/assert/is-almost-same-value`, using the minimum ULP bound which passes over the full fixture set. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude --- 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/cphasef/test/test.js | 21 ++++--------------- .../base/special/cphasef/test/test.native.js | 21 ++++--------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.js b/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.js index 0f3fca660bbe..85e8b605bb99 100644 --- a/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.js @@ -23,9 +23,8 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); -var absf = require( '@stdlib/math/base/special/absf' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); -var EPS = require( '@stdlib/constants/float32/eps' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var PI = require( '@stdlib/constants/float32/pi' ); @@ -162,8 +161,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; @@ -174,9 +171,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = 1.3 * EPS * absf( 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(); }); @@ -184,8 +179,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; @@ -196,9 +189,7 @@ tape( 'the function computes the argument of a complex number (when `re` is nega for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( 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(); }); @@ -206,8 +197,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; @@ -218,9 +207,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( 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(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.native.js index 4a748e809e00..0a096c79279f 100644 --- a/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cphasef/test/test.native.js @@ -24,9 +24,8 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); -var absf = require( '@stdlib/math/base/special/absf' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); -var EPS = require( '@stdlib/constants/float32/eps' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var PI = require( '@stdlib/constants/float32/pi' ); @@ -171,8 +170,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; @@ -183,9 +180,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = 1.3 * EPS * absf( 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(); }); @@ -193,8 +188,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; @@ -205,9 +198,7 @@ tape( 'the function computes the argument of a complex number (when `re` is nega for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( 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(); }); @@ -215,8 +206,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; @@ -227,9 +216,7 @@ tape( 'the function computes the argument of a complex number (when `re` and `im for ( i = 0; i < re.length; i++ ) { actual = cphasef( new Complex64( re[i], im[i] ) ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( 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(); });