Skip to content

Commit a275e39

Browse files
committed
chore: clean-up
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 209093d commit a275e39

File tree

7 files changed

+524
-50
lines changed

7 files changed

+524
-50
lines changed

lib/node_modules/@stdlib/ndarray/any-by/docs/repl.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
{{alias}}( x[, options], predicate[, thisArg] )
23
Tests whether at least one element along one or more ndarray dimensions
34
passes a test implemented by a predicate function.
@@ -11,7 +12,9 @@
1112
Function options.
1213

1314
options.dims: Array<integer> (optional)
14-
List of dimensions over which to perform a reduction. Default: null.
15+
List of dimensions over which to perform a reduction. If not provided,
16+
the function performs a reduction over all elements in a provided input
17+
ndarray.
1518

1619
options.keepdims: boolean (optional)
1720
Boolean indicating whether the reduced dimensions should be included in
@@ -26,7 +29,8 @@
2629
Returns
2730
-------
2831
out: ndarray
29-
Output ndarray.
32+
Output ndarray. When performing a reduction over all elements, the
33+
function returns a zero-dimensional ndarray containing the result.
3034

3135
Examples
3236
--------
@@ -41,7 +45,7 @@
4145

4246
{{alias}}.assign( x, y[, options], predicate[, thisArg] )
4347
Tests whether at least one element along one or more ndarray dimensions
44-
passes a test implemented by a predicate function and assigns the result to
48+
passes a test implemented by a predicate function and assigns the results to
4549
a provided output ndarray.
4650

4751
Parameters
@@ -50,13 +54,16 @@
5054
Input ndarray.
5155

5256
y: ndarray
53-
Output ndarray.
57+
Output ndarray. The output shape must match the shape of the non-reduced
58+
dimensions of the input ndarray.
5459

5560
options: Object (optional)
5661
Function options.
5762

5863
options.dims: Array<integer> (optional)
59-
List of dimensions over which to perform a reduction. Default: null.
64+
List of dimensions over which to perform a reduction. If not provided,
65+
the function performs a reduction over all elements in a provided input
66+
ndarray.
6067

6168
predicate: Function
6269
Predicate function.

lib/node_modules/@stdlib/ndarray/any-by/docs/types/index.d.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
import { ArrayLike } from '@stdlib/types/array';
2424
import { ndarray, boolndarray, typedndarray } from '@stdlib/types/ndarray';
2525

26+
/**
27+
* Input array.
28+
*/
29+
type InputArray<T> = typedndarray<T>;
30+
2631
/**
2732
* Returns a boolean indicating whether an element passes a test.
2833
*
@@ -55,7 +60,7 @@ type Binary<T, ThisArg> = ( this: ThisArg, value: T, indices: Array<number> ) =>
5560
* @param arr - input array
5661
* @returns boolean indicating whether an ndarray element passes a test
5762
*/
58-
type Ternary<T, ThisArg> = ( this: ThisArg, value: T, indices: Array<number>, arr: typedndarray<T> ) => boolean;
63+
type Ternary<T, U, ThisArg> = ( this: ThisArg, value: T, indices: Array<number>, arr: U ) => boolean;
5964

6065
/**
6166
* Returns a boolean indicating whether an element passes a test.
@@ -65,7 +70,7 @@ type Ternary<T, ThisArg> = ( this: ThisArg, value: T, indices: Array<number>, ar
6570
* @param arr - input array
6671
* @returns boolean indicating whether an ndarray element passes a test
6772
*/
68-
type Predicate<T, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, ThisArg>;
73+
type Predicate<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, U, ThisArg>;
6974

