Skip to content

Commit 3ef7ed7

Browse files
chore: updated according to code review
--- 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: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: failed ---
1 parent d2f8e62 commit 3ef7ed7

File tree

9 files changed

+103
-41
lines changed

9 files changed

+103
-41
lines changed

lib/node_modules/@stdlib/stats/base/snanmeanpn/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,19 @@ var v = snanmeanpn.ndarray( 4, x, 2, 1 );
145145
<!-- eslint no-undef: "error" -->
146146

147147
```javascript
148+
var uniform = require( '@stdlib/random/base/uniform' );
149+
var filledarrayBy = require( '@stdlib/array/filled-by' );
150+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
148151
var snanmeanpn = require( '@stdlib/stats/base/snanmeanpn' );
149-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
150152

151-
var x = discreteUniform( 10, -50, 50, {
152-
'dtype': 'float64'
153-
});
153+
function rand() {
154+
if ( bernoulli( 0.8 ) < 1 ) {
155+
return NaN;
156+
}
157+
return uniform( -50.0, 50.0 );
158+
}
159+
160+
var x = filledarrayBy( 10, 'float32', rand );
154161
console.log( x );
155162

156163
var v = snanmeanpn( x.length, x, 1 );
@@ -176,7 +183,7 @@ console.log( v );
176183
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values and using a two-pass error correction algorithm.
177184

178185
```c
179-
const double x[] = { 1.0, -2.0, NaN, 2.0 };
186+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
180187

