Skip to content

Commit 86b7c4b

Browse files
committed
refactor: refactor & cleanup
--- 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: na - 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: passed - task: lint_license_headers status: passed ---
1 parent 22dbb6f commit 86b7c4b

File tree

3 files changed

+33
-108
lines changed

3 files changed

+33
-108
lines changed

lib/node_modules/@stdlib/blas/ext/index-of/docs/repl.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
x: ndarray
99
Input array.
1010

11-
searchElement: ndarray|number|ComplexLike
11+
searchElement: ndarray|*
1212
Element in an input ndarray for which to find an index. May be either a
1313
scalar value or an ndarray having a data type same as the data type of
1414
the input ndarray. If provided a scalar value, the value is cast to the
@@ -20,24 +20,24 @@
2020
when performing the operation over all elements in a provided input
2121
ndarray, a search element ndarray must be a zero-dimensional ndarray.
2222

23-
fromIndex: ndarray|number (optional)
23+
fromIndex: ndarray|integer (optional)
2424
Index from which to begin searching. May be either a scalar value or an
25-
ndarray having an `int32` or `generic` data type. If provided an ndarray
26-
the value must have a shape which is broadcast compatible with the
27-
complement of the shape defined by `options.dims`. For example, given
28-
the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray
25+
ndarray having an `integer` or `generic` data type. If provided an
26+
ndarray the value must have a shape which is broadcast compatible with
27+
the complement of the shape defined by `options.dims`. For example,
28+
given the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray
2929
containing the index from which to begin searching must have a shape
3030
which is broadcast-compatible with the shape `[3, 4]`. Similarly
3131
when performing the operation over all elements in a provided input
3232
ndarray, an ndarray containing the index from which to begin searching
33-
must be a zero-dimensional ndarray. By default, the the index from which
34-
to begin searching is `0`.
33+
must be a zero-dimensional ndarray. By default, the value of the index
34+
from which to begin searching is `0`.
3535

3636
options: Object (optional)
3737
Function options.
3838

3939
options.dtype: string (optional)
40-
Output array data type. Must be a "integer_index" data type.
40+
Output array data type. Must be a "integer_index_and_generic" data type.
4141

4242
options.dims: Array<integer> (optional)
4343
List of dimensions over which to perform a reduction. If not provided,
@@ -70,7 +70,7 @@
7070
x: ndarray
7171
Input array.
7272

73-
searchElement: ndarray|number|ComplexLike
73+
searchElement: ndarray|*
7474
Element in an input ndarray for which to find an index. May be either a
7575
scalar value or an ndarray having a data type same as the data type of
7676
the input ndarray. If provided a scalar value, the value is cast to the
@@ -82,18 +82,18 @@
8282
when performing the operation over all elements in a provided input
8383
ndarray, a search element ndarray must be a zero-dimensional ndarray.
8484

85-
fromIndex: ndarray|number (optional)
85+
fromIndex: ndarray|integer (optional)
8686
Index from which to begin searching. May be either a scalar value or an
87-
ndarray having an `int32` or `generic` data type. If provided an ndarray
88-
the value must have a shape which is broadcast compatible with the
89-
complement of the shape defined by `options.dims`. For example, given
90-
the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray
87+
ndarray having an `integer` or `generic` data type. If provided an
88+
ndarray the value must have a shape which is broadcast compatible with
89+
the complement of the shape defined by `options.dims`. For example,
90+
given the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray
9191
containing the index from which to begin searching must have a shape
9292
which is broadcast-compatible with the shape `[3, 4]`. Similarly
9393
when performing the operation over all elements in a provided input
9494
ndarray, an ndarray containing the index from which to begin searching
95-
must be a zero-dimensional ndarray. By default, the the index from which
96-
to begin searching is `0`.
95+
must be a zero-dimensional ndarray. By default, the value of the index
96+
from which to begin searching is `0`.
9797

9898
out: ndarray
9999
Output array.

lib/node_modules/@stdlib/blas/ext/index-of/docs/types/index.d.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/// <reference types="@stdlib/types"/>
2222

2323
import { ArrayLike } from '@stdlib/types/array';
24-
import { IntegerAndGenericDataType as DataType, typedndarray } from '@stdlib/types/ndarray';
24+
import { IntegerIndexAndGenericDataType as DataType, typedndarray } from '@stdlib/types/ndarray';
2525

2626
/**
2727
* Input array.
@@ -36,12 +36,12 @@ type SearchElement<T> = typedndarray<T> | T;
3636
/**
3737
* From index.
3838
*/
39-
type FromIndex<U> = typedndarray<U> | U;
39+
type FromIndex = typedndarray<number> | number;
4040

4141
/**
4242
* Output array.
4343
*/
44-
type OutputArray<U> = typedndarray<U>;
44+
type OutputArray = typedndarray<number>;
4545

