From b2b7f62177558c251cb80f2110242c5cf14e52f7 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 10 Jun 2026 02:23:12 -0500 Subject: [PATCH] test: migrate `math/base/special/logit` to ULP-based testing --- 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/logit/test/test.js | 33 +++---------------- .../base/special/logit/test/test.native.js | 33 +++---------------- 2 files changed, 8 insertions(+), 58 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/logit/test/test.js b/lib/node_modules/@stdlib/math/base/special/logit/test/test.js index 24a6974fb823..5472ce779c2a 100644 --- a/lib/node_modules/@stdlib/math/base/special/logit/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/logit/test/test.js @@ -24,8 +24,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var logit = require( './../lib' ); @@ -72,8 +71,6 @@ tape( 'the function returns `+Infinity` when provided `1`', function test( t ) { tape( 'the function evaluates the logit of `x` for the interval `(0,0.25]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -82,21 +79,13 @@ tape( 'the function evaluates the logit of `x` for the interval `(0,0.25]`', fun x = small.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the logit of `x` for the interval `[0.25,0.75]`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -105,21 +94,13 @@ tape( 'the function evaluates the logit of `x` for the interval `[0.25,0.75]`', x = medium.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the logit of `x` for the interval `[0.75,1)`', function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -128,13 +109,7 @@ tape( 'the function evaluates the logit of `x` for the interval `[0.75,1)`', fun x = large.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/logit/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/logit/test/test.native.js index 6b038dfca35b..d387547b339e 100644 --- a/lib/node_modules/@stdlib/math/base/special/logit/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/logit/test/test.native.js @@ -25,8 +25,7 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var PINF = require( '@stdlib/constants/float64/pinf' ); var NINF = require( '@stdlib/constants/float64/ninf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -81,8 +80,6 @@ tape( 'the function returns `+Infinity` when provided `1`', opts, function test( tape( 'the function evaluates the logit of `x` for the interval `(0,0.25]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -91,21 +88,13 @@ tape( 'the function evaluates the logit of `x` for the interval `(0,0.25]`', opt x = small.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the logit of `x` for the interval `[0.25,0.75]`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -114,21 +103,13 @@ tape( 'the function evaluates the logit of `x` for the interval `[0.25,0.75]`', x = medium.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function evaluates the logit of `x` for the interval `[0.75,1)`', opts, function test( t ) { var expected; - var delta; - var tol; var x; var y; var i; @@ -137,13 +118,7 @@ tape( 'the function evaluates the logit of `x` for the interval `[0.75,1)`', opt x = large.x; for ( i = 0; i < x.length; i++ ) { y = logit( x[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); - } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. v: '+y+'. E: '+expected[i]+' Δ: '+delta+'. tol: '+tol ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); });