Skip to content

Commit ee59feb

Browse files
committed
refactor: fix fromIndex handling
--- 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: passed - 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 7d24076 commit ee59feb

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var searchElement = scalar2ndarray( 2.0, {
5252
'dtype': 'float64'
5353
});
5454

55-
var fromIndex = scalar2ndarray( 0, {
55+
var fromIndex = scalar2ndarray( 3, {
5656
'dtype': 'generic'
5757
});
5858

@@ -78,7 +78,7 @@ var ndarray = require( '@stdlib/ndarray/base/ctor' );
7878
var xbuf = new Float64Array( [ 1.0, 2.0, 4.0, 2.0 ] );
7979
var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
8080

81-
var searchElement = scalar2ndarray( 10.0, {
81+
var searchElement = scalar2ndarray( 2.0, {
8282
'dtype': 'float64'
8383
});
8484

@@ -129,7 +129,7 @@ var searchElement = scalar2ndarray( 80.0, {
129129
});
130130
console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
131131

132-
var fromIndex = scalar2ndarray( 0, {
132+
var fromIndex = scalar2ndarray( -1, {
133133
'dtype': 'generic'
134134
});
135135
console.log( 'From Index:', ndarraylike2scalar( fromIndex ) );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function createBenchmark( len ) {
5858
searchElement = scalar2ndarray( -10.0, {
5959
'dtype': 'float64'
6060
});
61-
fromIndex = scalar2ndarray( 0, {
61+
fromIndex = scalar2ndarray( -1, {
6262
'dtype': 'generic'
6363
});
6464

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { float64ndarray, typedndarray } from '@stdlib/types/ndarray';
4141
* 'dtype': 'float64'
4242
* });
4343
*
44-
* var fromIndex = scalar2ndarray( 0, {
44+
* var fromIndex = scalar2ndarray( 3, {
4545
* 'dtype': 'generic'
4646
* });
4747
*

lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-of/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var searchElement = scalar2ndarray( 80.0, {
3636
});
3737
console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
3838

39-
var fromIndex = scalar2ndarray( 0, {
39+
var fromIndex = scalar2ndarray( -1, {
4040
'dtype': 'generic'
4141
});
4242
console.log( 'From Index:', ndarraylike2scalar( fromIndex ) );

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
3030
* var dlastIndexOf = require( '@stdlib/blas/ext/base/ndarray/dlast-index-of' );
3131
*
32-
* var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
32+
* var xbuf = new Float64Array( [ 1.0, 2.0, 4.0, 2.0 ] );
3333
* var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
3434
*
3535
* var searchElement = scalar2ndarray( 2.0, {
3636
* 'dtype': 'float64'
3737
* });
3838
*
39-
* var fromIndex = scalar2ndarray( 0, {
39+
* var fromIndex = scalar2ndarray( 3, {
4040
* 'dtype': 'generic'
4141
* });
4242
*

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
4949
* 'dtype': 'float64'
5050
* });
5151
*
52-
* var fromIndex = scalar2ndarray( 0, {
52+
* var fromIndex = scalar2ndarray( 3, {
5353
* 'dtype': 'generic'
5454
* });
5555
*
@@ -78,14 +78,11 @@ function dlastIndexOf( arrays ) {
7878
} else if ( fromIndex >= N ) {
7979
return -1;
8080
}
81-
N -= fromIndex;
81+
N = fromIndex + 1;
8282
stride = getStride( x, 0 );
83-
offset = getOffset( x ) + ( stride*fromIndex );
83+
offset = getOffset( x );
8484

8585
idx = strided( N, searchElement, getData( x ), stride, offset );
86-
if ( idx >= 0 ) {
87-
idx += fromIndex;
88-
}
8986
return idx;
9087
}
9188

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tape( 'the function returns the last index of an element which equals a provided
6464
searchElement = scalar2ndarray( 1.0, {
6565
'dtype': 'float64'
6666
});
67-
fromIndex = scalar2ndarray( 0, {
67+
fromIndex = scalar2ndarray( 5, {
6868
'dtype': 'generic'
6969
});
7070
actual = dlastIndexOf( [ x, searchElement, fromIndex ] );
@@ -73,7 +73,7 @@ tape( 'the function returns the last index of an element which equals a provided
7373
searchElement = scalar2ndarray( 2.0, {
7474
'dtype': 'float64'
7575
});
76-
fromIndex = scalar2ndarray( 0, {
76+
fromIndex = scalar2ndarray( 5, {
7777
'dtype': 'generic'
7878
});
7979
actual = dlastIndexOf( [ x, searchElement, fromIndex ] );
@@ -114,7 +114,7 @@ tape( 'the function returns the last index of an element which equals a provided
114114
'dtype': 'generic'
115115
});
116116
actual = dlastIndexOf( [ x, searchElement, fromIndex ] );
117-
t.strictEqual( actual, 5, 'returns expected value' );
117+
t.strictEqual( actual, 4, 'returns expected value' );
118118

119119
searchElement = scalar2ndarray( 2.0, {
120120
'dtype': 'float64'
@@ -132,7 +132,7 @@ tape( 'the function returns the last index of an element which equals a provided
132132
'dtype': 'generic'
133133
});
134134
actual = dlastIndexOf( [ x, searchElement, fromIndex ] );
135-
t.strictEqual( actual, 3, 'returns expected value' );
135+
t.strictEqual( actual, -1, 'returns expected value' );
136136

137137
t.end();
138138
});

0 commit comments

Comments
 (0)