Skip to content

Commit 399caca

Browse files
committed
chore: fix test cases
--- 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 ---
1 parent d583a96 commit 399caca

File tree

4 files changed

+64
-80
lines changed

4 files changed

+64
-80
lines changed

lib/node_modules/@stdlib/blas/base/wasm/scnrm2/test/test.main.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,24 @@ var scnrm2 = require( './../lib' );
3030
// FUNCTIONS //
3131

3232
/**
33-
* Tests for element-wise approximate equality.
33+
* Tests for element approximate equality.
3434
*
3535
* @private
3636
* @param {Object} t - test object
37-
* @param {Collection} actual - actual values
38-
* @param {Collection} expected - expected values
37+
* @param {number} actual - actual value
38+
* @param {number} expected - expected value
3939
* @param {number} rtol - relative tolerance
4040
*/
4141
function isApprox( t, actual, expected, rtol ) {
4242
var delta;
4343
var tol;
44-
var i;
45-
46-
t.strictEqual( actual.length, expected.length, 'returns expected value' );
47-
for ( i = 0; i < expected.length; i++ ) {
48-
if ( actual[ i ] === expected[ i ] ) {
49-
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
50-
} else {
51-
delta = abs( actual[ i ] - expected[ i ] );
52-
tol = rtol * EPS * abs( expected[ i ] );
53-
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
54-
}
44+
45+
if ( actual === expected ) {
46+
t.strictEqual( actual, expected, 'returns expected value' );
47+
} else {
48+
delta = abs( actual - expected );
49+
tol = rtol * EPS * abs( expected );
50+
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
5551
}
5652
}
5753

@@ -73,15 +69,15 @@ tape( 'the `main` method calculates the L2-norm of a vector', function test( t )
7369
var nrm2;
7470
var x;
7571

76-
x = new Complex64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] );
72+
x = new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] );
7773

7874
nrm2 = scnrm2.main( x.length, x, 1 );
79-
isApprox( t, nrm2, 7.4, 1.0 );
75+
isApprox( t, nrm2, 11.575836902790, 1.0 );
8076

8177
x = new Complex64Array( [ -4.0, 0.0 ] );
8278

8379
nrm2 = scnrm2.main( x.length, x, 1 );
84-
isApprox( t, nrm2, 4.0, 1.0 );
80+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
8581

8682
t.end();
8783
});
@@ -104,7 +100,7 @@ tape( 'the `main` method supports a `stride` parameter', function test( t ) {
104100
]);
105101

106102
nrm2 = scnrm2.main( 3, x, 2 );
107-
isApprox( t, nrm2, 8.83, 1.0 );
103+
isApprox( t, nrm2, 8.831760866327, 1.0 );
108104

109105
t.end();
110106
});
@@ -123,7 +119,7 @@ tape( 'the `main` method supports a negative `stride` parameter', function test(
123119
]);
124120

125121
nrm2 = scnrm2.main( 2, x, -2 );
126-
isApprox( t, nrm2, 8.54, 1.0 );
122+
isApprox( t, nrm2, 8.544003745317, 1.0 );
127123

128124
t.end();
129125
});
@@ -163,8 +159,8 @@ tape( 'the `main` method supports view offsets', function test( t ) {
163159

164160
x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
165161

166-
nrm2 = scnrm2.main( 4, x1, 2 );
167-
isApprox( t, nrm2, 4.24, 1.0 );
162+
nrm2 = scnrm2.main( 2, x1, 2 );
163+
isApprox( t, nrm2, 4.24264068711, 1.0 );
168164

169165
t.end();
170166
});

lib/node_modules/@stdlib/blas/base/wasm/scnrm2/test/test.module.main.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@ var Module = require( './../lib' ).Module;
3333
// FUNCTIONS //
3434

