Skip to content

Commit 9dc0597

Browse files
committed
test: add accessors tests for nanstdevyc function
--- 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 bfec420 commit 9dc0597

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

lib/node_modules/@stdlib/stats/base/nanstdevyc/test/test.nanstdevyc.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
272272
t.end();
273273
});
274274

275+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
276+
var x;
277+
var v;
278+
279+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
280+
281+
v = nanstdevyc( 0, 1, toAccessorArray( x ), 1 );
282+
t.strictEqual( isnan( v ), true, 'returns expected value' );
283+
284+
v = nanstdevyc( -1, 1, toAccessorArray( x ), 1 );
285+
t.strictEqual( isnan( v ), true, 'returns expected value' );
286+
287+
t.end();
288+
});
289+
275290
tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` provided the first element is not `NaN`', function test( t ) {
276291
var x;
277292
var v;
@@ -289,6 +304,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
289304
t.end();
290305
});
291306

307+
tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` provided the first element is not `NaN` (accessors)', function test( t ) {
308+
var x;
309+
var v;
310+
311+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
312+
313+
v = nanstdevyc( 1, 0, toAccessorArray( x ), 1 );
314+
t.strictEqual( v, 0.0, 'returns expected value' );
315+
316+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
317+
318+
v = nanstdevyc( 1, 0, toAccessorArray( x ), 1 );
319+
t.strictEqual( isnan( v ), true, 'returns expected value' );
320+
321+
t.end();
322+
});
323+
292324
tape( 'if provided an `N` parameter equal to `1`, the function returns a sample standard deviation equal to `NaN`', function test( t ) {
293325
var x;
294326
var v;
@@ -306,6 +338,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a sample
306338
t.end();
307339
});
308340

341+
tape( 'if provided an `N` parameter equal to `1`, the function returns a sample standard deviation equal to `NaN` (accessors)', function test( t ) {
342+
var x;
343+
var v;
344+
345+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
346+
347+
v = nanstdevyc( 1, 1, toAccessorArray( x ), 1 );
348+
t.strictEqual( isnan( v ), true, 'returns expected value' );
349+
350+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
351+
352+
v = nanstdevyc( 1, 1, toAccessorArray( x ), 1 );
353+
t.strictEqual( isnan( v ), true, 'returns expected value' );
354+
355+
t.end();
356+
});
357+
309358
tape( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN`', function test( t ) {
310359
var x;
311360
var v;
@@ -321,6 +370,21 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
321370
t.end();
322371
});
323372

373+
tape( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
374+
var x;
375+
var v;
376+
377+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
378+
379+
v = nanstdevyc( x.length, x.length, toAccessorArray( x ), 1 );
380+
t.strictEqual( isnan( v ), true, 'returns expected value' );
381+
382+
v = nanstdevyc( x.length, x.length+1, toAccessorArray( x ), 1 );
383+
t.strictEqual( isnan( v ), true, 'returns expected value' );
384+
385+
t.end();
386+
});
387+
324388
tape( 'the function supports a `stride` parameter', function test( t ) {
325389
var x;
326390
var v;
@@ -451,6 +515,28 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
451515
t.end();
452516
});
453517

518+
tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` provided the correction term is not less than `0` and the first element is not `NaN` (accessors)', function test( t ) {
519+
var x;
520+
var v;
521+
522+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
523+
524+
v = nanstdevyc( x.length, 1, toAccessorArray( x ), 0 );
525+
t.strictEqual( v, 0.0, 'returns expected value' );
526+
527+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
528+
529+
v = nanstdevyc( x.length, 1, toAccessorArray( x ), 0 );
530+
t.strictEqual( isnan( v ), true, 'returns expected value' );
531+
532+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
533+
534+
v = nanstdevyc( x.length, x.length, toAccessorArray( x ), 0 );
535+
t.strictEqual( isnan( v ), true, 'returns expected value' );
536+
537+
t.end();
538+
});
539+
454540
tape( 'the function supports view offsets', function test( t ) {
455541
var x0;
456542
var x1;

lib/node_modules/@stdlib/stats/base/nanstdevyc/test/test.ndarray.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
271271
t.end();
272272
});
273273

