Skip to content

Commit 37729ad

Browse files
committed
fixup! fixup! feat: add protocol support to stats/base/varianceyc
--- 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 eaf388a commit 37729ad

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
142142
v = varianceyc( -1, 1, x, 1, 0 );
143143
t.strictEqual( isnan( v ), true, 'returns expected value' );
144144

145+
x = toAccessorArray([ 10.0 ]);
146+
v = varianceyc( 0, 0, x, 1, 0 );
147+
t.strictEqual( isnan( v ), true, 'returns expected value when N = 0 with a single value' );
148+
145149
t.end();
146150
});
147151

@@ -166,6 +170,10 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
166170
v = varianceyc( 1, 0, x, 1, 0 );
167171
t.strictEqual( v, 0.0, 'returns expected value' );
168172

173+
x = toAccessorArray([ 5.0 ]);
174+
v = varianceyc( 1, 0, x, 1, 0 );
175+
t.strictEqual( v, 0.0, 'returns expected value with a single value' );
176+
169177
t.end();
170178
});
171179

@@ -191,10 +199,14 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
191199
x = toAccessorArray([ 1.0, -2.0, -4.0, 5.0, 3.0 ]);
192200

193201
v = varianceyc( x.length, x.length, x, 1, 0 );
194-
t.strictEqual( isnan( v ), true, 'returns expected value' );
202+
t.strictEqual( isnan( v ), true, 'returns expected value when n = 0' );
195203

196204
v = varianceyc( x.length, x.length+1, x, 1, 0 );
197-
t.strictEqual( isnan( v ), true, 'returns expected value' );
205+
t.strictEqual( isnan( v ), true, 'returns expected value when n < 0' );
206+
207+
x = toAccessorArray([ 7.0, 8.0, 9.0 ]);
208+
v = varianceyc( x.length, x.length, x, 1, 0 );
209+
t.strictEqual( isnan( v ), true, 'returns expected value when n = 0 with different data' );
198210

199211
t.end();
200212
});
@@ -304,6 +316,10 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
304316
v = varianceyc( x.length, 1, toAccessorArray( x ), 0, 0 );
305317
t.strictEqual( v, 0.0, 'returns expected value' );
306318

319+
x = toAccessorArray([ 10.0 ]);
320+
v = varianceyc( x.length, 1, x, 0, 0 );
321+
t.strictEqual( v, 0.0, 'returns expected value with a single value' );
322+
307323
t.end();
308324
});
309325

@@ -345,3 +361,26 @@ tape( 'the function supports an `offset` parameter (accessor)', function test( t
345361
t.strictEqual( v, 6.25, 'returns expected value' );
346362
t.end();
347363
});
364+
365+
tape( 'the function handles specific accessor cases for coverage', function test( t ) {
366+
var x;
367+
var v;
368+
369+
x = toAccessorArray([ 999.0 ]);
370+
v = varianceyc( 1, 0, x, 1, 0 );
371+
t.strictEqual( v, 0.0, 'returns expected value for N === 1' );
372+
373+
x = toAccessorArray([ 999.0, 888.0, 777.0 ]);
374+
v = varianceyc( x.length, 1, x, 0, 0 );
375+
t.strictEqual( v, 0.0, 'returns expected value for strideX === 0' );
376+
377+
x = toAccessorArray([ 10.0, 20.0, 30.0 ]);
378+
v = varianceyc( 3, 3, x, 1, 0 );
379+
t.strictEqual( isnan( v ), true, 'returns NaN when n === 0' );
380+
381+
x = toAccessorArray([ 1.0 ]);
382+
v = varianceyc( 0, 0, x, 1, 0 );
383+
t.strictEqual( isnan( v ), true, 'returns NaN when N === 0' );
384+
385+
t.end();
386+
});

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu
143143
v = varianceyc( -1, 1, x, 1 );
144144
t.strictEqual( isnan( v ), true, 'returns expected value' );
145145

146+
x = toAccessorArray([ 10.0 ]);
147+
v = varianceyc( 0, 0, x, 1 );
148+
t.strictEqual( isnan( v ), true, 'returns expected value when N = 0 with a single value' );
149+
146150
t.end();
147151
});
148152

@@ -167,6 +171,10 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns a populat
167171
v = varianceyc( 1, 0, x, 1 );
168172
t.strictEqual( v, 0.0, 'returns expected value' );
169173

174+
x = toAccessorArray([ 5.0 ]);
175+
v = varianceyc( 1, 0, x, 1 );
176+
t.strictEqual( v, 0.0, 'returns expected value with a single value' );
177+
170178
t.end();
171179
});
172180

@@ -192,10 +200,14 @@ tape( 'if provided a `correction` parameter yielding `N-correction` less than or
192200
x = toAccessorArray([ 1.0, -2.0, -4.0, 5.0, 3.0 ]);
193201

194202
v = varianceyc( x.length, x.length, x, 1 );
195-
t.strictEqual( isnan( v ), true, 'returns expected value' );
203+
t.strictEqual( isnan( v ), true, 'returns expected value when n = 0' );
196204

197205
v = varianceyc( x.length, x.length+1, x, 1 );
198-
t.strictEqual( isnan( v ), true, 'returns expected value' );
206+
t.strictEqual( isnan( v ), true, 'returns expected value when n < 0' );
207+
208+
x = toAccessorArray([ 7.0, 8.0, 9.0 ]);
209+
v = varianceyc( x.length, x.length, x, 1 );
210+
t.strictEqual( isnan( v ), true, 'returns expected value when n = 0 with different data' );
199211

200212
t.end();
201213
});
@@ -305,6 +317,10 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns `0` (
305317
v = varianceyc( x.length, 1, toAccessorArray( x ), 0 );
306318
t.strictEqual( v, 0.0, 'returns expected value' );
307319

320+
x = toAccessorArray([ 10.0 ]);
321+
v = varianceyc( x.length, 1, x, 0 );
322+
t.strictEqual( v, 0.0, 'returns expected value with a single value' );
323+
308324
t.end();
309325
});
310326

@@ -357,3 +373,26 @@ tape( 'the function supports view offsets (accessor)', function test( t ) {
357373

358374
t.end();
359375
});
376+
377+
tape( 'the function handles specific accessor cases for complete branch coverage', function test( t ) {
378+
var x;
379+
var v;
380+
381+
x = toAccessorArray([ 999.0 ]);
382+
v = varianceyc( 1, 0, x, 1 );
383+
t.strictEqual( v, 0.0, 'returns expected value for N === 1' );
384+
385+
x = toAccessorArray([ 999.0, 888.0, 777.0 ]);
386+
v = varianceyc( x.length, 1, x, 0 );
387+
t.strictEqual( v, 0.0, 'returns expected value for strideX === 0' );
388+
389+
x = toAccessorArray([ 10.0, 20.0, 30.0 ]);
390+
v = varianceyc( 3, 3, x, 1 );
391+
t.strictEqual( isnan( v ), true, 'returns NaN when n === 0' );
392+
393+
x = toAccessorArray([ 1.0 ]);
394+
v = varianceyc( 0, 0, x, 1 );
395+
t.strictEqual( isnan( v ), true, 'returns NaN when N === 0' );
396+
397+
t.end();
398+
});

0 commit comments

Comments
 (0)