3535
/**
36-
* Tests for element-wise approximate equality.
36+
* Tests for element approximate equality.
3737
*
3838
* @private
3939
* @param {Object} t - test object
40-
* @param {Collection} actual - actual values
41-
* @param {Collection} expected - expected values
40+
* @param {number} actual - actual value
41+
* @param {number} expected - expected value
4242
* @param {number} rtol - relative tolerance
4343
*/
4444
function isApprox( t, actual, expected, rtol ) {
4545
var delta;
4646
var tol;
47-
var i;
48-
49-
t.strictEqual( actual.length, expected.length, 'returns expected value' );
50-
for ( i = 0; i < expected.length; i++ ) {
51-
if ( actual[ i ] === expected[ i ] ) {
52-
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
53-
} else {
54-
delta = abs( actual[ i ] - expected[ i ] );
55-
tol = rtol * EPS * abs( expected[ i ] );
56-
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
57-
}
47+
48+
if ( actual === expected ) {
49+
t.strictEqual( actual, expected, 'returns expected value' );
50+
} else {
51+
delta = abs( actual - expected );
52+
tol = rtol * EPS * abs( expected );
53+
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
5854
}
5955
}
6056

@@ -93,18 +89,18 @@ tape( 'a module instance has a `main` method which calculates the L2-norm of a v
9389

9490
xp = 0;
9591

96-
mod.write( xp, new Complex64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) );
92+
mod.write( xp, new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );
9793

9894
nrm2 = mod.main( 3, xp, 1 );
99-
isApprox( t, nrm2, 7.4, 1.0 );
95+
isApprox( t, nrm2, 11.575836902790, 1.0 );
10096

10197
// Short datasets:
10298
xp = 0;
10399

104100
mod.write( xp, new Complex64Array( [ -4.0, 0.0 ] ) );
105101

106102
nrm2 = mod.main( 1, xp, 1 );
107-
isApprox( t, nrm2, 4.0, 1.0 );
103+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
108104

109105
t.end();
110106
});
@@ -137,7 +133,7 @@ tape( 'a module instance has a `main` method which supports a `stride` parameter
137133
]));
138134

139135
nrm2 = mod.main( 3, xp, 2 );
140-
isApprox( t, nrm2, 8.83, 1.0 );
136+
isApprox( t, nrm2, 8.831760866327, 1.0 );
141137

142138
t.end();
143139
});
@@ -166,7 +162,7 @@ tape( 'a module instance has a `main` method which supports a negative `stride`
166162
]));
167163

168164
nrm2 = mod.main( 2, xp, -2 );
169-
isApprox( t, nrm2, 8.54, 1.0 );
165+
isApprox( t, nrm2, 8.544003745317, 1.0 );
170166

171167
t.end();
172168
});

lib/node_modules/@stdlib/blas/base/wasm/scnrm2/test/test.module.ndarray.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@ var Module = require( './../lib' ).Module;
3333
// FUNCTIONS //
3434

3535
/**
36-
* Tests for element-wise approximate equality.
36+
* Tests for element approximate equality.
3737
*
3838
* @private
3939
* @param {Object} t - test object
40-
* @param {Collection} actual - actual values
41-
* @param {Collection} expected - expected values
40+
* @param {number} actual - actual value
41+
* @param {number} expected - expected value
4242
* @param {number} rtol - relative tolerance
4343
*/
4444
function isApprox( t, actual, expected, rtol ) {
4545
var delta;
4646
var tol;
47-
var i;
48-
49-
t.strictEqual( actual.length, expected.length, 'returns expected value' );
50-
for ( i = 0; i < expected.length; i++ ) {
51-
if ( actual[ i ] === expected[ i ] ) {
52-
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
53-
} else {
54-
delta = abs( actual[ i ] - expected[ i ] );
55-
tol = rtol * EPS * abs( expected[ i ] );
56-
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
57-
}
47+
48+
if ( actual === expected ) {
49+
t.strictEqual( actual, expected, 'returns expected value' );
50+
} else {
51+
delta = abs( actual - expected );
52+
tol = rtol * EPS * abs( expected );
53+
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
5854
}
5955
}
6056

@@ -93,18 +89,18 @@ tape( 'a module instance has an `ndarray` method which calculates the L2-norm of
9389

9490
xp = 0;
9591

96-
mod.write( xp, new Complex64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) );
92+
mod.write( xp, new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );
9793

9894
nrm2 = mod.ndarray( 3, xp, 1, 0 );
99-
isApprox( t, nrm2, 7.4, 1.0 );
95+
isApprox( t, nrm2, 11.575836902790, 1.0 );
10096

10197
// Short datasets:
10298
xp = 0;
10399

104100
mod.write( xp, new Complex64Array( [ -4.0, 0.0 ] ) );
105101

106102
nrm2 = mod.ndarray( 1, xp, 1, 0 );
107-
isApprox( t, nrm2, 4.0, 1.0 );
103+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
108104

109105
t.end();
110106
});
@@ -137,7 +133,7 @@ tape( 'a module instance has an `ndarray` method which supports a `stride` param
137133
]));
138134

139135
nrm2 = mod.ndarray( 3, xp, 2, 0 );
140-
isApprox( t, nrm2, 8.83, 1.0 );
136+
isApprox( t, nrm2, 8.831760866327, 1.0 );
141137

