Skip to content

Commit 39ee4ab

Browse files
committed
fix: apply suggestions from code review
--- 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: 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 933e03c commit 39ee4ab

File tree

8 files changed

+26
-35
lines changed

8 files changed

+26
-35
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ var idx = sindexOf( x.length, 3.0, x, 1 );
5656
The function has the following parameters:
5757

5858
- **N**: number of indexed elements.
59-
- **searchElement**: element to search the index of.
59+
- **searchElement**: search element.
6060
- **x**: input [`Float32Array`][@stdlib/array/float32].
61-
- **strideX**: index increment.
61+
- **strideX**: stride length.
6262

63-
If the function is unable to find an element which equals a provided search element, the function returns `-1`.
63+
If the function is unable to find a search element, the function returns `-1`.
6464

6565
```javascript
6666
var Float32Array = require( '@stdlib/array/float32' );
@@ -79,7 +79,7 @@ var Float32Array = require( '@stdlib/array/float32' );
7979
var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ] );
8080

8181
var idx = sindexOf( 4, -1.0, x, 2 );
82-
// returns 6
82+
// returns 3
8383
```
8484

8585
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
@@ -95,7 +95,7 @@ var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd
9595

9696
// Find index...
9797
var idx = sindexOf( 3, -6.0, x1, 2 );
98-
// returns 4
98+
// returns 2
9999
```
100100

101101
#### sindexOf.ndarray( N, searchElement, x, strideX, offsetX )
@@ -123,7 +123,7 @@ var Float32Array = require( '@stdlib/array/float32' );
123123
var x = new Float32Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, 3.0 ] );
124124

125125
var idx = sindexOf.ndarray( 3, 3.0, x, 1, x.length-3 );
126-
// returns 7
126+
// returns 2
127127
```
128128

129129
</section>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createBenchmark( len ) {
5353

5454
b.tic();
5555
for ( i = 0; i < b.iterations; i++ ) {
56-
out = sindexOf( x.length, 2.0, x, 1 );
56+
out = sindexOf( x.length, len+1, x, 1 );
5757
if ( out !== out ) {
5858
b.fail( 'should return an integer' );
5959
}
@@ -89,7 +89,7 @@ function main() {
8989
len = pow( 10, i );
9090

9191
f = createBenchmark( len );
92-
bench( pkg+':dtype=float32,len='+len, f );
92+
bench( pkg+':len='+len, f );
9393
}
9494
}
9595

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createBenchmark( len ) {
5353

5454
b.tic();
5555
for ( i = 0; i < b.iterations; i++ ) {
56-
out = sindexOf( x.length, 2.0, x, 1, 0 );
56+
out = sindexOf( x.length, len+1, x, 1, 0 );
5757
if ( out !== out ) {
5858
b.fail( 'should return an integer' );
5959
}
@@ -89,7 +89,7 @@ function main() {
8989
len = pow( 10, i );
9090

9191
f = createBenchmark( len );
92-
bench( pkg+':dtype=float32,len='+len, f );
92+
bench( pkg+':len='+len, f );
9393
}
9494
}
9595

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Input array.
2424

2525
strideX: integer
26-
Index increment.
26+
Stride length.
2727

2828
Returns
2929
-------
@@ -57,7 +57,7 @@
5757
Input array.
5858

5959
strideX: integer
60-
Index increment.
60+
Stride length.
6161

6262
offsetX: integer
6363
Starting index.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ var ndarray = require( './ndarray.js' );
3030
* Returns the index of a specified search element in a single-precision floating-point strided array.
3131
*
3232
* @param {PositiveInteger} N - number of indexed elements
33-
* @param {Number} searchElement - number to search index of
33+
* @param {number} searchElement - search element
3434
* @param {Float32Array} x - input array
35-
* @param {integer} strideX - index increment
35+
* @param {integer} strideX - stride length
3636
* @returns {integer} index
3737
*
3838
* @example

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
* Returns the index of a specified search element in a single-precision floating-point strided array.
2525
*
2626
* @param {PositiveInteger} N - number of indexed elements
27-
* @param {Number} searchElement - number to search index of
27+
* @param {number} searchElement - search element
2828
* @param {Float32Array} x - input array
29-
* @param {integer} strideX - index increment
29+
* @param {integer} strideX - stride length
3030
* @param {NonNegativeInteger} offsetX - starting index
3131
* @returns {integer} index
3232
*
@@ -42,14 +42,14 @@ function sindexOf( N, searchElement, x, strideX, offsetX ) {
4242
var ix;
4343
var i;
4444

45-
if ( N <= 0 || x.length === 0 ) {
45+
if ( N <= 0 ) {
4646
return -1;
4747
}
4848

4949
ix = offsetX;
5050
for ( i = 0; i < N; i++ ) {
5151
if ( x[ ix ] === searchElement ) {
52-
return ix;
52+
return i;
5353
}
5454
ix += strideX;
5555
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ tape( 'the function returns the first index of an element which equals a provide
5151

5252
// Negative stride...
5353
actual = sindexOf( x.length, 1.0, x, -1 );
54-
t.strictEqual( actual, 1, 'returns expected value' );
54+
t.strictEqual( actual, 4, 'returns expected value' );
5555

5656
actual = sindexOf( x.length, 2.0, x, -1 );
57-
t.strictEqual( actual, 3, 'returns expected value' );
57+
t.strictEqual( actual, 2, 'returns expected value' );
5858

5959
actual = sindexOf( x.length, 3.0, x, -1 );
60-
t.strictEqual( actual, 5, 'returns expected value' );
60+
t.strictEqual( actual, 0, 'returns expected value' );
6161

6262
t.end();
6363
});

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ tape( 'the function returns the first index of an element which equals a provide
4444
t.strictEqual( actual, 0, 'returns expected value' );
4545

4646
actual = sindexOf( x.length, 2.0, x, 1, 1 );
47-
t.strictEqual( actual, 2, 'returns expected value' );
47+
t.strictEqual( actual, 1, 'returns expected value' );
4848

4949
actual = sindexOf( x.length, 3.0, x, 1, 2 );
50-
t.strictEqual( actual, 4, 'returns expected value' );
50+
t.strictEqual( actual, 2, 'returns expected value' );
5151

5252
// Negative stride...
5353
actual = sindexOf( x.length, 1.0, x, -1, x.length-1 );
54-
t.strictEqual( actual, 1, 'returns expected value' );
54+
t.strictEqual( actual, 4, 'returns expected value' );
5555

5656
actual = sindexOf( x.length, 2.0, x, -2, x.length-1 );
57-
t.strictEqual( actual, 3, 'returns expected value' );
57+
t.strictEqual( actual, 1, 'returns expected value' );
5858

5959
actual = sindexOf( x.length, 1.0, x, -2, x.length-2 );
60-
t.strictEqual( actual, 0, 'returns expected value' );
60+
t.strictEqual( actual, 2, 'returns expected value' );
6161

6262
t.end();
6363
});
@@ -91,12 +91,3 @@ tape( 'the function returns `-1` if provided a search element equal to `NaN`', f
9191

9292
t.end();
9393
});
94-
95-
tape( 'the function returns `-1` if provided an offset which exceeds the maximum array index', function test( t ) {
96-
var actual;
97-
98-
actual = sindexOf( 3, 2.0, new Float32Array( [ 1.0, 2.0, 3.0 ] ), 1, 20 );
99-
t.strictEqual( actual, -1, 'returns expected value' );
100-
101-
t.end();
102-
});

0 commit comments

Comments
 (0)