Skip to content

Commit 2848c77

Browse files
committed
fix: improve type specificity, remove unreachable path, and fix docs
--- 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8f581f1 commit 2848c77

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
predicate: Function
2929
Predicate function.
3030

31-
thisArg: Any (optional)
31+
thisArg: any (optional)
3232
Predicate execution context.
3333

3434
Returns
@@ -55,7 +55,8 @@
5555

5656
{{alias}}.assign( x, n, y[, options], predicate[, thisArg] )
5757
Tests whether at least `n` elements along one or more ndarray dimensions
58-
pass a test implemented by a predicate function.
58+
pass a test implemented by a predicate function and assigns the results to
59+
a provided output ndarray.
5960

6061
Parameters
6162
----------
@@ -79,14 +80,10 @@
7980
the function performs a reduction over all elements in a provided input
8081
ndarray.
8182

82-
options.keepdims: boolean (optional)
83-
Boolean indicating whether the reduced dimensions should be included in
84-
the returned ndarray as singleton dimensions. Default: false.
85-
8683
predicate: Function
8784
Predicate function.
8885

89-
thisArg: Any (optional)
86+
thisArg: any (optional)
9087
Predicate execution context.
9188

9289
Returns

lib/node_modules/@stdlib/ndarray/some-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, integerndarray, 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.
@@ -127,7 +132,7 @@ interface SomeBy {
127132
* var v = out.get();
128133
* // returns true
129134
*/
130-
<T = unknown, U = unknown>( x: ndarray, n: integerndarray | number, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolndarray;
135+
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, n: integerndarray | number, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
131136

132137
/**
133138
* Tests whether at least `n` elements along one or more ndarray dimensions pass a test implemented by a predicate function.
@@ -168,7 +173,7 @@ interface SomeBy {
168173
* var v = out.get();
169174
* // returns true
170175
*/
171-
<T = unknown, U = unknown>( x: ndarray, n: integerndarray | number, options: Options, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolndarray;
176+
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, n: integerndarray | number, options: Options, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): boolndarray;
172177

173178
/**
174179
* Tests whether at least `n` elements along one or more ndarray dimensions pass a test implemented by a predicate function.
@@ -213,7 +218,7 @@ interface SomeBy {
213218
* var v = out.get();
214219
* // returns true
215220
*/
216-
assign<T = unknown, U extends ndarray = ndarray, V = unknown>( x: ndarray, n: integerndarray | number, y: U, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;
221+
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: ndarray, n: integerndarray | number, y: V, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
217222

218223
/**
219224
* Tests whether at least `n` elements along one or more ndarray dimensions pass a test implemented by a predicate function.
@@ -260,7 +265,7 @@ interface SomeBy {
260265
* var v = out.get();
261266
* // returns true
262267
*/
263-
assign<T = unknown, U extends ndarray = ndarray, V = unknown>( x: ndarray, n: integerndarray | number, y: U, options: BaseOptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;
268+
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends ndarray = ndarray, ThisArg = unknown>( x: ndarray, n: integerndarray | number, y: V, options: BaseOptions, predicate: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
264269
}
265270

266271
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var DEFAULT_DTYPE = defaults.get( 'dtypes.integer_index' );
7070
* @throws {TypeError} options argument must be an object
7171
* @throws {TypeError} callback argument must be a function
7272
* @throws {RangeError} dimension indices must not exceed input ndarray bounds
73-
* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
73+
* @throws {Error} dimension indices must be unique
7474
* @throws {Error} must provide valid options
7575
* @returns {ndarray} output ndarray
7676
*

lib/node_modules/@stdlib/ndarray/some-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)