274+
tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
275+
var x;
276+
var v;
277+
278+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
279+
280+
v = nanstdevyc( 0, 1, toAccessorArray( x ), 1, 0 );
281+
t.strictEqual( isnan( v ), true, 'returns expected value' );
282+
283+
v = nanstdevyc( -1, 1, toAccessorArray( x ), 1, 0 );
284+
t.strictEqual( isnan( v ), true, 'returns expected value' );
285+
286+
t.end();
287+
});
288+
274289
tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` provided the first element is not `NaN`', function test( t ) {
275290
var x;
276291
var v;
@@ -288,6 +303,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
288303
t.end();
289304
});
290305

306+
tape( 'if provided an `N` parameter equal to `1`, the function returns a population standard deviation of `0` provided the first element is not `NaN` (accessors)', function test( t ) {
307+
var x;
308+
var v;
309+
310+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
311+
312+
v = nanstdevyc( 1, 0, toAccessorArray( x ), 1, 0 );
313+
t.strictEqual( v, 0.0, 'returns expected value' );
314+
315+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
316+
317+
v = nanstdevyc( 1, 0, toAccessorArray( x ), 1, 0 );
318+
t.strictEqual( isnan( v ), true, 'returns expected value' );
319+
320+
t.end();
321+
});
322+
291323
tape( 'if provided an `N` parameter equal to `1`, the function returns a sample standard deviation equal to `NaN`', function test( t ) {
292324
var x;
293325
var v;
@@ -305,6 +337,23 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a sample
305337
t.end();
306338
});
307339

340+
tape( 'if provided an `N` parameter equal to `1`, the function returns a sample standard deviation equal to `NaN` (accessors)', function test( t ) {
341+
var x;
342+
var v;
343+
344+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
345+
346+
v = nanstdevyc( 1, 1, toAccessorArray( x ), 1, 0 );
347+
t.strictEqual( isnan( v ), true, 'returns expected value' );
348+
349+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
350+
351+
v = nanstdevyc( 1, 1, toAccessorArray( x ), 1, 0 );
352+
t.strictEqual( isnan( v ), true, 'returns expected value' );
353+
354+
t.end();
355+
});
356+
308357
tape( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN`', function test( t ) {
309358
var x;
310359
var v;
@@ -320,6 +369,21 @@ tape( 'if provided a `correction` parameter yielding a correction term less than
320369
t.end();
321370
});
322371

372+
tape( 'if provided a `correction` parameter yielding a correction term less than or equal to `0`, the function returns `NaN` (accessors)', function test( t ) {
373+
var x;
374+
var v;
375+
376+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
377+
378+
v = nanstdevyc( x.length, x.length, toAccessorArray( x ), 1, 0 );
379+
t.strictEqual( isnan( v ), true, 'returns expected value' );
380+
381+
v = nanstdevyc( x.length, x.length+1, toAccessorArray( x ), 1, 0 );
382+
t.strictEqual( isnan( v ), true, 'returns expected value' );
383+
384+
t.end();
385+
});
386+
323387
tape( 'the function supports a `stride` parameter', function test( t ) {
324388
var x;
325389
var v;
@@ -450,6 +514,28 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` p
450514
t.end();
451515
});
452516

517+
tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` provided the correction term is not less than `0` and the first element is not `NaN` (accessors)', function test( t ) {
518+
var x;
519+
var v;
520+
521+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
522+
523+
v = nanstdevyc( x.length, 1, toAccessorArray( x ), 0, 0 );
524+
t.strictEqual( v, 0.0, 'returns expected value' );
525+
526+
x = [ NaN, 1.0, -2.0, -4.0, 5.0, 3.0 ];
527+
528+
v = nanstdevyc( x.length, 1, toAccessorArray( x ), 0, 0 );
529+
t.strictEqual( isnan( v ), true, 'returns expected value' );
530+
531+
x = [ 1.0, -2.0, -4.0, 5.0, 3.0 ];
532+
533+
v = nanstdevyc( x.length, x.length, toAccessorArray( x ), 0, 0 );
534+
t.strictEqual( isnan( v ), true, 'returns expected value' );
535+
536+
t.end();
537+
});
538+
453539
tape( 'the function supports an `offset` parameter', function test( t ) {
454540
var x;
455541
var v;

0 commit comments

Comments
 (0)