Skip to content

Commit 01186a6

Browse files
committed
test: add tests for an invalid correction argument
--- 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: passed - 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 cc9cb3f commit 01186a6

File tree

7 files changed

+284
-3
lines changed

7 files changed

+284
-3
lines changed

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ The function accepts the following arguments:
386386
- **LDB**: `[in] CBLAS_INT` stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`).
387387
388388
```c
389-
void stdlib_strided_dcovmatmtk( const CBLAS_LAYOUT layout, const CBLAS_ORIENT orient, const int uplo, const CBLAS_INT M, const CBLAS_INT N, const double correction, const double *means, const CBLAS_INT strideM, const double *A, const CBLAS_INT LDA, double *B, const CBLAS_INT LDB );
389+
void stdlib_strided_dcovmatmtk( const CBLAS_LAYOUT layout, const CBLAS_ORIENT orient, const int uplo, const CBLAS_INT M, const CBLAS_INT N, const double correction, const double *Means, const CBLAS_INT strideM, const double *A, const CBLAS_INT LDA, double *B, const CBLAS_INT LDB );
390390
```
391391

392-
#### stdlib_strided_dcovmatmtk_ndarray( orient,uplo, M,N, c, \*Means,sm,om, \*A,sa1,sa2,oa, \*B,sb1,sb2,ob )
392+
#### stdlib_strided_dcovmatmtk_ndarray( orient, uplo, M, N, c, \*Means, sm, om, \*A, sa1, sa2, oa, \*B, sb1, sb2, ob )
393393

394394
Computes the [covariance matrix][covariance-matrix] for an `M` by `N` double-precision floating-point matrix `A` and assigns the results to a matrix `B` when provided known means and using a one-pass textbook algorithm and alternative indexing semantics.
395395

@@ -428,7 +428,7 @@ The function accepts the following arguments:
428428
- **ob**: `[in] CBLAS_INT` starting index for `B`.
429429
430430
```c
431-
void stdlib_strided_dcovmatmtk_ndarray( const CBLAS_ORIENT orient, const int uplo, const CBLAS_INT M, const CBLAS_INT N, const double correction, const double *means, const CBLAS_INT strideM, const CBLAS_INT offsetM, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB );
431+
void stdlib_strided_dcovmatmtk_ndarray( const CBLAS_ORIENT orient, const int uplo, const CBLAS_INT M, const CBLAS_INT N, const double correction, const double *Means, const CBLAS_INT strideM, const CBLAS_INT offsetM, const double *A, const CBLAS_INT strideA1, const CBLAS_INT strideA2, const CBLAS_INT offsetA, double *B, const CBLAS_INT strideB1, const CBLAS_INT strideB2, const CBLAS_INT offsetB );
432432
```
433433

434434
</section>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"order": "column-major",
3+
"orientation": "columns",
4+
"uplo": "full",
5+
6+
"M": 3,
7+
"N": 2,
8+
9+
"correction": 10.0,
10+
11+
"means": [ 1.0, 1.0 ],
12+
"strideM": 1,
13+
"offsetM": 0,
14+
15+
"A": [
16+
0.9278263806530006,
17+
2.2592357076016163,
18+
-0.18706208825461680,
19+
20+
1.9581128868601922,
21+
1.4217847035122055,
22+
-0.37989759037239734
23+
],
24+
"A_mat": [
25+
[ 0.9278263806530006, 1.9581128868601922 ],
26+
[ 2.2592357076016163, 1.4217847035122055 ],
27+
[ -0.18706208825461680, -0.37989759037239734 ]
28+
],
29+
"lda": 3,
30+
"strideA1": 1,
31+
"strideA2": 3,
32+
"offsetA": 0,
33+
34+
"B": [ 0.0, 0.0, 0.0, 0.0 ],
35+
"B_mat": [
36+
[ 0.0, 0.0 ],
37+
[ 0.0, 0.0 ]
38+
],
39+
"ldb": 2,
40+
"strideB1": 1,
41+
"strideB2": 2,
42+
"offsetB": 0,
43+
44+
"B_out": null
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"order": "row-major",
3+
"orientation": "rows",
4+
"uplo": "full",
5+
6+
"M": 2,
7+
"N": 3,
8+
9+
"correction": 10.0,
10+
11+
"means": [ 1.0, 1.0 ],
12+
"strideM": 1,
13+
"offsetM": 0,
14+
15+
"A": [
16+
0.9278263806530006,
17+
2.2592357076016163,
18+
-0.18706208825461680,
19+
20+
1.9581128868601922,
21+
1.4217847035122055,
22+
-0.37989759037239734
23+
],
24+
"A_mat": [
25+
[ 0.9278263806530006, 2.2592357076016163, -0.18706208825461680 ],
26+
[ 1.9581128868601922, 1.4217847035122055, -0.37989759037239734 ]
27+
],
28+
"lda": 3,
29+
"strideA1": 3,
30+
"strideA2": 1,
31+
"offsetA": 0,
32+
33+
"B": [ 0.0, 0.0, 0.0, 0.0 ],
34+
"B_mat": [
35+
[ 0.0, 0.0 ],
36+
[ 0.0, 0.0 ]
37+
],
38+
"ldb": 2,
39+
"strideB1": 2,
40+
"strideB2": 1,
41+
"offsetB": 0,
42+
43+
"B_out": null
44+
}

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/test/test.dcovmatmtk.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
var tape = require( 'tape' );
2626
var Float64Array = require( '@stdlib/array/float64' );
2727
var isAlmostEqualFloat64Array = require( '@stdlib/assert/is-almost-equal-float64array' );
28+
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
29+
var filledarray = require( '@stdlib/array/filled' );
2830
var dcovmatmtk = require( './../lib/dcovmatmtk.js' );
2931

3032

@@ -36,13 +38,15 @@ var rmcols = require( './fixtures/row_major_columns.json' );
3638
var rmu = require( './fixtures/row_major_upper.json' );
3739
var rml = require( './fixtures/row_major_lower.json' );
3840
var rmsm = require( './fixtures/row_major_sm.json' );
41+
var rmic = require( './fixtures/row_major_invalid_correction.json' );
3942

4043
var cm = require( './fixtures/column_major.json' );
4144
var cmc = require( './fixtures/column_major_corrected.json' );
4245
var cmrows = require( './fixtures/column_major_rows.json' );
4346
var cmu = require( './fixtures/column_major_upper.json' );
4447
var cml = require( './fixtures/column_major_lower.json' );
4548
var cmsm = require( './fixtures/column_major_sm.json' );
49+
var cmic = require( './fixtures/column_major_invalid_correction.json' );
4650

4751

4852
// TESTS //
@@ -423,3 +427,47 @@ tape( 'the function supports specifying a stride for the vector of known means (
423427
t.strictEqual( isAlmostEqualFloat64Array( out, expected, 200 ), true, 'returns expected value' );
424428
t.end();
425429
});
430+
431+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (row-major)', function test( t ) {
432+
var expected;
433+
var data;
434+
var out;
435+
var A;
436+
var B;
437+
var m;
438+
439+
data = rmic;
440+
441+
m = new Float64Array( data.means );
442+
A = new Float64Array( data.A );
443+
B = new Float64Array( data.B );
444+
445+
expected = filledarray( NaN, B.length, 'float64' );
446+
447+
out = dcovmatmtk( data.order, data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, A, data.lda, B, data.ldb );
448+
t.strictEqual( out, B, 'returns expected value' );
449+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
450+
t.end();
451+
});
452+
453+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (column-major)', function test( t ) {
454+
var expected;
455+
var data;
456+
var out;
457+
var A;
458+
var B;
459+
var m;
460+
461+
data = cmic;
462+
463+
m = new Float64Array( data.means );
464+
A = new Float64Array( data.A );
465+
B = new Float64Array( data.B );
466+
467+
expected = filledarray( NaN, B.length, 'float64' );
468+
469+
out = dcovmatmtk( data.order, data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, A, data.lda, B, data.ldb );
470+
t.strictEqual( out, B, 'returns expected value' );
471+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
472+
t.end();
473+
});

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/test/test.dcovmatmtk.native.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var resolve = require( 'path' ).resolve;
2626
var tape = require( 'tape' );
2727
var Float64Array = require( '@stdlib/array/float64' );
2828
var isAlmostEqualFloat64Array = require( '@stdlib/assert/is-almost-equal-float64array' );
29+
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
30+
var filledarray = require( '@stdlib/array/filled' );
2931
var tryRequire = require( '@stdlib/utils/try-require' );
3032

3133

@@ -37,13 +39,15 @@ var rmcols = require( './fixtures/row_major_columns.json' );
3739
var rmu = require( './fixtures/row_major_upper.json' );
3840
var rml = require( './fixtures/row_major_lower.json' );
3941
var rmsm = require( './fixtures/row_major_sm.json' );
42+
var rmic = require( './fixtures/row_major_invalid_correction.json' );
4043

4144
var cm = require( './fixtures/column_major.json' );
4245
var cmc = require( './fixtures/column_major_corrected.json' );
4346
var cmrows = require( './fixtures/column_major_rows.json' );
4447
var cmu = require( './fixtures/column_major_upper.json' );
4548
var cml = require( './fixtures/column_major_lower.json' );
4649
var cmsm = require( './fixtures/column_major_sm.json' );
50+
var cmic = require( './fixtures/column_major_invalid_correction.json' );
4751

4852

4953
// VARIABLES //
@@ -432,3 +436,47 @@ tape( 'the function supports specifying a stride for the vector of known means (
432436
t.strictEqual( isAlmostEqualFloat64Array( out, expected, 200 ), true, 'returns expected value' );
433437
t.end();
434438
});
439+
440+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (row-major)', opts, function test( t ) {
441+
var expected;
442+
var data;
443+
var out;
444+
var A;
445+
var B;
446+
var m;
447+
448+
data = rmic;
449+
450+
m = new Float64Array( data.means );
451+
A = new Float64Array( data.A );
452+
B = new Float64Array( data.B );
453+
454+
expected = filledarray( NaN, B.length, 'float64' );
455+
456+
out = dcovmatmtk( data.order, data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, A, data.lda, B, data.ldb );
457+
t.strictEqual( out, B, 'returns expected value' );
458+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
459+
t.end();
460+
});
461+
462+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (column-major)', opts, function test( t ) {
463+
var expected;
464+
var data;
465+
var out;
466+
var A;
467+
var B;
468+
var m;
469+
470+
data = cmic;
471+
472+
m = new Float64Array( data.means );
473+
A = new Float64Array( data.A );
474+
B = new Float64Array( data.B );
475+
476+
expected = filledarray( NaN, B.length, 'float64' );
477+
478+
out = dcovmatmtk( data.order, data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, A, data.lda, B, data.ldb );
479+
t.strictEqual( out, B, 'returns expected value' );
480+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
481+
t.end();
482+
});

lib/node_modules/@stdlib/stats/strided/dcovmatmtk/test/test.ndarray.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
var tape = require( 'tape' );
2626
var Float64Array = require( '@stdlib/array/float64' );
2727
var isAlmostEqualFloat64Array = require( '@stdlib/assert/is-almost-equal-float64array' );
28+
var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' );
29+
var filledarray = require( '@stdlib/array/filled' );
2830
var dcovmatmtk = require( './../lib/ndarray.js' );
2931

3032

@@ -41,6 +43,7 @@ var rmob = require( './fixtures/row_major_ob.json' );
4143
var rmom = require( './fixtures/row_major_om.json' );
4244
var rmsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' );
4345
var rmsb1sb2 = require( './fixtures/row_major_sb1_sb2.json' );
46+
var rmic = require( './fixtures/row_major_invalid_correction.json' );
4447

4548
var cm = require( './fixtures/column_major.json' );
4649
var cmc = require( './fixtures/column_major_corrected.json' );
@@ -53,6 +56,7 @@ var cmob = require( './fixtures/column_major_ob.json' );
5356
var cmom = require( './fixtures/column_major_om.json' );
5457
var cmsa1sa2 = require( './fixtures/column_major_sa1_sa2.json' );
5558
var cmsb1sb2 = require( './fixtures/column_major_sb1_sb2.json' );
59+
var cmic = require( './fixtures/column_major_invalid_correction.json' );
5660

5761

5862
// TESTS //
@@ -627,3 +631,47 @@ tape( 'the function supports specifying an offset for `B` (column-major)', funct
627631
t.strictEqual( isAlmostEqualFloat64Array( out, expected, 200 ), true, 'returns expected value' );
628632
t.end();
629633
});
634+
635+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (row-major)', function test( t ) {
636+
var expected;
637+
var data;
638+
var out;
639+
var A;
640+
var B;
641+
var m;
642+
643+
data = rmic;
644+
645+
m = new Float64Array( data.means );
646+
A = new Float64Array( data.A );
647+
B = new Float64Array( data.B );
648+
649+
expected = filledarray( NaN, B.length, 'float64' );
650+
651+
out = dcovmatmtk( data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, data.offsetM, A, data.strideA1, data.strideA2, data.offsetA, B, data.strideB1, data.strideB2, data.offsetB );
652+
t.strictEqual( out, B, 'returns expected value' );
653+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
654+
t.end();
655+
});
656+
657+
tape( 'the function sets elements in the output matrix to `NaN` if provided an invalid correction argument (column-major)', function test( t ) {
658+
var expected;
659+
var data;
660+
var out;
661+
var A;
662+
var B;
663+
var m;
664+
665+
data = cmic;
666+
667+
m = new Float64Array( data.means );
668+
A = new Float64Array( data.A );
669+
B = new Float64Array( data.B );
670+
671+
expected = filledarray( NaN, B.length, 'float64' );
672+
673+
out = dcovmatmtk( data.orientation, data.uplo, data.M, data.N, data.correction, m, data.strideM, data.offsetM, A, data.strideA1, data.strideA2, data.offsetA, B, data.strideB1, data.strideB2, data.offsetB );
674+
t.strictEqual( out, B, 'returns expected value' );
675+
t.strictEqual( isSameFloat64Array( out, expected ), true, 'returns expected value' );
676+
t.end();
677+
});

0 commit comments

Comments
 (0)