Skip to content

Commit 5aa1f03

Browse files
committed
refactor: update tests and docs
--- 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: passed - 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: passed - task: lint_c_examples status: passed - 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 cf8a885 commit 5aa1f03

File tree

7 files changed

+26
-57
lines changed

7 files changed

+26
-57
lines changed

lib/node_modules/@stdlib/stats/base/snanmeanors/examples/c/example.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222

2323
int main( void ) {
2424
// Create a strided array:
25-
float x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 };
25+
const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f };
2626

2727
// Specify the number of elements:
28-
int64_t N = 6;
28+
const int N = 6;
2929

3030
// Specify the stride length:
31-
int64_t stride = 2;
31+
const int strideX = 2;
3232

3333
// Compute the arithmetic mean:
34-
float v = stdlib_strided_snanmeanors( N, x, stride );
34+
float v = stdlib_strided_snanmeanors( N, x, strideX );
3535

3636
// Print the result:
3737
printf( "mean: %f\n", v );

lib/node_modules/@stdlib/stats/base/snanmeanors/examples/index.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,19 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
23-
var Float32Array = require( '@stdlib/array/float32' );
21+
var uniform = require( '@stdlib/random/base/uniform' );
22+
var filledarrayBy = require( '@stdlib/array/filled-by' );
23+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
2424
var snanmeanors = require( './../lib' );
2525

26-
var x;
27-
var i;
28-
29-
x = new Float32Array( 10 );
30-
for ( i = 0; i < x.length; i++ ) {
31-
if ( randu() < 0.2 ) {
32-
x[ i ] = NaN;
33-
} else {
34-
x[ i ] = round( (randu()*100.0) - 50.0 );
26+
function rand() {
27+
if ( bernoulli( 0.8 ) < 1 ) {
28+
return NaN;
3529
}
30+
return uniform( -50.0, 50.0 );
3631
}
32+
33+
var x = filledarrayBy( 10, 'float32', rand );
3734
console.log( x );
3835

3936
var v = snanmeanors( x.length, x, 1 );

lib/node_modules/@stdlib/stats/base/snanmeanors/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2020 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var floor = require( '@stdlib/math/base/special/floor' );
2524
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2625
var Float32Array = require( '@stdlib/array/float32' );
2726
var snanmeanors = require( './../lib/ndarray.js' );
@@ -90,7 +89,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
9089
});
9190

9291
tape( 'the function supports a `stride` parameter', function test( t ) {
93-
var N;
9492
var x;
9593
var v;
9694

@@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
106104
NaN // 4
107105
]);
108106

109-
N = floor( x.length / 2 );
110-
v = snanmeanors( N, x, 2, 0 );
107+
v = snanmeanors( 5, x, 2, 0 );
111108

112109
t.strictEqual( v, 1.25, 'returns expected value' );
113110
t.end();
114111
});
115112

116113
tape( 'the function supports a negative `stride` parameter', function test( t ) {
117-
var N;
118114
var x;
119115
var v;
120116

@@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
130126
NaN // 0
131127
]);
132128

133-
N = floor( x.length / 2 );
134-
v = snanmeanors( N, x, -2, 6 );
129+
v = snanmeanors( 5, x, -2, 8 );
135130

136131
t.strictEqual( v, 1.25, 'returns expected value' );
137132
t.end();
@@ -150,7 +145,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
150145
});
151146

152147
tape( 'the function supports an `offset` parameter', function test( t ) {
153-
var N;
154148
var x;
155149
var v;
156150

@@ -166,9 +160,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) {
166160
NaN,
167161
NaN // 4
168162
]);
169-
N = floor( x.length / 2 );
170163

171-
v = snanmeanors( N, x, 2, 1 );
164+
v = snanmeanors( 5, x, 2, 1 );
172165
t.strictEqual( v, 1.25, 'returns expected value' );
173166

174167
t.end();

lib/node_modules/@stdlib/stats/base/snanmeanors/test/test.ndarray.native.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
25-
var floor = require( '@stdlib/math/base/special/floor' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var Float32Array = require( '@stdlib/array/float32' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -99,7 +98,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
9998
});
10099

101100
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
102-
var N;
103101
var x;
104102
var v;
105103

@@ -115,15 +113,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
115113
NaN // 4
116114
]);
117115

118-
N = floor( x.length / 2 );
119-
v = snanmeanors( N, x, 2, 0 );
116+
v = snanmeanors( 5, x, 2, 0 );
120117

121118
t.strictEqual( v, 1.25, 'returns expected value' );
122119
t.end();
123120
});
124121

125122
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
126-
var N;
127123
var x;
128124
var v;
129125

