Skip to content

Commit 20df6cf

Browse files
committed
fix: 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: passed - task: lint_package_json status: na - task: lint_repl_help status: na - 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: passed - 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 2f833e4 commit 20df6cf

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var idx = sindexOf( [ x, searchElement, fromIndex ] );
9494

9595
## Notes
9696

97-
- When searching for a search element, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same.
97+
- If `fromIndex` is greater than or equal to zero and less than the ndarray length, searching begins at that index and if `fromIndex` is greater than or equal to the array length, the function returns `-1`. Similarly, if `fromIndex` is negative, it is added to the array length, and, if the result is less than zero, searching begins at index `0`.
9898

9999
</section>
100100

@@ -128,7 +128,7 @@ console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
128128
var fromIndex = scalar2ndarray( 0, {
129129
'dtype': 'generic'
130130
});
131-
console.log( 'From Index:', ndarray2array( fromIndex ) );
131+
console.log( 'From Index:', ndarraylike2scalar( fromIndex ) );
132132

133133
var idx = sindexOf( [ x, searchElement, fromIndex ] );
134134
console.log( idx );

lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/benchmark/benchmark.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ function createBenchmark( len ) {
6565
return benchmark;
6666

6767
function benchmark( b ) {
68-
var idx;
68+
var out;
6969
var i;
7070

7171
b.tic();
7272
for ( i = 0; i < b.iterations; i++ ) {
73-
idx = sindexOf( [ x, searchElement, fromIndex ] );
74-
if ( !isInteger( idx ) ) {
73+
out = sindexOf( [ x, searchElement, fromIndex ] );
74+
if ( out !== out ) {
7575
b.fail( 'should return an integer' );
7676
}
7777
}
7878
b.toc();
79-
if ( !isInteger( idx ) ) {
79+
if ( !isInteger( out ) ) {
8080
b.fail( 'should return an integer' );
8181
}
8282
b.pass( 'benchmark finished' );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { typedndarray } from '@stdlib/types/ndarray';
2525
/**
2626
* Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
2727
*
28-
* @param arrays - array-like object containing an input ndarray, a search element ndarray and a from index ndarray.
28+
* @param arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the search element and a zero-dimensional ndarray containing the from index.
2929
* @returns index
3030
*
3131
* @example
@@ -48,7 +48,7 @@ import { typedndarray } from '@stdlib/types/ndarray';
4848
* var v = sindexOf( [ x, searchElement, fromIndex ] );
4949
* // returns 3
5050
*/
51-
declare function sindexOf<T extends typedndarray<number> = typedndarray<number>>( arrays: [ T, T, T ] ): number;
51+
declare function sindexOf<T = unknown>( arrays: [ typedndarray<T>, typedndarray<number>, typedndarray<number> ] ): number;
5252

5353

5454
// EXPORTS //

lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
3333
/**
3434
* Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
3535
*
36-
* @param {ArrayLikeObject<Object>} arrays - array-like object containing an input ndarray, a search element ndarray and a from index ndarray.
36+
* @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the search element and a zero-dimensional ndarray containing the from index.
3737
* @returns {integer} index
3838
*
3939
* @example
@@ -66,11 +66,10 @@ function sindexOf( arrays ) {
6666
var x;
6767

6868
x = arrays[ 0 ];
69+
N = numelDimension( x, 0 );
6970
searchElement = ndarraylike2scalar( arrays[ 1 ] );
7071
fromIndex = ndarraylike2scalar( arrays[ 2 ] );
7172

72-
N = numelDimension( x, 0 );
73-
7473
if ( fromIndex >= 0 ) {
7574
if ( fromIndex >= N ) {
7675
return -1;

lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ tape( 'the function returns the first index of an element which equals a provide
125125
actual = sindexOf( [ x, searchElement, fromIndex ] );
126126
t.strictEqual( actual, 3, 'returns expected value' );
127127

128-
searchElement = scalar2ndarray( 4.0, {
128+
searchElement = scalar2ndarray( 2.0, {
129129
'dtype': 'float32'
130130
});
131-
fromIndex = scalar2ndarray( -4, {
131+
fromIndex = scalar2ndarray( -7, {
132132
'dtype': 'generic'
133133
});
134134
actual = sindexOf( [ x, searchElement, fromIndex ] );
135-
t.strictEqual( actual, -1, 'returns expected value' );
135+
t.strictEqual( actual, 2, 'returns expected value' );
136136

137137
t.end();
138138
});

0 commit comments

Comments
 (0)