142138
t.end();
143139
});
@@ -168,7 +164,7 @@ tape( 'a module instance has an `ndarray` method which supports a negative `stri
168164
]));
169165

170166
nrm2 = mod.ndarray( 2, xp, -2, 3 );
171-
isApprox( t, nrm2, 4.24, 1.0 );
167+
isApprox( t, nrm2, 4.24264068711, 1.0 );
172168

173169
t.end();
174170
});
@@ -201,7 +197,7 @@ tape( 'a module instance has an `ndarray` method which supports an `x` offset',
201197
]));
202198

203199
nrm2 = mod.ndarray( 2, xp, 2, 2 );
204-
isApprox( t, nrm2, 4.24, 1.0 );
200+
isApprox( t, nrm2, 4.24264068711, 1.0 );
205201

206202
t.end();
207203
});

lib/node_modules/@stdlib/blas/base/wasm/scnrm2/test/test.ndarray.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,24 @@ var scnrm2 = require( './../lib' );
3030
// FUNCTIONS //
3131

3232
/**
33-
* Tests for element-wise approximate equality.
33+
* Tests for element approximate equality.
3434
*
3535
* @private
3636
* @param {Object} t - test object
37-
* @param {Collection} actual - actual values
38-
* @param {Collection} expected - expected values
37+
* @param {number} actual - actual value
38+
* @param {number} expected - expected value
3939
* @param {number} rtol - relative tolerance
4040
*/
4141
function isApprox( t, actual, expected, rtol ) {
4242
var delta;
4343
var tol;
44-
var i;
45-
46-
t.strictEqual( actual.length, expected.length, 'returns expected value' );
47-
for ( i = 0; i < expected.length; i++ ) {
48-
if ( actual[ i ] === expected[ i ] ) {
49-
t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' );
50-
} else {
51-
delta = abs( actual[ i ] - expected[ i ] );
52-
tol = rtol * EPS * abs( expected[ i ] );
53-
t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' );
54-
}
44+
45+
if ( actual === expected ) {
46+
t.strictEqual( actual, expected, 'returns expected value' );
47+
} else {
48+
delta = abs( actual - expected );
49+
tol = rtol * EPS * abs( expected );
50+
t.ok( delta <= tol, 'within tolerance. actual: '+actual+'. expected: '+expected+'. delta: '+delta+'. tol: '+tol+'.' );
5551
}
5652
}
5753

@@ -73,16 +69,16 @@ tape( 'the `ndarray` method calculates the L2-norm of a vector', function test(
7369
var nrm2;
7470
var x;
7571

76-
x = new Complex64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] );
72+
x = new Complex64Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] );
7773

7874
nrm2 = scnrm2.ndarray( x.length, x, 1, 0 );
79-
isApprox( t, nrm2, 7.4, 2.0 );
75+
isApprox( t, nrm2, 11.575836902790, 1.0 );
8076

8177
// Short datasets:
8278
x = new Complex64Array( [ -4.0, 0.0 ] );
8379

8480
nrm2 = scnrm2.ndarray( x.length, x, 1, 0 );
85-
isApprox( t, nrm2, 4.0, 1.0 );
81+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
8682

8783
t.end();
8884
});
@@ -105,7 +101,7 @@ tape( 'the `ndarray` method supports a `stride` parameter', function test( t ) {
105101
]);
106102

107103
nrm2 = scnrm2.ndarray( 3, x, 2, 0 );
108-
isApprox( t, nrm2, 8.83, 1.0 );
104+
isApprox( t, nrm2, 8.831760866327, 1.0 );
109105

110106
t.end();
111107
});
@@ -124,7 +120,7 @@ tape( 'the `ndarray` method supports a negative stride parameter', function test
124120
]);
125121

126122
nrm2 = scnrm2.ndarray( 2, x, -2, x.length-2 );
127-
isApprox( t, nrm2, 8.54, 1.0 );
123+
isApprox( t, nrm2, 8.544003745317, 1.0 );
128124

129125
t.end();
130126
});
@@ -147,7 +143,7 @@ tape( 'the `ndarray` method supports an `offset` parameter', function test( t )
147143
]);
148144

149145
nrm2 = scnrm2.ndarray( 2, x, 2, 2 );
150-
isApprox( t, nrm2, 4.24, 1.0 );
146+
isApprox( t, nrm2, 4.24264068711, 1.0 );
151147

152148
t.end();
153149
});

0 commit comments

Comments
 (0)