@@ -139,8 +135,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
139135
NaN // 0
140136
]);
141137

142-
N = floor( x.length / 2 );
143-
v = snanmeanors( N, x, -2, 6 );
138+
v = snanmeanors( 5, x, -2, 8 );
144139

145140
t.strictEqual( v, 1.25, 'returns expected value' );
146141
t.end();
@@ -159,7 +154,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
159154
});
160155

161156
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
162-
var N;
163157
var x;
164158
var v;
165159

@@ -175,9 +169,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) {
175169
NaN,
176170
NaN // 4
177171
]);
178-
N = floor( x.length / 2 );
179172

180-
v = snanmeanors( N, x, 2, 1 );
173+
v = snanmeanors( 5, x, 2, 1 );
181174
t.strictEqual( v, 1.25, 'returns expected value' );
182175

183176
t.end();

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24-
var floor = require( '@stdlib/math/base/special/floor' );
2524
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2625
var Float32Array = require( '@stdlib/array/float32' );
2726
var snanmeanors = require( './../lib/snanmeanors.js' );
@@ -90,7 +89,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
9089
});
9190

9291
tape( 'the function supports a `stride` parameter', function test( t ) {
93-
var N;
9492
var x;
9593
var v;
9694

@@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) {
106104
NaN // 4
107105
]);
108106

109-
N = floor( x.length / 2 );
110-
v = snanmeanors( N, x, 2 );
107+
v = snanmeanors( 5, x, 2 );
111108

112109
t.strictEqual( v, 1.25, 'returns expected value' );
113110
t.end();
114111
});
115112

116113
tape( 'the function supports a negative `stride` parameter', function test( t ) {
117-
var N;
118114
var x;
119115
var v;
120116

@@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
130126
NaN // 0
131127
]);
132128

133-
N = floor( x.length / 2 );
134-
v = snanmeanors( N, x, -2 );
129+
v = snanmeanors( 5, x, -2 );
135130

136131
t.strictEqual( v, 1.25, 'returns expected value' );
137132
t.end();
@@ -152,7 +147,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
152147
tape( 'the function supports view offsets', function test( t ) {
153148
var x0;
154149
var x1;
155-
var N;
156150
var v;
157151

158152
x0 = new Float32Array([
@@ -169,9 +163,8 @@ tape( 'the function supports view offsets', function test( t ) {
169163
]);
170164

171165
x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
172-
N = floor(x1.length / 2);
173166

174-
v = snanmeanors( N, x1, 2 );
167+
v = snanmeanors( 5, x1, 2 );
175168
t.strictEqual( v, 1.25, 'returns expected value' );
176169

177170
t.end();

lib/node_modules/@stdlib/stats/base/snanmeanors/test/test.snanmeanors.native.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var tape = require( 'tape' );
25-
var floor = require( '@stdlib/math/base/special/floor' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var Float32Array = require( '@stdlib/array/float32' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -181,7 +180,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first
181180
});
182181

183182
tape( 'the function supports a `stride` parameter', opts, function test( t ) {
184-
var N;
185183
var x;
186184
var v;
187185

@@ -197,15 +195,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) {
197195
NaN // 4
198196
]);
199197

200-
N = floor( x.length / 2 );
201-
v = snanmeanors( N, x, 2 );
198+
v = snanmeanors( 5, x, 2 );
202199

203200
t.strictEqual( v, 1.25, 'returns expected value' );
204201
t.end();
205202
});
206203

207204
tape( 'the function supports a negative `stride` parameter', opts, function test( t ) {
208-
var N;
209205
var x;
210206
var v;
211207

@@ -221,8 +217,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
221217
NaN // 0
222218
]);
223219

224-
N = floor( x.length / 2 );
225-
v = snanmeanors( N, x, -2 );
220+
v = snanmeanors( 5, x, -2 );
226221

227222
t.strictEqual( v, 1.25, 'returns expected value' );
228223
t.end();
@@ -243,7 +238,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f
243238
tape( 'the function supports view offsets', opts, function test( t ) {
244239
var x0;
245240
var x1;
246-
var N;
247241
var v;
248242

249243
x0 = new Float32Array([
@@ -260,9 +254,8 @@ tape( 'the function supports view offsets', opts, function test( t ) {
260254
]);
261255

262256
x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
263-
N = floor(x1.length / 2);
264257

265-
v = snanmeanors( N, x1, 2 );
258+
v = snanmeanors( 5, x1, 2 );
266259
t.strictEqual( v, 1.25, 'returns expected value' );
267260

268261
t.end();

0 commit comments

Comments
 (0)