181188
double v = stdlib_strided_dnanmeanpn( 3, x, 1 );
182189
// returns ~0.33333
@@ -197,7 +204,7 @@ float stdlib_strided_dnanmeanpn( const CBLAS_INT N, const float *X, const CBLAS_
197204
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
198205

199206
```c
200-
const double x[] = { 1.0, -2.0, NaN, 2.0 };
207+
const double x[] = { 1.0, -2.0, 0.0/0.0, 2.0 };
201208

202209
double v = stdlib_strided_dnanmeanpn_ndarray( 3, x, 1, 0 );
203210
// returns ~0.33333

lib/node_modules/@stdlib/stats/base/snanmeanpn/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2527
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2628
var pow = require( '@stdlib/math/base/special/pow' );
2729
var pkg = require( './../package.json' ).name;
2830
var snanmeanpn = require( './../lib/snanmeanpn.js' );
2931

3032

31-
// VARIABLES //
32-
33-
var options = {
34-
'dtype': 'float64'
35-
};
36-
37-
3833
// FUNCTIONS //
3934

35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.2 ) ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
4048
/**
4149
* Creates a benchmark function.
4250
*
@@ -45,7 +53,7 @@ var options = {
4553
* @returns {Function} benchmark function
4654
*/
4755
function createBenchmark( len ) {
48-
var x = uniform( len, -10.0, 10.0, options );
56+
var x = filledarrayBy( len, 'float32', rand );
4957
return benchmark;
5058

5159
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/snanmeanpn/benchmark/benchmark.native.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/array/uniform' );
26+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
27+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2628
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2729
var pow = require( '@stdlib/math/base/special/pow' );
2830
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -35,13 +37,23 @@ var snanmeanpn = tryRequire( resolve( __dirname, './../lib/snanmeanpn.native.js'
3537
var opts = {
3638
'skip': ( snanmeanpn instanceof Error )
3739
};
38-
var options = {
39-
'dtype': 'float64'
40-
};
4140

4241

4342
// FUNCTIONS //
4443

44+
/**
45+
* Returns a random value or `NaN`.
46+
*
47+
* @private
48+
* @returns {number} random number or `NaN`
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.2 ) ) {
52+
return NaN;
53+
}
54+
return uniform( -10.0, 10.0 );
55+
}
56+
4557
/**
4658
* Creates a benchmark function.
4759
*
@@ -50,7 +62,7 @@ var options = {
5062
* @returns {Function} benchmark function
5163
*/
5264
function createBenchmark( len ) {
53-
var x = uniform( len, -10.0, 10.0, options );
65+
var x = filledarrayBy( len, 'float32', rand );
5466
return benchmark;
5567

5668
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/snanmeanpn/benchmark/benchmark.ndarray.js

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

2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
25+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
26+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2527
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2628
var pow = require( '@stdlib/math/base/special/pow' );
2729
var pkg = require( './../package.json' ).name;
2830
var snanmeanpn = require( './../lib/ndarray.js' );
2931

3032

31-
// VARIABLES //
32-
33-
var options = {
34-
'dtype': 'float64'
35-
};
36-
37-
3833
// FUNCTIONS //
3934

35+
/**
36+
* Returns a random value or `NaN`.
37+
*
38+
* @private
39+
* @returns {number} random number or `NaN`
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.2 ) ) {
43+
return NaN;
44+
}
45+
return uniform( -10.0, 10.0 );
46+
}
47+
4048
/**
4149
* Creates a benchmark function.
4250
*
@@ -45,7 +53,7 @@ var options = {
4553
* @returns {Function} benchmark function
4654
*/
4755
function createBenchmark( len ) {
48-
var x = uniform( len, -10.0, 10.0, options );
56+
var x = filledarrayBy( len, 'float32', rand );
4957
return benchmark;
5058

5159
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/snanmeanpn/benchmark/benchmark.ndarray.native.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/array/uniform' );
26+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
27+
var filledarrayBy = require( '@stdlib/array/filled-by' );
2628
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2729
var pow = require( '@stdlib/math/base/special/pow' );
2830
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -35,13 +37,23 @@ var snanmeanpn = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' )
3537
var opts = {
3638
'skip': ( snanmeanpn instanceof Error )
3739
};
38-
var options = {
39-
'dtype': 'float64'
40-
};
4140

4241

4342
// FUNCTIONS //
4443

44+
/**
45+
* Returns a random value or `NaN`.
46+
*
47+
* @private
48+
* @returns {number} random number or `NaN`
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.2 ) ) {
52+
return NaN;
53+
}
54+
return uniform( -10.0, 10.0 );
55+
}
56+
4557
/**
4658
* Creates a benchmark function.
4759
*
@@ -50,7 +62,7 @@ var options = {
5062
* @returns {Function} benchmark function
5163
*/
5264
function createBenchmark( len ) {
53-
var x = uniform( len, -10.0, 10.0, options );
65+
var x = filledarrayBy( len, 'float32', rand );
5466
return benchmark;
5567

5668
function benchmark( b ) {

lib/node_modules/@stdlib/stats/base/snanmeanpn/benchmark/c/benchmark.length.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ static double benchmark1( int iterations, int len ) {
102102
int i;
103103

104104
for ( i = 0; i < len; i++ ) {
105-
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
105+
if ( rand_double() < 0.2 ) {
106+
x[ i ] = 0.0 / 0.0; // NaN
107+
} else {
108+
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
109+
}
106110
}
107111
v = 0.0f;
108112
t = tic();
@@ -136,7 +140,11 @@ static double benchmark2( int iterations, int len ) {
136140
int i;
137141

138142
for ( i = 0; i < len; i++ ) {
139-
x[ i ] = ( rand_float()*20000.0f ) - 10000.0f;
143+
if ( rand_double() < 0.2 ) {
144+
x[ i ] = 0.0 / 0.0; // NaN
145+
} else {
146+
x[ i ] = ( rand_double() * 20000.0 ) - 10000.0;
147+
}
140148
}
141149
v = 0.0f;
142150
t = tic();

lib/node_modules/@stdlib/stats/base/snanmeanpn/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Input array.
2424

2525
strideX: integer
26-
Stride Length.
26+
Stride length.
2727

2828
Returns
2929
-------
@@ -67,7 +67,7 @@
6767
Input array.
6868

6969
strideX: integer
70-
Stride Length.
70+
Stride length.
7171

7272
offsetX: integer
7373
Starting index.

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

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

1919
'use strict';
2020

21-
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22-
var snanmeanpn = require( './../lib' );
21+
var uniform = require( '@stdlib/random/base/uniform' );
22+
var filledarrayBy = require( '@stdlib/array/filled-by' );
23+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
24+
var snanmeanpn = require( '@stdlib/stats/base/snanmeanpn' );
2325

24-
var x = discreteUniform( 10, -50, 50, {
25-
'dtype': 'float64'
26-
});
26+
function rand() {
27+
if ( bernoulli( 0.8 ) < 1 ) {
28+
return NaN;
29+
}
30+
return uniform( -50.0, 50.0 );
31+
}
32+
33+
var x = filledarrayBy( 10, 'float32', rand );
2734
console.log( x );
2835

2936
var v = snanmeanpn( x.length, x, 1 );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2020 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.
@@ -43,7 +43,7 @@ float API_SUFFIX(stdlib_strided_snanmeanpn)( const CBLAS_INT N, const float *X,
4343
}
4444

4545
/**
46-
* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
46+
* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.
4747
*
4848
* @param N number of indexed elements
4949
* @param X input array

0 commit comments

Comments
 (0)