From 969943848bf69804f24768932a38188f19d85e3f Mon Sep 17 00:00:00 2001 From: Arjan Date: Tue, 18 Aug 2026 16:39:43 +0530 Subject: [PATCH 1/2] test: migrate `math/base/special/cinvf` to ULP-based assertion --- 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/cinvf/test/test.js | 165 ++---------------- .../base/special/cinvf/test/test.native.js | 165 ++---------------- 2 files changed, 38 insertions(+), 292 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js index c6bf34fde3cc..38110790674e 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js @@ -24,14 +24,13 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var absf = require( '@stdlib/math/base/special/absf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var cinvf = require( './../lib' ); @@ -66,10 +65,8 @@ tape( 'the function computes the inverse of a single-precision complex floating- }); tape( 'the function computes a complex inverse', function test( t ) { - var delta; var qre; var qim; - var tol; var re; var im; var i; @@ -83,27 +80,13 @@ tape( 'the function computes a complex inverse', function test( t ) { for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.4 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.4 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large negative imaginary components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -119,27 +102,13 @@ tape( 'the function computes a complex inverse (large negative imaginary compone for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large negative real components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -155,27 +124,13 @@ tape( 'the function computes a complex inverse (large negative real components)' for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large positive imaginary components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -191,27 +146,13 @@ tape( 'the function computes a complex inverse (large positive imaginary compone for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large positive real components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -227,27 +168,13 @@ tape( 'the function computes a complex inverse (large positive real components)' for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny negative imaginary components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -263,27 +190,13 @@ tape( 'the function computes a complex inverse (tiny negative imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.5 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny negative real components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -299,27 +212,13 @@ tape( 'the function computes a complex inverse (tiny negative real components)', for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.5 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny positive imaginary components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -335,27 +234,13 @@ tape( 'the function computes a complex inverse (tiny positive imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.3 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny positive real components)', function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -371,20 +256,8 @@ tape( 'the function computes a complex inverse (tiny positive real components)', for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.6 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js index b5ea7318475e..0954f390f92a 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js @@ -25,14 +25,13 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var absf = require( '@stdlib/math/base/special/absf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); var PINF = require( '@stdlib/constants/float32/pinf' ); var NINF = require( '@stdlib/constants/float32/ninf' ); var Complex64 = require( '@stdlib/complex/float32/ctor' ); var realf = require( '@stdlib/complex/float32/real' ); var imagf = require( '@stdlib/complex/float32/imag' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -75,10 +74,8 @@ tape( 'the function computes the inverse of a single-precision complex floating- }); tape( 'the function computes a complex inverse', opts, function test( t ) { - var delta; var qre; var qim; - var tol; var re; var im; var i; @@ -92,27 +89,13 @@ tape( 'the function computes a complex inverse', opts, function test( t ) { for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.4 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.4 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large negative imaginary components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -128,27 +111,13 @@ tape( 'the function computes a complex inverse (large negative imaginary compone for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large negative real components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -164,27 +133,13 @@ tape( 'the function computes a complex inverse (large negative real components)' for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large positive imaginary components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -200,27 +155,13 @@ tape( 'the function computes a complex inverse (large positive imaginary compone for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (large positive real components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -236,27 +177,13 @@ tape( 'the function computes a complex inverse (large positive real components)' for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny negative imaginary components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -272,27 +199,13 @@ tape( 'the function computes a complex inverse (tiny negative imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.5 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny negative real components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -308,27 +221,13 @@ tape( 'the function computes a complex inverse (tiny negative real components)', for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.5 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny positive imaginary components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -344,27 +243,13 @@ tape( 'the function computes a complex inverse (tiny positive imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = 1.3 * EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function computes a complex inverse (tiny positive real components)', opts, function test( t ) { - var delta; - var tol; var qre; var qim; var re; @@ -380,20 +265,8 @@ tape( 'the function computes a complex inverse (tiny positive real components)', for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - if ( realf( q ) === qre[ i ] ) { - t.strictEqual( realf( q ), qre[ i ], 'returns expected real component' ); - } else { - delta = absf( realf( q ) - qre[ i ] ); - tol = 1.6 * EPS * absf( qre[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. real: '+realf( q )+'. expected: '+qre[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - if ( imagf( q ) === qim[ i ] ) { - t.strictEqual( imagf( q ), qim[ i ], 'returns expected imaginary component' ); - } else { - delta = absf( imagf( q ) - qim[ i ] ); - tol = EPS * absf( qim[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+re[i]+'+ '+im[i]+'i. imag: '+imagf( q )+'. expected: '+qim[i]+'. delta: '+delta+'. tol: '+tol+'.' ); - } + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); From 07ec31891f3ea4a160acdbc2c4b62021ec671fbd Mon Sep 17 00:00:00 2001 From: Arjan Date: Tue, 18 Aug 2026 17:01:41 +0530 Subject: [PATCH 2/2] fix: update tolerances --- 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 --- --- .../@stdlib/math/base/special/cinvf/test/test.js | 8 ++++---- .../@stdlib/math/base/special/cinvf/test/test.native.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js index 38110790674e..cc8affe69798 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.js @@ -190,7 +190,7 @@ tape( 'the function computes a complex inverse (tiny negative imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); @@ -212,7 +212,7 @@ tape( 'the function computes a complex inverse (tiny negative real components)', for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); @@ -234,7 +234,7 @@ tape( 'the function computes a complex inverse (tiny positive imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); @@ -257,7 +257,7 @@ tape( 'the function computes a complex inverse (tiny positive real components)', q = cinvf( new Complex64( re[ i ], im[ i ] ) ); t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js index 0954f390f92a..142e629c7950 100644 --- a/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/cinvf/test/test.native.js @@ -199,7 +199,7 @@ tape( 'the function computes a complex inverse (tiny negative imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); @@ -243,7 +243,7 @@ tape( 'the function computes a complex inverse (tiny positive imaginary componen for ( i = 0; i < re.length; i++ ) { q = cinvf( new Complex64( re[ i ], im[ i ] ) ); - t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 1 ), true, 'returns expected value' ); t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); } t.end(); @@ -266,7 +266,7 @@ tape( 'the function computes a complex inverse (tiny positive real components)', q = cinvf( new Complex64( re[ i ], im[ i ] ) ); t.strictEqual( isAlmostSameValue( realf( q ), qre[ i ], 2 ), true, 'returns expected value' ); - t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( isAlmostSameValue( imagf( q ), qim[ i ], 1 ), true, 'returns expected value' ); } t.end(); });