Skip to content

Commit 8f4091b

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: passed - 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: passed - 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 a71ff1d commit 8f4091b

File tree

7 files changed

+44
-164
lines changed

7 files changed

+44
-164
lines changed

lib/node_modules/@stdlib/blas/base/wasm/dznrm2/benchmark/benchmark.module.main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function createBenchmark( len ) {
8080
// Initialize the module:
8181
mod.initializeSync(); // eslint-disable-line node/no-sync
8282

83-
// Reallocate the underlying memory to allow storing one vector and a complex number:
83+
// Reallocate the underlying memory to allow storing one vector:
8484
nb = bytesPerElement( 'complex128' );
85-
mod.realloc( (N*nb)+nb );
85+
mod.realloc( N*nb );
8686

8787
// Define a pointer (i.e., byte offset) to the first vector element:
8888
xptr = 0;

lib/node_modules/@stdlib/blas/base/wasm/dznrm2/benchmark/benchmark.module.ndarray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function createBenchmark( len ) {
8080
// Initialize the module:
8181
mod.initializeSync(); // eslint-disable-line node/no-sync
8282

83-
// Reallocate the underlying memory to allow storing one vector and a complex number:
83+
// Reallocate the underlying memory to allow storing one vector:
8484
nb = bytesPerElement( 'complex128' );
85-
mod.realloc( (N*nb)+nb );
85+
mod.realloc( N*nb );
8686

8787
// Define a pointer (i.e., byte offset) to the first vector element:
8888
xptr = 0;

lib/node_modules/@stdlib/blas/base/wasm/dznrm2/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
~3.16
8181

8282
// Using offset parameter:
83-
> var x = new {{alias:@stdlib/array/complex128}}( [ 3.0, 2.0, 3.0, 0.0 ] );
83+
> x = new {{alias:@stdlib/array/complex128}}( [ 3.0, 2.0, 3.0, 0.0 ] );
8484
> out = {{alias}}.ndarray( 1, x, 1, 1 )
8585
3.0
8686

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

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,10 @@
2222

2323
var tape = require( 'tape' );
2424
var Complex128Array = require( '@stdlib/array/complex128' );
25-
var EPS = require( '@stdlib/constants/float64/eps' );
26-
var abs = require( '@stdlib/math/base/special/abs' );
25+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
2726
var dznrm2 = require( './../lib' );
2827

2928

30-
// FUNCTIONS //
31-
32-
/**
33-
* Tests for element-wise approximate equality.
34-
*
35-
* @private
36-
* @param {Object} t - test object
37-
* @param {Collection} actual - actual values
38-
* @param {Collection} expected - expected values
39-
* @param {number} rtol - relative tolerance
40-
*/
41-
function isApprox( t, actual, expected, rtol ) {
42-
var delta;
43-
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-
}
55-
}
56-
}
57-
58-
5929
// TESTS //
6030

6131
tape( 'main export is an object', function test( t ) {
@@ -73,15 +43,15 @@ tape( 'the `main` method calculates the L2-norm of a vector', function test( t )
7343
var nrm2;
7444
var x;
7545

76-
x = new Complex128Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] );
46+
x = new Complex128Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] );
7747

7848
nrm2 = dznrm2.main( x.length, x, 1 );
79-
isApprox( t, nrm2, 7.4, 1.0 );
49+
t.strictEqual( nrm2, sqrt( 134.0 ), 'returns expected value' );
8050

8151
x = new Complex128Array( [ -4.0, 0.0 ] );
8252

8353
nrm2 = dznrm2.main( x.length, x, 1 );
84-
isApprox( t, nrm2, 4.0, 1.0 );
54+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
8555

8656
t.end();
8757
});
@@ -104,7 +74,7 @@ tape( 'the `main` method supports a `stride` parameter', function test( t ) {
10474
]);
10575

10676
nrm2 = dznrm2.main( 3, x, 2 );
107-
isApprox( t, nrm2, 8.83, 1.0 );
77+
t.strictEqual( nrm2, sqrt( 78.0 ), 'returns expected value' );
10878

10979
t.end();
11080
});
@@ -123,7 +93,7 @@ tape( 'the `main` method supports a negative `stride` parameter', function test(
12393
]);
12494

12595
nrm2 = dznrm2.main( 2, x, -2 );
126-
isApprox( t, nrm2, 8.54, 1.0 );
96+
t.strictEqual( nrm2, sqrt( 73.0 ), 'returns expected value' );
12797

12898
t.end();
12999
});
@@ -158,13 +128,13 @@ tape( 'the `main` method supports view offsets', function test( t ) {
158128
-2.0,
159129
-2.0,
160130
2.0, // 2
161-
3.0 // 2
131+
3.0 // 2
162132
]);
163133

164134
x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*2 ); // start at 3rd element
165135

166-
nrm2 = dznrm2.main( 4, x1, 2 );
167-
isApprox( t, nrm2, 4.24, 1.0 );
136+
nrm2 = dznrm2.main( 2, x1, 2 );
137+
t.strictEqual( nrm2, sqrt( 18.0 ), 'returns expected value' );
168138

169139
t.end();
170140
});

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

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,10 @@
2525
var tape = require( 'tape' );
2626
var Memory = require( '@stdlib/wasm/memory' );
2727
var Complex128Array = require( '@stdlib/array/complex128' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
29-
var abs = require( '@stdlib/math/base/special/abs' );
28+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
3029
var Module = require( './../lib' ).Module;
3130

3231

33-
// FUNCTIONS //
34-
35-
/**
36-
* Tests for element-wise approximate equality.
37-
*
38-
* @private
39-
* @param {Object} t - test object
40-
* @param {Collection} actual - actual values
41-
* @param {Collection} expected - expected values
42-
* @param {number} rtol - relative tolerance
43-
*/
44-
function isApprox( t, actual, expected, rtol ) {
45-
var delta;
46-
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-
}
58-
}
59-
}
60-
61-
6232
// TESTS //
6333

