Skip to content

Commit e23686c

Browse files
committed
chore: fixed linting and clean-up
1 parent d32eca9 commit e23686c

File tree

8 files changed

+22
-37
lines changed

8 files changed

+22
-37
lines changed

lib/node_modules/@stdlib/stats/incr/nanpcorr/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
99
You may obtain a copy of the License at
1010
11-
http://www.apache.org/licenses/LICENSE-2.0
11+
http://www.apache.org/licenses/LICENSE-2.0
1212
1313
Unless required by applicable law or agreed to in writing, software
1414
distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# incrnanpcorr
2222

23-
> Compute a [sample Pearson product-moment correlation coefficient][pearson-correlation] incrementally.
23+
> Compute a [sample Pearson product-moment correlation coefficient][pearson-correlation] incrementally, ignoring `NaN` values.
2424
2525
<section class="intro">
2626

@@ -70,7 +70,7 @@ var incrnanpcorr = require( '@stdlib/stats/incr/nanpcorr' );
7070

7171
#### incrnanpcorr( \[mx, my] )
7272

73-
Returns an accumulator `function` which incrementally computes a [sample Pearson product-moment correlation coefficient][pearson-correlation].
73+
Returns an accumulator function which incrementally computes a [sample Pearson product-moment correlation coefficient][pearson-correlation], ignoring `NaN` values.
7474

7575
```javascript
7676
var accumulator = incrnanpcorr();
@@ -92,7 +92,7 @@ var accumulator = incrnanpcorr();
9292
var v = accumulator( 2.0, 1.0 );
9393
// returns 0.0
9494

95-
var v = accumulator( NaN, 1.0 );
95+
v = accumulator( NaN, 1.0 );
9696
// returns 0.0
9797

9898
v = accumulator( 1.0, -5.0 );
@@ -116,7 +116,7 @@ v = accumulator();
116116

117117
## Notes
118118

119-
- Input values are **not** type checked. If provided `NaN` or a value which, when used in computations, results in `NaN`, it will be ignored but you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
119+
- Input values are **not** type checked. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
120120

121121
</section>
122122

@@ -130,8 +130,8 @@ v = accumulator();
130130

131131
```javascript
132132
var randu = require( '@stdlib/random/base/randu' );
133-
var incrnanpcorr = require( './../lib' );
134133
var isnan = require( '@stdlib/math/base/assert/is-nan' );
134+
var incrnanpcorr = require( '@stdlib/stats/incr/nanpcorr' );
135135

136136
var accumulator;
137137
var r;
@@ -145,8 +145,8 @@ accumulator = incrnanpcorr();
145145
// For each simulated datum, update the sample Pearson correlation coefficient...
146146
console.log( '\nx\ty\tCorrelation Coefficient\n' );
147147
for ( i = 0; i < 100; i++ ) {
148-
x = (randu() < 0.2) ? NaN : randu()*100.0; // ~20% NaN values assigned to `x`
149-
y = (randu() < 0.2) ? NaN : randu()*100.0; // ~20% NaN values assigned to `y`
148+
x = ( randu() < 0.2 ) ? NaN : randu()*100.0; // ~20% NaN values assigned to `x`
149+
y = ( randu() < 0.2 ) ? NaN : randu()*100.0; // ~20% NaN values assigned to `y`
150150
r = accumulator( x, y );
151151
}
152152
console.log( accumulator() );

lib/node_modules/@stdlib/stats/incr/nanpcorr/benchmark/benchmark.js

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

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
2524
var pkg = require( './../package.json' ).name;
2625
var incrnanpcorr = require( './../lib' );
2726