7075
/**
7176
* Base options.
@@ -129,7 +134,7 @@ interface AnyBy {
129134
* var v = out.get();
130135
* // returns true
131136
*/
132-
<T = unknown, U = unknown>( x: ndarray, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolndarray;
137+
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
133138

134139
/**
135140
* Tests whether at least one element along one or more ndarray dimensions passes a test implemented by a predicate function.
@@ -172,7 +177,7 @@ interface AnyBy {
172177
* var v = out.get();
173178
* // returns true
174179
*/
175-
<T = unknown, U = unknown>( x: ndarray, options: Options, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolndarray;
180+
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
176181

177182
/**
178183
* Tests whether at least one element along one or more ndarray dimensions passes a test implemented by a predicate function.
@@ -219,7 +224,7 @@ interface AnyBy {
219224
* var v = out.get();
220225
* // returns true
221226
*/
222-
assign<T = unknown, U extends ndarray = ndarray, V = unknown>( x: ndarray, y: U, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;
227+
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: U, y: V, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
223228

224229
/**
225230
* Tests whether at least one element along one or more ndarray dimensions passes a test implemented by a predicate function.
@@ -268,7 +273,7 @@ interface AnyBy {
268273
* var v = out.get();
269274
* // returns true
270275
*/
271-
assign<T = unknown, U extends ndarray = ndarray, V = unknown>( x: ndarray, y: U, options: BaseOptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;
276+
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: U, y: V, options: BaseOptions, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
272277
}
273278

274279
/**

lib/node_modules/@stdlib/ndarray/any-by/docs/types/test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19+
/* eslint-disable space-in-parens */
20+
1921
import zeros = require( '@stdlib/ndarray/zeros' );
2022
import empty = require( '@stdlib/ndarray/empty' );
2123
import anyBy = require( './index' );
@@ -161,15 +163,7 @@ function clbk( value: number ): boolean {
161163
const x = zeros( [ 2, 2 ] );
162164
const y = empty( [], {
163165
'dtype': 'bool'
164-
} );
165-
166-
anyBy.assign( x, y, clbk ); // $ExpectType boolndarray
167-
anyBy.assign( x, y, {}, clbk ); // $ExpectType boolndarray
168-
anyBy.assign( x, y, { 'dims': [ 0 ] }, clbk ); // $ExpectType boolndarray
169-
170-
anyBy.assign( x, y, clbk, {} ); // $ExpectType boolndarray
171-
anyBy.assign( x, y, {}, clbk, {} ); // $ExpectType boolndarray
172-
anyBy.assign( x, y, { 'dims': [ 0 ] }, clbk, {} ); // $ExpectType boolndarray
166+
});
173167

174168
anyBy.assign( x, y, clbk ); // $ExpectType boolndarray
175169
anyBy.assign( x, y, {}, clbk ); // $ExpectType boolndarray
@@ -184,7 +178,7 @@ function clbk( value: number ): boolean {
184178
{
185179
const y = empty( [], {
186180
'dtype': 'bool'
187-
} );
181+
});
188182

189183
anyBy.assign( 5, y, clbk ); // $ExpectError
190184
anyBy.assign( true, y, clbk ); // $ExpectError
@@ -223,7 +217,7 @@ function clbk( value: number ): boolean {
223217
anyBy.assign( ( x: number ): number => x, y, {}, clbk, {} ); // $ExpectError
224218
}
225219

226-
// The compiler throws an error if the `assign` method is provided an output argument which is not an ndarray...
220+
// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray...
227221
{
228222
const x = zeros( [ 2, 2 ] );
229223

@@ -269,7 +263,7 @@ function clbk( value: number ): boolean {
269263
const x = zeros( [ 2, 2 ] );
270264
const y = empty( [], {
271265
'dtype': 'bool'
272-
} );
266+
});
273267

274268
anyBy.assign( x, y, '5', clbk ); // $ExpectError
275269
anyBy.assign( x, y, 5, clbk ); // $ExpectError
@@ -293,7 +287,7 @@ function clbk( value: number ): boolean {
293287
const x = zeros( [ 2, 2 ] );
294288
const y = empty( [], {
295289
'dtype': 'int32'
296-
} );
290+
});
297291

298292
anyBy.assign( x, y, '5' ); // $ExpectError
299293
anyBy.assign( x, y, 5 ); // $ExpectError
@@ -333,7 +327,7 @@ function clbk( value: number ): boolean {
333327
const x = zeros( [ 2, 2 ] );
334328
const y = empty( [], {
335329
'dtype': 'bool'
336-
} );
330+
});
337331

338332
anyBy.assign( x, y, { 'dims': '5' }, clbk ); // $ExpectError
339333
anyBy.assign( x, y, { 'dims': 5 }, clbk ); // $ExpectError
@@ -357,7 +351,7 @@ function clbk( value: number ): boolean {
357351
const x = zeros( [ 2, 2 ] );
358352
const y = empty( [], {
359353
'dtype': 'bool'
360-
} );
354+
});
361355

362356
anyBy.assign(); // $ExpectError
363357
anyBy.assign( x ); // $ExpectError

lib/node_modules/@stdlib/ndarray/any-by/lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var validate = require( './validate.js' );
5757
* @throws {TypeError} options argument must be an object
5858
* @throws {TypeError} callback argument must be a function
5959
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
60-
* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
60+
* @throws {Error} dimension indices must be unique
6161
* @throws {Error} must provide valid options
6262
* @returns {ndarray} output ndarray
6363
*

lib/node_modules/@stdlib/ndarray/any-by/lib/validate.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ function validate( opts, ndims, options ) {
7676
if ( tmp.length !== opts.dims.length ) {
7777
return new Error( format( 'invalid option. `%s` option contains duplicate indices. Option: [%s].', 'dims', join( opts.dims, ',' ) ) );
7878
}
79-
if ( tmp.length > ndims ) {
80-
return new RangeError( format( 'invalid option. `%s` option specifies more dimensions than exists in the input array. Number of dimensions: %d. Option: [%s].', 'dims', ndims, join( opts.dims, ',' ) ) );
81-
}
8279
opts.dims = tmp;
8380
}
8481
return null;

0 commit comments

Comments
 (0)