Skip to content

Commit 4ca068f

Browse files
authored
test: update to test for exact equality
PR-URL: #2864 Ref: #2039 Reviewed-by: Athan Reines <[email protected]>
1 parent 7edbd56 commit 4ca068f

File tree

20 files changed

+482
-1028
lines changed

20 files changed

+482
-1028
lines changed

lib/node_modules/@stdlib/blas/base/dgemv/test/test.dgemv.js

Lines changed: 26 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
var tape = require( 'tape' );
2626
var Float64Array = require( '@stdlib/array/float64' );
27-
var EPS = require( '@stdlib/constants/float64/eps' );
28-
var abs = require( '@stdlib/math/base/special/abs' );
2927
var dgemv = require( './../lib/dgemv.js' );
3028

3129

@@ -46,35 +44,6 @@ var rxnyp = require( './fixtures/row_major_xnyp.json' );
4644
var rxpyp = require( './fixtures/row_major_xpyp.json' );
4745

4846

49-
// FUNCTIONS //
50-
51-
/**
52-
* Tests for element-wise approximate equality.
53-
*
54-
* @private
55-
* @param {Object} t - test object
56-
* @param {Collection} actual - actual values
57-
* @param {Collection} expected - expected values
58-
* @param {number} rtol - relative tolerance
59-
*/
60-
function isApprox( t, actual, expected, rtol ) {
61-
var delta;
62-
var tol;
63-
var i;
64-
65-
t.strictEqual( actual.length, expected.length, 'returns expected value' );
66-
for ( i = 0; i < expected.length; i++ ) {
67-
if ( actual[ i ] === expected[ i ] ) {
68-
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
69-
} else {
70-
delta = abs( actual[ i ] - expected[ i ] );
71-
tol = rtol * EPS * abs( expected[ i ] );
72-
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
73-
}
74-
}
75-
}
76-
77-
7847
// TESTS //
7948

8049
tape( 'main export is a function', function test( t ) {
@@ -253,8 +222,9 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x +
253222
expected = new Float64Array( data.y_out );
254223

255224
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
256-
isApprox( t, y, expected, 2.0 );
257225
t.strictEqual( out, y, 'returns expected value' );
226+
t.deepEqual( out, expected, 'returns expected value' );
227+
258228
t.end();
259229
});
260230

@@ -275,8 +245,9 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x +
275245
expected = new Float64Array( data.y_out );
276246

277247
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
278-
isApprox( t, y, expected, 2.0 );
279248
t.strictEqual( out, y, 'returns expected value' );
249+
t.deepEqual( out, expected, 'returns expected value' );
250+
280251
t.end();
281252
});
282253

@@ -297,8 +268,9 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x +
297268
expected = new Float64Array( data.y_out );
298269

299270
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
300-
isApprox( t, y, expected, 2.0 );
301271
t.strictEqual( out, y, 'returns expected value' );
272+
t.deepEqual( out, expected, 'returns expected value' );
273+
302274
t.end();
303275
});
304276

@@ -319,8 +291,9 @@ tape( 'the function performs one of the matrix-vector operations `y = α*A*x +
319291
expected = new Float64Array( data.y_out );
320292

321293
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
322-
isApprox( t, y, expected, 2.0 );
323294
t.strictEqual( out, y, 'returns expected value' );
295+
t.deepEqual( out, expected, 'returns expected value' );
296+
324297
t.end();
325298
});
326299

@@ -339,6 +312,7 @@ tape( 'the function returns a reference to the second input vector (row-major)',
339312

340313
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
341314
t.strictEqual( out, y, 'returns expected value' );
315+
342316
t.end();
343317
});
344318

@@ -357,6 +331,7 @@ tape( 'the function returns a reference to the second input vector (column-major
357331

358332
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
359333
t.strictEqual( out, y, 'returns expected value' );
334+
360335
t.end();
361336
});
362337

@@ -523,8 +498,9 @@ tape( 'the function supports specifying `x` and `y` strides (row-major)', functi
523498
expected = new Float64Array( data.y_out );
524499

525500
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
526-
isApprox( t, y, expected, 2.0 );
527501
t.strictEqual( out, y, 'returns expected value' );
502+
t.deepEqual( out, expected, 'returns expected value' );
503+
528504
t.end();
529505
});
530506

@@ -545,8 +521,9 @@ tape( 'the function supports specifying `x` and `y` strides (column-major)', fun
545521
expected = new Float64Array( data.y_out );
546522

547523
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
548-
isApprox( t, y, expected, 2.0 );
549524
t.strictEqual( out, y, 'returns expected value' );
525+
t.deepEqual( out, expected, 'returns expected value' );
526+
550527
t.end();
551528
});
552529

@@ -567,8 +544,9 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func
567544
expected = new Float64Array( data.y_out );
568545

569546
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
570-
isApprox( t, y, expected, 2.0 );
571547
t.strictEqual( out, y, 'returns expected value' );
548+
t.deepEqual( out, expected, 'returns expected value' );
549+
572550
t.end();
573551
});
574552

@@ -589,8 +567,9 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f
589567
expected = new Float64Array( data.y_out );
590568

591569
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
592-
isApprox( t, y, expected, 2.0 );
593570
t.strictEqual( out, y, 'returns expected value' );
571+
t.deepEqual( out, expected, 'returns expected value' );
572+
594573
t.end();
595574
});
596575

@@ -611,8 +590,9 @@ tape( 'the function supports specifying a negative `y` stride (row-major)', func
611590
expected = new Float64Array( data.y_out );
612591

613592
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
614-
isApprox( t, y, expected, 2.0 );
615593
t.strictEqual( out, y, 'returns expected value' );
594+
t.deepEqual( out, expected, 'returns expected value' );
595+
616596
t.end();
617597
});
618598

@@ -633,8 +613,9 @@ tape( 'the function supports specifying a negative `y` stride (column-major)', f
633613
expected = new Float64Array( data.y_out );
634614

635615
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
636-
isApprox( t, y, expected, 2.0 );
637616
t.strictEqual( out, y, 'returns expected value' );
617+
t.deepEqual( out, expected, 'returns expected value' );
618+
638619
t.end();
639620
});
640621

@@ -655,8 +636,9 @@ tape( 'the function supports complex access patterns (row-major)', function test
655636
expected = new Float64Array( data.y_out );
656637

657638
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
658-
isApprox( t, y, expected, 2.0 );
659639
t.strictEqual( out, y, 'returns expected value' );
640+
t.deepEqual( out, expected, 'returns expected value' );
641+
660642
t.end();
661643
});
662644

@@ -677,7 +659,8 @@ tape( 'the function supports complex access patterns (column-major)', function t
677659
expected = new Float64Array( data.y_out );
678660

679661
out = dgemv( data.order, data.trans, data.M, data.N, data.alpha, a, data.lda, x, data.strideX, data.beta, y, data.strideY );
680-
isApprox( t, y, expected, 2.0 );
681662
t.strictEqual( out, y, 'returns expected value' );
663+
t.deepEqual( out, expected, 'returns expected value' );
664+
682665
t.end();
683666
});

0 commit comments

Comments
 (0)