6434
tape( 'main export is a function', function test( t ) {
@@ -93,18 +63,18 @@ tape( 'a module instance has a `main` method which calculates the L2-norm of a v
9363

9464
xp = 0;
9565

96-
mod.write( xp, new Complex128Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) );
66+
mod.write( xp, new Complex128Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );
9767

9868
nrm2 = mod.main( 3, xp, 1 );
99-
isApprox( t, nrm2, 7.4, 1.0 );
69+
t.strictEqual( nrm2, sqrt( 134.0 ), 'returns expected value' );
10070

10171
// Short datasets:
10272
xp = 0;
10373

10474
mod.write( xp, new Complex128Array( [ -4.0, 0.0 ] ) );
10575

10676
nrm2 = mod.main( 1, xp, 1 );
107-
isApprox( t, nrm2, 4.0, 1.0 );
77+
t.strictEqual( nrm2, 4.0, 'returns expected value' );
10878

10979
t.end();
11080
});
@@ -137,7 +107,7 @@ tape( 'a module instance has a `main` method which supports a `stride` parameter
137107
]));
138108

139109
nrm2 = mod.main( 3, xp, 2 );
140-
isApprox( t, nrm2, 8.83, 1.0 );
110+
t.strictEqual( nrm2, sqrt( 78.0 ), 'returns expected value' );
141111

142112
t.end();
143113
});
@@ -166,7 +136,7 @@ tape( 'a module instance has a `main` method which supports a negative `stride`
166136
]));
167137

168138
nrm2 = mod.main( 2, xp, -2 );
169-
isApprox( t, nrm2, 8.54, 1.0 );
139+
t.strictEqual( nrm2, sqrt( 73.0 ), 'returns expected value' );
170140

171141
t.end();
172142
});

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

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,10 @@
2525
var tape = require( 'tape' );
2626
var Memory = require( '@stdlib/wasm/memory' );
2727
var Complex128Array = require( '@stdlib/array/complex128' );
28-
var EPS = require( '@stdlib/constants/float64/eps' );
29-
var abs = require( '@stdlib/math/base/special/abs' );
28+
var sqrt = require( '@stdlib/math/base/special/sqrt' );
3029
var Module = require( './../lib' ).Module;
3130

3231

33-
// FUNCTIONS //
34-
35-
/**
36-
* Tests for element-wise approximate equality.
37-
*
38-
* @private
39-
* @param {Object} t - test object
40-
* @param {Collection} actual - actual values
41-
* @param {Collection} expected - expected values
42-
* @param {number} rtol - relative tolerance
43-
*/
44-
function isApprox( t, actual, expected, rtol ) {
45-
var delta;
46-
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-
}
58-
}
59-
}
60-
61-
6232
// TESTS //
6333

6434
tape( 'main export is a function', function test( t ) {
@@ -93,18 +63,18 @@ tape( 'a module instance has an `ndarray` method which calculates the L2-norm of
9363

9464
xp = 0;
9565

96-
mod.write( xp, new Complex128Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) );
66+
mod.write( xp, new Complex128Array( [ 3.0, -4.0, -6.0, 8.0, 0.0, 3.0 ] ) );
9767

9868
nrm2 = mod.ndarray( 3, xp, 1, 0 );
99-
isApprox( t, nrm2, 7.4, 1.0 );
69+
t.strictEqual( nrm2, sqrt( 134.0 ), 'returns expected value' );
10070

10171
// Short datasets:
10272
xp = 0;
10373

10474
mod.write( xp, new Complex128Array( [ -4.0, 0.0 ] ) );
10575

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

10979
t.end();
11080
});
@@ -137,7 +107,7 @@ tape( 'a module instance has an `ndarray` method which supports a `stride` param
137107
]));
138108

139109
nrm2 = mod.ndarray( 3, xp, 2, 0 );
140-
isApprox( t, nrm2, 8.83, 1.0 );
110+
t.strictEqual( nrm2, sqrt( 78.0 ), 'returns expected value' );
141111

142112
t.end();
143113
});
@@ -157,18 +127,18 @@ tape( 'a module instance has an `ndarray` method which supports a negative `stri
157127
xp = 0;
158128

159129
mod.write( xp, new Complex128Array([
160-
1.0, // 2
161-
2.0, // 2
130+
1.0,
162131
2.0,
163-
-7.0,
164-
-2.0, // 1
165-
3.0, // 1
166-
4.0,
167-
2.0
132+
2.0, // 2
133+
-7.0, // 2
134+
-2.0,
135+
3.0,
136+
4.0, // 1
137+
2.0 // 1
168138
]));
169139

170140
nrm2 = mod.ndarray( 2, xp, -2, 3 );
171-
isApprox( t, nrm2, 4.24, 1.0 );
141+
t.strictEqual( nrm2, sqrt( 73.0 ), 'returns expected value' );
172142

173143
t.end();
174144
});
@@ -197,11 +167,11 @@ tape( 'a module instance has an `ndarray` method which supports an `x` offset',
197167
-2.0,
198168
-2.0,
199169
2.0, // 2
200-
3.0 // 2
170+
3.0 // 2
201171
]));
202172

203173
nrm2 = mod.ndarray( 2, xp, 2, 2 );
204-
isApprox( t, nrm2, 4.24, 1.0 );
174+
t.strictEqual( nrm2, sqrt( 18.0 ), 'returns expected value' );
205175

206176
t.end();
207177
});

0 commit comments

Comments
 (0)