4646
/**
4747
* Interface defining "base" options.
@@ -82,7 +82,6 @@ interface IndexOf {
8282
* @returns output ndarray
8383
*
8484
* @example
85-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
8685
* var array = require( '@stdlib/ndarray/array' );
8786
*
8887
* var x = array( [ -1.0, 2.0, -3.0 ] );
@@ -93,7 +92,7 @@ interface IndexOf {
9392
* var idx = y.get();
9493
* // returns 1
9594
*/
96-
<T = unknown, U = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, options?: Options ): OutputArray<U>; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how `x` interacts with output data type policy and whether that policy has been overridden by `options.dtype`.
95+
<T = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, options?: Options ): OutputArray; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how `x` interacts with output data type policy and whether that policy has been overridden by `options.dtype`.
9796

9897
/**
9998
* Returns the first index of specified search element along one or more ndarray dimensions.
@@ -105,7 +104,6 @@ interface IndexOf {
105104
* @returns output ndarray
106105
*
107106
* @example
108-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
109107
* var array = require( '@stdlib/ndarray/array' );
110108
*
111109
* var x = array( [ -1.0, 2.0, -3.0, 2.0, -5.0, 6.0 ] );
@@ -116,7 +114,7 @@ interface IndexOf {
116114
* var idx = y.get();
117115
* // returns 3
118116
*/
119-
<T = unknown, U = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex<U>, options?: Options ): OutputArray<U>; // NOTE: we lose type specificity here, but retaining specificity would likely be difficult and/or tedious to completely enumerate, as the output ndarray data type is dependent on how `x` interacts with output data type policy and whether that policy has been overridden by `options.dtype`.
117+
<T = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex, options?: Options ): OutputArray;
120118

121119
/**
122120
* Returns the first index of a specified search element along one or more ndarray dimensions and assigns results to a provided output ndarray.
@@ -128,7 +126,6 @@ interface IndexOf {
128126
* @returns output ndarray
129127
*
130128
* @example
131-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
132129
* var zeros = require( '@stdlib/ndarray/zeros' );
133130
* var array = require( '@stdlib/ndarray/array' );
134131
*
@@ -146,7 +143,7 @@ interface IndexOf {
146143
* var idx = out.get();
147144
* // returns 1
148145
*/
149-
assign<T = unknown, U extends OutputArray<unknown> = OutputArray<unknown>>( x: InputArray<T>, searchElement: SearchElement<T>, out: U, options?: BaseOptions ): U;
146+
assign<T = unknown, U extends OutputArray = OutputArray>( x: InputArray<T>, searchElement: SearchElement<T>, out: U, options?: BaseOptions ): U;
150147

151148
/**
152149
* Returns the first index of a specified search element along one or more ndarray dimensions and assigns results to a provided output ndarray.
@@ -159,7 +156,6 @@ interface IndexOf {
159156
* @returns output ndarray
160157
*
161158
* @example
162-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
163159
* var zeros = require( '@stdlib/ndarray/zeros' );
164160
* var array = require( '@stdlib/ndarray/array' );
165161
*
@@ -177,7 +173,7 @@ interface IndexOf {
177173
* var idx = out.get();
178174
* // returns 3
179175
*/
180-
assign<T = unknown, U extends OutputArray<unknown> = OutputArray<unknown>, V = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex<V>, out: U, options?: BaseOptions ): U;
176+
assign<T = unknown, U extends OutputArray = OutputArray>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex, out: U, options?: BaseOptions ): U;
181177
}
182178

