From 40e1d1c87c03f6199872b42400c465035c9f33c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Aug 2026 10:24:00 +0000 Subject: [PATCH] test: migrate `math/base/special/rempio2` to ULP-based assertions Replaces the computed relative tolerance checks (`delta <= EPS*abs(x)`) in `test/test.js` and `test/test.native.js` with ULP-based assertions using `@stdlib/assert/is-almost-same-value`, mirroring the idiom already used by the float32 counterpart `math/base/special/rempio2f`. The reconstruction checks over the positive, negative, and multiples of pi/4 input ranges assert equality to within 1 ULP. For the tiny positive and tiny negative ranges, reconstruction is exact, and so the assertions use exact equality. Ref: https://github.com/stdlib-js/stdlib/issues/11352 Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_0126JBJYGMzjhQq8VHZUyEaa --- .../math/base/special/rempio2/test/test.js | 33 ++++--------------- .../base/special/rempio2/test/test.native.js | 33 ++++--------------- 2 files changed, 12 insertions(+), 54 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.js b/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.js index 4645d805c09a..e4d595e30878 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.js @@ -27,11 +27,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var incrspace = require( '@stdlib/array/base/incrspace' ); var linspace = require( '@stdlib/array/base/linspace' ); var randu = require( '@stdlib/random/base/randu' ); -var abs = require( '@stdlib/math/base/special/abs' ); var pow = require( '@stdlib/math/base/special/pow' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PIO2 = require( '@stdlib/constants/float64/half-pi' ); var PIO4 = require( '@stdlib/constants/float64/fourth-pi' ); var rempio2 = require( './../lib' ); @@ -70,8 +69,6 @@ tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provide }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -88,16 +85,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -114,16 +107,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'returns expected value' ); + t.strictEqual( z, x, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -140,16 +129,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -166,16 +151,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'returns expected value' ); + t.strictEqual( z, x, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -192,9 +173,7 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x[i] ); - tol = EPS * abs( x[i] ); - t.strictEqual( delta <= tol, true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( z, x[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.native.js index aebecf791c36..0cd39b8ad88e 100644 --- a/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/rempio2/test/test.native.js @@ -28,11 +28,10 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var incrspace = require( '@stdlib/array/base/incrspace' ); var linspace = require( '@stdlib/array/base/linspace' ); var randu = require( '@stdlib/random/base/randu' ); -var abs = require( '@stdlib/math/base/special/abs' ); var pow = require( '@stdlib/math/base/special/pow' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var PIO2 = require( '@stdlib/constants/float64/half-pi' ); var PIO4 = require( '@stdlib/constants/float64/fourth-pi' ); var Float64Array = require( '@stdlib/array/float64' ); @@ -80,8 +79,6 @@ tape( 'the function returns `0` and sets the elements of `y` to `NaN` if provide }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (positive)', opts, function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -98,16 +95,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny positive)', opts, function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -124,16 +117,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + t.strictEqual( z, x, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (negative)', opts, function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -150,16 +139,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + t.strictEqual( isAlmostSameValue( z, x, 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (tiny negative)', opts, function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -176,16 +161,12 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x ); - tol = EPS * abs( x ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + t.strictEqual( z, x, 'returns expected value' ); } t.end(); }); tape( 'the function returns `n` and stores `r` as two double-precision floating point numbers in `y` such that `x - nπ/2 = r` (multiples of π/4)', opts, function test( t ) { - var delta; - var tol; var x; var y; var z; @@ -202,9 +183,7 @@ tape( 'the function returns `n` and stores `r` as two double-precision floating t.strictEqual( isNumber( y[1] ), true, 'returns expected value' ); z = ( PIO2*n ) + ( y[0]+y[1] ); - delta = abs( z - x[i] ); - tol = EPS * abs( x[i] ); - t.strictEqual( delta <= tol, true, 'can recover input value' ); + t.strictEqual( isAlmostSameValue( z, x[ i ], 1 ), true, 'returns expected value' ); } t.end(); });