Skip to content

Commit 5f65e30

Browse files
fix: update examples to use correct N values and handle NaN in arrays
--- 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: na - task: lint_javascript_tests status: na - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent 79daa36 commit 5f65e30

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,28 @@ The function has the following parameters:
7272

7373
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`,
7474

75+
<!-- eslint-disable max-len -->
76+
7577
```javascript
7678
var Float32Array = require( '@stdlib/array/float32' );
7779

78-
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] );
80+
var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN, NaN ] );
7981

80-
var v = snanmeanpn( 4, x, 2 );
82+
var v = snanmeanpn( 5, x, 2 );
8183
// returns 1.25
8284
```
8385

8486
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
8587

86-
<!-- eslint-disable stdlib/capitalized-comments -->
88+
<!-- eslint-disable stdlib/capitalized-comments, max-len -->
8789

8890
```javascript
8991
var Float32Array = require( '@stdlib/array/float32' );
9092

91-
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
93+
var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
9294
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
9395

94-
var v = snanmeanpn( 4, x1, 2 );
96+
var v = snanmeanpn( 5, x1, 2 );
9597
// returns 1.25
9698
```
9799

@@ -114,12 +116,14 @@ The function has the following additional parameters:
114116

115117
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element
116118

119+
<!-- eslint-disable max-len -->
120+
117121
```javascript
118122
var Float32Array = require( '@stdlib/array/float32' );
119123

120-
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] );
124+
var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN, NaN ] );
121125

122-
var v = snanmeanpn.ndarray( 4, x, 2, 1 );
126+
var v = snanmeanpn.ndarray( 5, x, 2, 1 );
123127
// returns 1.25
124128
```
125129

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@
3838
~0.3333
3939

4040
// Using `N` and stride parameters:
41-
> x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] );
42-
> {{alias}}( 3, x, 2 )
41+
> x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] );
42+
> {{alias}}( 4, x, 2 )
4343
~0.3333
4444

4545
// Using view offsets:
46-
> var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
46+
> var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
4747
> var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
48-
> {{alias}}( 3, x1, 2 )
48+
> {{alias}}( 4, x1, 2 )
4949
~-0.3333
5050

5151

@@ -85,8 +85,8 @@
8585
~0.3333
8686

8787
// Using offset parameter:
88-
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] );
89-
> {{alias}}.ndarray( 3, x, 2, 1 )
88+
> var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] );
89+
> {{alias}}.ndarray( 4, x, 2, 1 )
9090
~-0.3333
9191

9292
See Also

0 commit comments

Comments
 (0)