@@ -55,7 +54,7 @@ bench( pkg+'::accumulator', function benchmark( b ) {
5554

5655
b.tic();
5756
for ( i = 0; i < b.iterations; i++ ) {
58-
v = acc( randu(), randu() );
57+
v = acc( i, i );
5958
if ( v !== v ) {
6059
b.fail( 'should not return NaN' );
6160
}
@@ -77,7 +76,7 @@ bench( pkg+'::accumulator,known_means', function benchmark( b ) {
7776

7877
b.tic();
7978
for ( i = 0; i < b.iterations; i++ ) {
80-
v = acc( randu(), randu() );
79+
v = acc( i, i );
8180
if ( v !== v ) {
8281
b.fail( 'should not return NaN' );
8382
}

lib/node_modules/@stdlib/stats/incr/nanpcorr/docs/repl.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11

22
{{alias}}( [mx, my] )
33
Returns an accumulator function which incrementally computes a sample
4-
Pearson product-moment correlation coefficient.
4+
Pearson product-moment correlation coefficient, ignoring `NaN` values.
55

66
If provided values, the accumulator function returns an updated sample
77
correlation coefficient. If not provided values, the accumulator function
88
returns the current sample correlation coefficient.
99

10-
If provided `NaN` or a value which, when used in computations, results in
11-
`NaN`, it will be ignored by the accumulator.
12-
1310
Parameters
1411
----------
1512
mx: number (optional)

lib/node_modules/@stdlib/stats/incr/nanpcorr/docs/types/index.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@
2323
/**
2424
* If provided arguments, returns an updated sample correlation coefficient.
2525
*
26-
* ## Notes
27-
*
28-
* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations.
29-
*
3026
* @param x - value
3127
* @param y - value
3228
* @returns updated sample correlation coefficient
3329
*/
3430
type accumulator = ( x?: number, y?: number ) => number | null;
3531

3632
/**
37-
* Returns an accumulator function which incrementally computes an updated sample correlation coefficient.
33+
* Returns an accumulator function which incrementally computes an updated sample correlation coefficient, ignoring `NaN` values.
3834
*
3935
* @param meanx - mean value
4036
* @param meany - mean value
@@ -46,7 +42,7 @@ type accumulator = ( x?: number, y?: number ) => number | null;
4642
declare function incrnanpcorr( meanx: number, meany: number ): accumulator;
4743

4844
/**
49-
* Returns an accumulator function which incrementally computes an updated sample correlation coefficient.
45+
* Returns an accumulator function which incrementally computes an updated sample correlation coefficient, ignoring `NaN` values.
5046
*
5147
* @returns accumulator function
5248
*

lib/node_modules/@stdlib/stats/incr/nanpcorr/examples/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
'use strict';
2020

2121
var randu = require( '@stdlib/random/base/randu' );
22-
var incrnanpcorr = require( './../lib' );
2322
var isnan = require( '@stdlib/math/base/assert/is-nan' );
23+
var incrnanpcorr = require( './../lib' );
2424

2525
var accumulator;
2626
var r;
@@ -34,9 +34,9 @@ accumulator = incrnanpcorr();
3434
// For each simulated datum, update the sample Pearson correlation coefficient...
3535
console.log( '\nx\ty\tCorrelation Coefficient\n' );
3636
for ( i = 0; i < 100; i++ ) {
37-
x = (randu() < 0.2) ? NaN : randu()*100.0; // ~20% NaN values assigned to `x`
38-
y = (randu() < 0.2) ? NaN : randu()*100.0; // ~20% NaN values assigned to `y`
37+
x = ( randu() < 0.2 ) ? NaN : randu() * 100.0; // ~20% NaN values assigned to `x`
38+
y = ( randu() < 0.2 ) ? NaN : randu() * 100.0; // ~20% NaN values assigned to `y`
3939
r = accumulator( x, y );
40-
console.log( '%d\t%d\t%d', isnan(x) ? 'NaN' : x.toFixed( 4 ), isnan(y) ? 'NaN' : y.toFixed( 4 ), r.toFixed( 4 ) );
40+
console.log( '%d\t%d\t%d', ( isnan(x) ) ? 'NaN' : x.toFixed( 4 ), ( isnan(y) ) ? 'NaN' : y.toFixed( 4 ), r.toFixed( 4 ) );
4141
}
4242
console.log( '\nFinal r: %d\n', accumulator() );

lib/node_modules/@stdlib/stats/incr/nanpcorr/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Compute a sample Pearson product-moment correlation coefficient incrementally, ignpring `NaN` value.
22+
* Compute a sample Pearson product-moment correlation coefficient incrementally, ignoring `NaN` values.
2323
*
2424
* @module @stdlib/stats/incr/nanpcorr
2525
*

lib/node_modules/@stdlib/stats/incr/nanpcorr/lib/main.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020

2121
// MODULES //
2222

23-
var isNumber = require( '@stdlib/assert/is-number' );
2423
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2524
var incrpcorr = require( '@stdlib/stats/incr/pcorr' );
2625

2726

2827
// MAIN //
2928

3029
/**
31-
* Returns an accumulator function which incrementally computes a sample Pearson product-moment correlation coefficient, ignoring `NaN` value.
30+
* Returns an accumulator function which incrementally computes a sample Pearson product-moment correlation coefficient, ignoring `NaN` values.
3231
*
3332
* ## Method
3433
*
@@ -168,12 +167,6 @@ function incrnanpcorr( meanx, meany ) {
168167
var N;
169168

170169
if ( arguments.length ) {
171-
if ( !isNumber( meanx ) ) {
172-
throw new TypeError( 'invalid argument. First argument must be a number. Value: `' + meanx + '`.' );
173-
}
174-
if ( !isNumber( meany ) ) {
175-
throw new TypeError( 'invalid argument. Second argument must be a number. Value: `' + meany + '`.' );
176-
}
177170
pcorr = incrpcorr( meanx, meany );
178171
} else {
179172
pcorr = incrpcorr();
@@ -196,10 +189,10 @@ function incrnanpcorr( meanx, meany ) {
196189
if ( N === 0 ) {
197190
return null;
198191
}
199-
return pcorr(); // Return the current correlation
192+
return pcorr();
200193
}
201194
if ( isnan( x ) || isnan( y ) ) {
202-
return pcorr(); // Ignore NaN values
195+
return pcorr();
203196
}
204197
N += 1;
205198
return pcorr( x, y );

lib/node_modules/@stdlib/stats/incr/nanpcorr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/stats/incr/nanpcorr",
33
"version": "0.0.0",
4-
"description": "Compute a sample Pearson product-moment correlation coefficient.",
4+
"description": "Compute a sample Pearson product-moment correlation coefficient, ignoring `NaN` values.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

0 commit comments

Comments
 (0)