Skip to content

Commit 7d6c7bf

Browse files
committed
test: remove general use of absolute tolerance
--- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: failed ---
1 parent 5672a23 commit 7d6c7bf

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

lib/node_modules/@stdlib/lapack/base/zrot/test/test.ndarray.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ var zrot = require( './../lib/ndarray.js' );
3939
* @param {Collection} actual - actual values
4040
* @param {Collection} expected - expected values
4141
* @param {number} rtol - relative tolerance
42-
* @param {number} atol - absolute tolerance
4342
*/
44-
function isApprox( t, actual, expected, rtol, atol ) {
45-
var absTol;
46-
var relTol;
43+
function isApprox( t, actual, expected, rtol ) {
4744
var delta;
45+
var tol;
4846
var i;
4947

5048
t.strictEqual( actual.length, expected.length, 'returns expected value' );
@@ -53,9 +51,11 @@ function isApprox( t, actual, expected, rtol, atol ) {
5351
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
5452
} else {
5553
delta = abs( actual[ i ] - expected[ i ] );
56-
relTol = rtol * EPS * abs( expected[ i ] );
57-
absTol = atol * EPS;
58-
t.ok( delta <= relTol || delta < absTol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. relative tol: '+relTol+'. absolute tol: '+absTol+'.' );
54+
tol = rtol * EPS * abs( expected[ i ] );
55+
if ( tol === 0.0 ) {
56+
tol = EPS; // absolute tolerance when `expected[i]` is `0`
57+
}
58+
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
5959
}
6060
}
6161
}
@@ -132,8 +132,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
132132
]);
133133

134134
out = zrot( cx.length, cx, 1, 0, cy, 1, 0, 0.8, s );
135-
isApprox( t, viewX, cxe, 2.0, 0.0 );
136-
isApprox( t, viewY, cye, 2.0, 0.0 );
135+
isApprox( t, viewX, cxe, 2.0 );
136+
isApprox( t, viewY, cye, 2.0 );
137137
t.strictEqual( out, cy, 'returns expected value' );
138138
t.end();
139139
});
@@ -195,8 +195,8 @@ tape( 'the function supports an `x` stride', function test( t ) {
195195
]);
196196

197197
out = zrot( 2, cx, 2, 0, cy, 1, 0, 0.8, s );
198-
isApprox( t, viewX, cxe, 2.0, 0.0 );
199-
isApprox( t, viewY, cye, 2.0, 0.0 );
198+
isApprox( t, viewX, cxe, 2.0 );
199+
isApprox( t, viewY, cye, 2.0 );
200200
t.strictEqual( out, cy, 'returns expected value' );
201201
t.end();
202202
});
@@ -258,8 +258,8 @@ tape( 'the function supports an `x` offset', function test( t ) {
258258
]);
259259

260260
out = zrot( 3, cx, 1, 1, cy, 1, 0, 0.8, s );
261-
isApprox( t, viewX, cxe, 2.0, 0.0 );
262-
isApprox( t, viewY, cye, 2.0, 2.0 );
261+
isApprox( t, viewX, cxe, 2.0 );
262+
isApprox( t, viewY, cye, 4.0 );
263263
t.strictEqual( out, cy, 'returns expected value' );
264264
t.end();
265265
});
@@ -321,8 +321,8 @@ tape( 'the function supports a `y` stride', function test( t ) {
321321
]);
322322

323323
out = zrot( 2, cx, 1, 0, cy, 2, 0, 0.8, s );
324-
isApprox( t, viewX, cxe, 2.0, 0.0 );
325-
isApprox( t, viewY, cye, 2.0, 2.0 );
324+
isApprox( t, viewX, cxe, 2.0 );
325+
isApprox( t, viewY, cye, 2.0 );
326326
t.strictEqual( out, cy, 'returns expected value' );
327327
t.end();
328328
});
@@ -384,8 +384,8 @@ tape( 'the function supports a `y` offset', function test( t ) {
384384
]);
385385

386386
out = zrot( 2, cx, 2, 0, cy, -1, 1, 0.8, s );
387-
isApprox( t, viewX, cxe, 2.0, 0.0 );
388-
isApprox( t, viewY, cye, 4.0, 0.0 );
387+
isApprox( t, viewX, cxe, 2.0 );
388+
isApprox( t, viewY, cye, 4.0 );
389389
t.strictEqual( out, cy, 'returns expected value' );
390390
t.end();
391391
});
@@ -493,8 +493,8 @@ tape( 'the function supports negative strides', function test( t ) {
493493
]);
494494

495495
out = zrot( 2, cx, -1, 1, cy, -2, 2, 0.8, s );
496-
isApprox( t, viewX, cxe, 2.0, 0.0 );
497-
isApprox( t, viewY, cye, 2.0, 2.0 );
496+
isApprox( t, viewX, cxe, 2.0 );
497+
isApprox( t, viewY, cye, 2.0 );
498498
t.strictEqual( out, cy, 'returns expected value' );
499499
t.end();
500500
});
@@ -556,8 +556,8 @@ tape( 'the function supports complex access patterns', function test( t ) {
556556
]);
557557

558558
out = zrot( 2, cx, 2, 1, cy, 1, 2, 0.8, s );
559-
isApprox( t, viewX, cxe, 2.0, 0.0 );
560-
isApprox( t, viewY, cye, 2.0, 2.0 );
559+
isApprox( t, viewX, cxe, 2.0 );
560+
isApprox( t, viewY, cye, 4.0 );
561561
t.strictEqual( out, cy, 'returns expected value' );
562562
t.end();
563563
});