183179
/**

lib/node_modules/@stdlib/blas/ext/index-of/docs/types/test.ts

Lines changed: 9 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import indexOf = require( './index' );
3232
'dtype': 'float64'
3333
});
3434

35-
indexOf<number, number>( x, 0.0 ); // $ExpectType OutputArray<number>
36-
indexOf<number, number>( x, 0.0, 1 ); // $ExpectType OutputArray<number>
37-
indexOf<number, number>( x, 0.0, {} ); // $ExpectType OutputArray<number>
38-
indexOf<number, number>( x, 0.0, 1, {} ); // $ExpectType OutputArray<number>
35+
indexOf<number>( x, 0.0 ); // $ExpectType OutputArray
36+
indexOf<number>( x, 0.0, 1 ); // $ExpectType OutputArray
37+
indexOf<number>( x, 0.0, {} ); // $ExpectType OutputArray
38+
indexOf<number>( x, 0.0, 1, {} ); // $ExpectType OutputArray
3939
}
4040

4141
// The compiler throws an error if the function is provided a first argument which is not an ndarray...
@@ -108,7 +108,7 @@ import indexOf = require( './index' );
108108
indexOf( x, ( x: number ): number => x, 0, {} ); // $ExpectError
109109
}
110110

111-
// The compiler throws an error if the function is provided a from index argument which is not an ndarray or scalar value...
111+
// The compiler throws an error if the function is provided a from index argument which is not an ndarray or an integer value...
112112
{
113113
const x = zeros( [ 2, 2 ], {
114114
'dtype': 'float64'
@@ -216,8 +216,6 @@ import indexOf = require( './index' );
216216

217217
indexOf( x, 0.0, { 'keepdims': '5' } ); // $ExpectError
218218
indexOf( x, 0.0, { 'keepdims': 5 } ); // $ExpectError
219-
indexOf( x, 0.0, { 'keepdims': true } ); // $ExpectError
220-
indexOf( x, 0.0, { 'keepdims': false } ); // $ExpectError
221219
indexOf( x, 0.0, { 'keepdims': null } ); // $ExpectError
222220
indexOf( x, 0.0, { 'keepdims': {} } ); // $ExpectError
223221
indexOf( x, 0.0, { 'keepdims': ( x: number ): number => x } ); // $ExpectError
@@ -249,16 +247,13 @@ import indexOf = require( './index' );
249247
});
250248

251249
indexOf.assign( x, 0.0, y ); // $ExpectType int32ndarray
252-
indexOf.assign( x, 0.0, y, {} ); // $ExpectType in32ndarray
253-
indexOf.assign( x, 0.0, 1, y ); // $ExpectType in32ndarray
254-
indexOf.assign( x, 0.0, 1, y, {} ); // $ExpectType in32ndarray
250+
indexOf.assign( x, 0.0, y, {} ); // $ExpectType int32ndarray
251+
indexOf.assign( x, 0.0, 1, y ); // $ExpectType int32ndarray
252+
indexOf.assign( x, 0.0, 1, y, {} ); // $ExpectType int32ndarray
255253
}
256254

257255
// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray...
258256
{
259-
const x = zeros( [ 2, 2 ], {
260-
'dtype': 'float64'
261-
});
262257
const y = zeros( [], {
263258
'dtype': 'int32'
264259
});
@@ -310,43 +305,31 @@ import indexOf = require( './index' );
310305
});
311306

312307
indexOf.assign( x, '5', y ); // $ExpectError
313-
indexOf.assign( x, 5, y ); // $ExpectError
314308
indexOf.assign( x, true, y ); // $ExpectError
315309
indexOf.assign( x, false, y ); // $ExpectError
316-
indexOf.assign( x, null, y ); // $ExpectError
317-
indexOf.assign( x, void 0, y ); // $ExpectError
318310
indexOf.assign( x, {}, y ); // $ExpectError
319311
indexOf.assign( x, ( x: number ): number => x, y ); // $ExpectError
320312

321313
indexOf.assign( x, '5', 0, y ); // $ExpectError
322-
indexOf.assign( x, 5, 0, y ); // $ExpectError
323314
indexOf.assign( x, true, 0, y ); // $ExpectError
324315
indexOf.assign( x, false, 0, y ); // $ExpectError
325-
indexOf.assign( x, null, 0, y ); // $ExpectError
326-
indexOf.assign( x, void 0, 0, y ); // $ExpectError
327316
indexOf.assign( x, {}, 0, y ); // $ExpectError
328317
indexOf.assign( x, ( x: number ): number => x, 0, y ); // $ExpectError
329318

330319
indexOf.assign( x, '5', y, {} ); // $ExpectError
331-
indexOf.assign( x, 5, y, {} ); // $ExpectError
332320
indexOf.assign( x, true, y, {} ); // $ExpectError
333321
indexOf.assign( x, false, y, {} ); // $ExpectError
334-
indexOf.assign( x, null, y, {} ); // $ExpectError
335-
indexOf.assign( x, void 0, y, {} ); // $ExpectError
336322
indexOf.assign( x, {}, y, {} ); // $ExpectError
337323
indexOf.assign( x, ( x: number ): number => x, y, {} ); // $ExpectError
338324

339325
indexOf.assign( x, '5', 0, y, {} ); // $ExpectError
340-
indexOf.assign( x, 5, 0, y, {} ); // $ExpectError
341326
indexOf.assign( x, true, 0, y, {} ); // $ExpectError
342327
indexOf.assign( x, false, 0, y, {} ); // $ExpectError
343-
indexOf.assign( x, null, 0, y, {} ); // $ExpectError
344-
indexOf.assign( x, void 0, 0, y, {} ); // $ExpectError
345328
indexOf.assign( x, {}, 0, y, {} ); // $ExpectError
346329
indexOf.assign( x, ( x: number ): number => x, 0, y, {} ); // $ExpectError
347330
}
348331

349-
// The compiler throws an error if the `assign` method is provided a from index argument which is not an ndarray or scalar value...
332+
// The compiler throws an error if the `assign` method is provided a from index argument which is not an ndarray or an integer value...
350333
{
351334
const x = zeros( [ 2, 2 ], {
352335
'dtype': 'float64'
@@ -356,7 +339,6 @@ import indexOf = require( './index' );
356339
});
357340

358341
indexOf.assign( x, 0.0, '5', y ); // $ExpectError
359-
indexOf.assign( x, 0.0, 5, y ); // $ExpectError
360342
indexOf.assign( x, 0.0, true, y ); // $ExpectError
361343
indexOf.assign( x, 0.0, false, y ); // $ExpectError
362344
indexOf.assign( x, 0.0, null, y ); // $ExpectError
@@ -365,7 +347,6 @@ import indexOf = require( './index' );
365347
indexOf.assign( x, 0.0, ( x: number ): number => x, y ); // $ExpectError
366348

367349
indexOf.assign( x, 0.0, '5', y, {} ); // $ExpectError
368-
indexOf.assign( x, 0.0, 5, y, {} ); // $ExpectError
369350
indexOf.assign( x, 0.0, true, y, {} ); // $ExpectError
370351
indexOf.assign( x, 0.0, false, y, {} ); // $ExpectError
371352
indexOf.assign( x, 0.0, null, y, {} ); // $ExpectError
@@ -463,58 +444,6 @@ import indexOf = require( './index' );
463444
indexOf.assign( x, 0.0, 1, y, { 'dims': ( x: number ): number => x } ); // $ExpectError
464445
}
465446

466-
// The compiler throws an error if the `assign` method is provided an invalid `dtype` option...
467-
{
468-
const x = zeros( [ 2, 2 ], {
469-
'dtype': 'float64'
470-
});
471-
const y = zeros( [], {
472-
'dtype': 'int32'
473-
});
474-
475-
indexOf.assign( x, 0.0, y, { 'dtype': '5' } ); // $ExpectError
476-
indexOf.assign( x, 0.0, y, { 'dtype': 5 } ); // $ExpectError
477-
indexOf.assign( x, 0.0, y, { 'dtype': true } ); // $ExpectError
478-
indexOf.assign( x, 0.0, y, { 'dtype': false } ); // $ExpectError
479-
indexOf.assign( x, 0.0, y, { 'dtype': null } ); // $ExpectError
480-
indexOf.assign( x, 0.0, y, { 'dtype': {} } ); // $ExpectError
481-
indexOf.assign( x, 0.0, y, { 'dtype': ( x: number ): number => x } ); // $ExpectError
482-
483-
indexOf.assign( x, 0.0, 1, y, { 'dtype': '5' } ); // $ExpectError
484-
indexOf.assign( x, 0.0, 1, y, { 'dtype': 5 } ); // $ExpectError
485-
indexOf.assign( x, 0.0, 1, y, { 'dtype': true } ); // $ExpectError
486-
indexOf.assign( x, 0.0, 1, y, { 'dtype': false } ); // $ExpectError
487-
indexOf.assign( x, 0.0, 1, y, { 'dtype': null } ); // $ExpectError
488-
indexOf.assign( x, 0.0, 1, y, { 'dtype': {} } ); // $ExpectError
489-
indexOf.assign( x, 0.0, 1, y, { 'dtype': ( x: number ): number => x } ); // $ExpectError
490-
}
491-
492-
// The compiler throws an error if the `assign` method is provided an invalid `keepdims` option...
493-
{
494-
const x = zeros( [ 2, 2 ], {
495-
'dtype': 'float64'
496-
});
497-
const y = zeros( [], {
498-
'dtype': 'int32'
499-
});
500-
501-
indexOf.assign( x, 0.0, y, { 'keepdims': '5' } ); // $ExpectError
502-
indexOf.assign( x, 0.0, y, { 'keepdims': 5 } ); // $ExpectError
503-
indexOf.assign( x, 0.0, y, { 'keepdims': true } ); // $ExpectError
504-
indexOf.assign( x, 0.0, y, { 'keepdims': false } ); // $ExpectError
505-
indexOf.assign( x, 0.0, y, { 'keepdims': null } ); // $ExpectError
506-
indexOf.assign( x, 0.0, y, { 'keepdims': {} } ); // $ExpectError
507-
indexOf.assign( x, 0.0, y, { 'keepdims': ( x: number ): number => x } ); // $ExpectError
508-
509-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': '5' } ); // $ExpectError
510-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': 5 } ); // $ExpectError
511-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': true } ); // $ExpectError
512-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': false } ); // $ExpectError
513-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': null } ); // $ExpectError
514-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': {} } ); // $ExpectError
515-
indexOf.assign( x, 0.0, 1, y, { 'keepdims': ( x: number ): number => x } ); // $ExpectError
516-
}
517-
518447
// The compiler throws an error if the `assign` method is provided an unsupported number of arguments...
519448
{
520449
const x = zeros( [ 2, 2 ], {

0 commit comments

Comments
 (0)