Skip to content

Commit 42a1a4d

Browse files
committed
Auto-generated commit
1 parent 0582c74 commit 42a1a4d

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -38559,6 +38559,10 @@ A total of 50 people contributed to this release. Thank you to the following con
3855938559

3856038560
<details>
3856138561

38562+
- [`6dc5ea7`](https://github.com/stdlib-js/stdlib/commit/6dc5ea77dbef23e522255c7c60e5db1ccfa85568) - **refactor:** use base array assertion utility _(by Athan Reines)_
38563+
- [`87d73e7`](https://github.com/stdlib-js/stdlib/commit/87d73e766f9238784e96d9a7a78cec726b9b718b) - **refactor:** use base array assertion utility _(by Athan Reines)_
38564+
- [`22e382b`](https://github.com/stdlib-js/stdlib/commit/22e382b0c5829205f4319aa82140efb39e3b1ad8) - **style:** resolve lint errors _(by Athan Reines)_
38565+
- [`ebb7d9d`](https://github.com/stdlib-js/stdlib/commit/ebb7d9dadfb327239bb796b6177f91b8cc60b7d8) - **style:** resolve lint error _(by Athan Reines)_
3856238566
- [`2366870`](https://github.com/stdlib-js/stdlib/commit/23668709f2da0d4a3e3f5eb401eebaf03eb328cd) - **refactor:** use const double for parameter in `stats/base/dists/betaprime/logpdf` [(#6452)](https://github.com/stdlib-js/stdlib/pull/6452) _(by Neeraj Pathak)_
3856338567
- [`3aca840`](https://github.com/stdlib-js/stdlib/commit/3aca840adab39372b0b641f9bf99e0b192e6150a) - **remove:** remove `stats/base/smidrange` _(by Aayush Khanna)_
3856438568
- [`c1d3885`](https://github.com/stdlib-js/stdlib/commit/c1d3885204c3351bc3298b2f7c18b4003ae060df) - **refactor:** update paths _(by Aayush Khanna)_

ranks/lib/is_missing.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
'use strict';
2020

21-
// FUNCTIONS //
21+
// MODULES //
2222

2323
var contains = require( '@stdlib/assert/contains' );
24+
var filled = require( '@stdlib/array/base/filled' );
2425

2526

2627
// MAIN //
@@ -39,7 +40,7 @@ function isMissing( arr, encoding ) {
3940
var i;
4041

4142
len = arr.length;
42-
out = new Array( len );
43+
out = filled( false, len );
4344
for ( i = 0; i < len; i++ ) {
4445
out[ i ] = contains( encoding, arr[ i ] );
4546
}

ranks/lib/main.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
var isCollection = require( '@stdlib/assert/is-collection' );
2424
var contains = require( '@stdlib/assert/contains' );
25+
var zeros = require( '@stdlib/array/base/zeros' );
2526
var format = require( '@stdlib/string/format' );
2627
var sum = require( './sum.js' );
2728
var order = require( './order.js' );
@@ -105,9 +106,9 @@ function ranks( x, options ) {
105106
missingIndices = isMissing( x, encoding );
106107
n = xnew.length;
107108
totalNoTies = 0;
108-
ranks = new Array( n );
109109
ordered = order( xnew );
110110

111+
ranks = zeros( n );
111112
if ( method === 'ordinal' ) {
112113
for ( i = 0; i < n; i++ ) {
113114
ranks[ ordered[ i ] ] = i + 1;
@@ -149,24 +150,24 @@ function ranks( x, options ) {
149150
if ( missing === 'first' ) {
150151
countMissing = sum( missingIndices );
151152
j = 1;
152-
finalRanks = new Array( missingIndices.length );
153+
finalRanks = [];
153154
for ( i = 0; i < missingIndices.length; i++ ) {
154155
if ( missingIndices[ i ] ) {
155-
finalRanks[ i ] = j;
156+
finalRanks.push( j );
156157
j += 1;
157158
} else {
158-
finalRanks[ i ] = ranks.shift() + countMissing;
159+
finalRanks.push( ranks.shift() + countMissing );
159160
}
160161
}
161162
return finalRanks;
162163
}
163164
if ( missing === 'last' ) {
164-
finalRanks = new Array( missingIndices.length );
165+
finalRanks = [];
165166
for ( i = 0; i < missingIndices.length; i++ ) {
166167
if ( missingIndices[ i ] ) {
167-
finalRanks[ i ] = i + ranks.length + 1;
168+
finalRanks.push( i + ranks.length + 1 );
168169
} else {
169-
finalRanks[ i ] = ranks.shift();
170+
finalRanks.push( ranks.shift() );
170171
}
171172
}
172173
return finalRanks;

ranks/lib/validate.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var contains = require( '@stdlib/assert/contains' );
23+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2424
var isArray = require( '@stdlib/assert/is-array' );
2525
var isObject = require( '@stdlib/assert/is-object' );
2626
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
@@ -33,6 +33,9 @@ var format = require( '@stdlib/string/format' );
3333
var METHODS = [ 'min', 'max', 'average', 'dense', 'ordinal' ];
3434
var MISSING = [ 'last', 'first', 'remove' ];
3535

36+
var isMethod = contains( METHODS );
37+
var isMissing = contains( MISSING );
38+
3639

3740
// MAIN //
3841

@@ -59,13 +62,13 @@ function validate( opts, options ) {
5962
}
6063
if ( hasOwnProp( options, 'method' ) ) {
6164
opts.method = options.method;
62-
if ( !isString( opts.method ) || !contains( METHODS, opts.method ) ) {
65+
if ( !isString( opts.method ) || !isMethod( opts.method ) ) {
6366
return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'method', METHODS.join( '", "' ), opts.method ) );
6467
}
6568
}
6669
if ( hasOwnProp( options, 'missing' ) ) {
6770
opts.missing = options.missing;
68-
if ( !isString( opts.missing ) || !contains( MISSING, opts.missing ) ) {
71+
if ( !isString( opts.missing ) || !isMissing( opts.missing ) ) {
6972
return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'missing', MISSING.join( '", "' ), opts.missing ) );
7073
}
7174
}

wilcoxon/lib/validate.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var contains = require( '@stdlib/assert/contains' );
23+
var contains = require( '@stdlib/array/base/assert/contains' ).factory;
2424
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
2525
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2626
var isObject = require( '@stdlib/assert/is-plain-object' );
@@ -35,6 +35,9 @@ var format = require( '@stdlib/string/format' );
3535
var ALTERNATIVE_VALUES = [ 'two-sided', 'less', 'greater' ];
3636
var ZERO_METHOD_VALUES = [ 'pratt', 'wilcox', 'zsplit' ];
3737

38+
var isAlternativeValue = contains( ALTERNATIVE_VALUES );
39+
var isZeroMethod = contains( ZERO_METHOD_VALUES );
40+
3841

3942
// MAIN //
4043

@@ -70,7 +73,7 @@ function validate( opts, options ) {
7073
if ( !isString( opts.alternative ) ) {
7174
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'alternative', opts.alternative ) );
7275
}
73-
if ( !contains( ALTERNATIVE_VALUES, opts.alternative ) ) {
76+
if ( !isAlternativeValue( opts.alternative ) ) {
7477
return new Error( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'alternative', ALTERNATIVE_VALUES.join( '", "' ), opts.alternative ) );
7578
}
7679
}
@@ -100,7 +103,7 @@ function validate( opts, options ) {
100103
if ( !isString( opts.zeroMethod ) ) {
101104
return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'zeroMethod', opts.alternative ) );
102105
}
103-
if ( !contains( ZERO_METHOD_VALUES, opts.zeroMethod ) ) {
106+
if ( !isZeroMethod( opts.zeroMethod ) ) {
104107
return new Error( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'zeroMethod', ZERO_METHOD_VALUES.join( '", "' ), opts.zeroMethod ) );
105108
}
106109
}

0 commit comments

Comments
 (0)