From 8183e7904b0c93c9b71a88896bb8e422403ad54a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 11 Aug 2026 21:28:18 +0000 Subject: [PATCH] test: migrate `math/base/special/atan2f` to ULP-based assertions Replaces relative-tolerance comparisons in the fixture-driven test cases with `isAlmostSameValue` checks expressed in ULPs, mirroring the approach used for `math/base/special/atan2d`. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01GxDGtL3RkuPzo2Wp3V97rB --- 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/atan2f/test/test.js | 21 ++++--------------- .../base/special/atan2f/test/test.native.js | 21 ++++--------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js index 210e309cd06b..44240997c678 100644 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.js @@ -24,9 +24,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 isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-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' ); @@ -188,8 +187,6 @@ tape( 'the function returns `-PI/2` if provided a negative `y` and `x=-0`', func tape( 'the function evaluates the `atan2f` function (when x and y are positive)', function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -200,9 +197,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)' for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[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. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); @@ -210,8 +205,6 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)' tape( 'the function evaluates the `atan2f` function (when x is negative and y is positive)', function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -222,9 +215,7 @@ tape( 'the function evaluates the `atan2f` function (when x is negative and y is for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[i] ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -232,8 +223,6 @@ tape( 'the function evaluates the `atan2f` function (when x is negative and y is tape( 'the function evaluates the `atan2f` function (when x and y are negative)', function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -244,9 +233,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are negative)' for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[i] ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js index 794cfb43cfde..6824aec73f7a 100755 --- a/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/atan2f/test/test.native.js @@ -25,9 +25,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 isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-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' ); @@ -197,8 +196,6 @@ tape( 'the function returns `-PI/2` if provided a negative `y` and `x=-0`', opts tape( 'the function evaluates the `atan2f` function (when x and y are positive)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -209,9 +206,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)' for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[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. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); @@ -219,8 +214,6 @@ tape( 'the function evaluates the `atan2f` function (when x and y are positive)' tape( 'the function evaluates the `atan2f` function (when x is negative and y is positive)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -231,9 +224,7 @@ tape( 'the function evaluates the `atan2f` function (when x is negative and y is for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[i] ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); @@ -241,8 +232,6 @@ tape( 'the function evaluates the `atan2f` function (when x is negative and y is tape( 'the function evaluates the `atan2f` function (when x and y are negative)', opts, function test( t ) { var expected; var actual; - var delta; - var tol; var x; var y; var i; @@ -253,9 +242,7 @@ tape( 'the function evaluates the `atan2f` function (when x and y are negative)' for ( i = 0; i < x.length; i++ ) { actual = atan2f( y[i], x[i] ); expected[ i ] = f32( expected[ i ] ); - delta = absf( actual - expected[i] ); - tol = EPS * absf( expected[i] ); - t.strictEqual( delta <= tol, true, 'within tolerance. y: '+y[i]+'. x: '+x[i]+'. Actual: '+actual+'. E: '+expected[i]+'. tol: '+tol+'. Δ: '+delta+'.' ); + t.strictEqual( isAlmostSameValue( actual, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });