Skip to content

Commit 82d7cc6

Browse files
committed
Refactor use of Array constructor
1 parent 0ad9b6f commit 82d7cc6

File tree

48 files changed

+104
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+104
-88
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
2424
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var Float64Array = require( '@stdlib/array/float64' );
2627

2728

2829
// MAIN //
@@ -213,7 +214,7 @@ function incrmcovariance( W, meanx, meany ) {
213214
if ( !isPositiveInteger( W ) ) {
214215
throw new TypeError( 'invalid argument. First argument must be a positive integer. Value: `' + W + '`.' );
215216
}
216-
buf = new Array( 2*W ); // strided array
217+
buf = new Float64Array( 2*W ); // strided array
217218
n = W - 1;
218219
C = 0.0;
219220
wi = -1;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimit
2424
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var sqrt = require( '@stdlib/math/base/special/sqrt' );
27+
var Float64Array = require( '@stdlib/array/float64' );
2728

2829

2930
// MAIN //
@@ -144,7 +145,7 @@ function incrmcv( W, mean ) {
144145
if ( !isPositiveInteger( W ) ) {
145146
throw new TypeError( 'invalid argument. Must provide a positive integer. Value: `' + W + '`.' );
146147
}
147-
buf = new Array( W );
148+
buf = new Float64Array( W );
148149
n = W - 1;
149150
M2 = 0.0;
150151
i = -1;

lib/node_modules/@stdlib/stats/incr/meanstdev/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import incrmeanstdev = require( './index' );
2424
// The function returns an accumulator function...
2525
{
2626
incrmeanstdev(); // $ExpectType accumulator
27-
const out = new Array( 2 );
27+
const out = [ 0.0, 0.0 ];
2828
incrmeanstdev( out ); // $ExpectType accumulator
2929
}
3030

lib/node_modules/@stdlib/stats/incr/meanstdev/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ tape( 'the function returns an accumulator function', function test( t ) {
6868
});
6969

7070
tape( 'the function returns an accumulator function (output)', function test( t ) {
71-
t.equal( typeof incrmeanstdev( new Array( 2 ) ), 'function', 'returns a function' );
71+
t.equal( typeof incrmeanstdev( [ 0.0, 0.0 ] ), 'function', 'returns a function' );
7272
t.end();
7373
});
7474

lib/node_modules/@stdlib/stats/incr/meanvar/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import incrmeanvar = require( './index' );
2424
// The function returns an accumulator function...
2525
{
2626
incrmeanvar(); // $ExpectType accumulator
27-
const out = new Array( 2 );
27+
const out = [ 0.0, 0.0 ];
2828
incrmeanvar( out ); // $ExpectType accumulator
2929
}
3030

lib/node_modules/@stdlib/stats/incr/meanvar/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ tape( 'the function returns an accumulator function', function test( t ) {
6767
});
6868

6969
tape( 'the function returns an accumulator function (output)', function test( t ) {
70-
t.equal( typeof incrmeanvar( new Array( 2 ) ), 'function', 'returns a function' );
70+
t.equal( typeof incrmeanvar( [ 0.0, 0.0 ] ), 'function', 'returns a function' );
7171
t.end();
7272
});
7373

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimit
2424
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2525
var ln = require( '@stdlib/math/base/special/ln' );
2626
var exp = require( '@stdlib/math/base/special/exp' );
27+
var Float64Array = require( '@stdlib/array/float64' );
2728

2829

2930
// MAIN //
@@ -65,7 +66,7 @@ function incrmgmean( W ) {
6566
if ( !isPositiveInteger( W ) ) {
6667
throw new TypeError( 'invalid argument. Must provide a positive integer. Value: `' + W + '`.' );
6768
}
68-
buf = new Array( W );
69+
buf = new Float64Array( W );
6970
sum = 0.0;
7071
i = -1;
7172
N = 0;

lib/node_modules/@stdlib/stats/incr/mgmean/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ tape( 'the accumulator function computes a moving geometric mean incrementally',
8585

8686
acc = incrmgmean( 3 );
8787

88-
actual = new Array( N );
88+
actual = [];
8989
for ( i = 0; i < N; i++ ) {
90-
actual[ i ] = acc( data[ i ] );
90+
actual.push( acc( data[ i ] ) );
9191
}
9292
// Note: computed by hand using textbook formula:
9393
expected = [

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var max = require( '@stdlib/math/base/special/max' );
3131
var sqrt = require( '@stdlib/math/base/special/sqrt' );
3232
var roundn = require( '@stdlib/math/base/special/roundn' );
3333
var tQuantile = require( '@stdlib/stats/base/dists/t/quantile' );
34+
var Float64Array = require( '@stdlib/array/float64' );
3435
var validate = require( './validate.js' );
3536
var defaults = require( './defaults.json' );
3637
var incrmminmax = require( './minmax.js' );
@@ -96,7 +97,7 @@ function incrmgrubbs( W ) {
9697
throw err;
9798
}
9899
}
99-
buf = new Array( W );
100+
buf = new Float64Array( W );
100101
df = W - 2;
101102
gc = 0.0;
102103
G = 0.0;

lib/node_modules/@stdlib/stats/incr/mhmean/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ tape( 'the accumulator function computes a moving harmonic mean incrementally',
8585

8686
acc = incrmhmean( 3 );
8787

88-
actual = new Array( N );
88+
actual = [];
8989
for ( i = 0; i < N; i++ ) {
90-
actual[ i ] = acc( data[ i ] );
90+
actual.push( acc( data[ i ] ) );
9191
}
9292
// Note: computed by hand using textbook formula:
9393
expected = [

0 commit comments

Comments
 (0)