lib/node_modules/@stdlib/lapack/base/zrot/test/test.zrot.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ var zrot = require( './../lib/zrot.js' );
3939
* @param {Collection} actual - actual values
4040
* @param {Collection} expected - expected values
4141
* @param {number} rtol - relative tolerance
42-
* @param {number} atol - absolute tolerance
4342
*/
44-
function isApprox( t, actual, expected, rtol, atol ) {
45-
var absTol;
46-
var relTol;
43+
function isApprox( t, actual, expected, rtol ) {
4744
var delta;
45+
var tol;
4846
var i;
4947

5048
t.strictEqual( actual.length, expected.length, 'returns expected value' );
@@ -53,9 +51,11 @@ function isApprox( t, actual, expected, rtol, atol ) {
5351
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
5452
} else {
5553
delta = abs( actual[ i ] - expected[ i ] );
56-
relTol = rtol * EPS * abs( expected[ i ] );
57-
absTol = atol * EPS;
58-
t.ok( delta <= relTol || delta < absTol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. relative tol: '+relTol+'. absolute tol: '+absTol+'.' );
54+
tol = rtol * EPS * abs( expected[ i ] );
55+
if ( tol === 0.0 ) {
56+
tol = EPS; // absolute tolerance when `expected[i]` is `0`
57+
}
58+
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
5959
}
6060
}
6161
}
@@ -133,8 +133,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
133133
]);
134134

135135
out = zrot( cx.length, cx, 1, cy, 1, 0.8, s );
136-
isApprox( t, viewX, cxe, 2.0, 0.0 );
137-
isApprox( t, viewY, cye, 2.0, 0.0 );
136+
isApprox( t, viewX, cxe, 2.0 );
137+
isApprox( t, viewY, cye, 2.0 );
138138
t.strictEqual( out, cy, 'returns expected value' );
139139
t.end();
140140
});
@@ -198,8 +198,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
198198
]);
199199

200200
out = zrot( cx.length, cx, 1, cy, 1, 1.25, s );
201-
isApprox( t, viewX, cxe, 2.0, 0.0 );
202-
isApprox( t, viewY, cye, 2.0, 0.0 );
201+
isApprox( t, viewX, cxe, 2.0 );
202+
isApprox( t, viewY, cye, 2.0 );
203203
t.strictEqual( out, cy, 'returns expected value' );
204204
t.end();
205205
});
@@ -263,8 +263,8 @@ tape( 'the function applies a plane rotation', function test( t ) {
263263
]);
264264

265265
out = zrot( cx.length, cx, 1, cy, 1, 1.25, s );
266-
isApprox( t, viewX, cxe, 2.0, 0.0 );
267-
isApprox( t, viewY, cye, 4.0, 2.0 );
266+
isApprox( t, viewX, cxe, 2.0 );
267+
isApprox( t, viewY, cye, 4.0 );
268268
t.strictEqual( out, cy, 'returns expected value' );
269269
t.end();
270270
});
@@ -326,8 +326,8 @@ tape( 'the function supports an `x` stride', function test( t ) {
326326
]);
327327

328328
out = zrot( 2, cx, 2, cy, 1, 0.8, s );
329-
isApprox( t, viewX, cxe, 2.0, 0.0 );
330-
isApprox( t, viewY, cye, 4.0, 0.0 );
329+
isApprox( t, viewX, cxe, 2.0 );
330+
isApprox( t, viewY, cye, 4.0 );
331331
t.strictEqual( out, cy, 'returns expected value' );
332332
t.end();
333333
});
@@ -389,8 +389,8 @@ tape( 'the function supports a `y` stride', function test( t ) {
389389
]);
390390

391391
out = zrot( 2, cx, 1, cy, 2, 0.8, s );
392-
isApprox( t, viewX, cxe, 2.0, 0.0 );
393-
isApprox( t, viewY, cye, 2.0, 2.0 );
392+
isApprox( t, viewX, cxe, 2.0 );
393+
isApprox( t, viewY, cye, 2.0 );
394394
t.strictEqual( out, cy, 'returns expected value' );
395395
t.end();
396396
});
@@ -498,8 +498,8 @@ tape( 'the function supports negative strides', function test( t ) {
498498
]);
499499

500500
out = zrot( 2, cx, -1, cy, -2, 0.8, s );
501-
isApprox( t, viewX, cxe, 2.0, 0.0 );
502-
isApprox( t, viewY, cye, 2.0, 2.0 );
501+
isApprox( t, viewX, cxe, 2.0 );
502+
isApprox( t, viewY, cye, 2.0 );
503503
t.strictEqual( out, cy, 'returns expected value' );
504504
t.end();
505505
});
@@ -561,8 +561,8 @@ tape( 'the function supports complex access patterns', function test( t ) {
561561
]);
562562

563563
out = zrot( 2, cx, 2, cy, -1, 0.8, s );
564-
isApprox( t, viewX, cxe, 2.0, 0.0 );
565-
isApprox( t, viewY, cye, 4.0, 0.0 );
564+
isApprox( t, viewX, cxe, 2.0 );
565+
isApprox( t, viewY, cye, 4.0 );
566566
t.strictEqual( out, cy, 'returns expected value' );
567567
t.end();
568568
});
@@ -632,8 +632,8 @@ tape( 'the function supports view offsets', function test( t ) {
632632
]);
633633

634634
out = zrot( 2, cx1, -2, cy1, 1, 0.8, s );
635-
isApprox( t, viewX, cxe, 2.0, 0.0 );
636-
isApprox( t, viewY, cye, 2.0, 2.0 );
635+
isApprox( t, viewX, cxe, 2.0 );
636+
isApprox( t, viewY, cye, 4.0 );
637637
t.strictEqual( out, cy1, 'returns expected value' );
638638
t.end();
639639
});

0 commit comments

Comments
 (0)