Skip to content

Commit e842e22

Browse files
committed
test: 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8612da3 commit e842e22

File tree

2 files changed

+83
-4
lines changed

2 files changed

+83
-4
lines changed

lib/node_modules/@stdlib/blas/ext/last-index-of/test/test.assign.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var ndarray = require( '@stdlib/ndarray/ctor' );
2626
var zeros = require( '@stdlib/ndarray/zeros' );
2727
var ndarray2array = require( '@stdlib/ndarray/to-array' );
2828
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
29+
var Int32Array = require( '@stdlib/array/int32' );
2930
var getDType = require( '@stdlib/ndarray/dtype' );
3031
var getShape = require( '@stdlib/ndarray/shape' );
3132
var getOrder = require( '@stdlib/ndarray/order' );
@@ -1518,7 +1519,7 @@ tape( 'the function supports providing a from index (0d ndarray, options)', func
15181519
t.end();
15191520
});
15201521

1521-
tape( 'the function supports providing a from index (scalar, broadcasted)', function test( t ) {
1522+
tape( 'the function supports providing a from index and operation dimension', function test( t ) {
15221523
var expected;
15231524
var actual;
15241525
var xbuf;
@@ -1583,7 +1584,7 @@ tape( 'the function supports providing a from index (scalar, broadcasted)', func
15831584
t.end();
15841585
});
15851586

1586-
tape( 'the function supports providing a from index (0d ndarray, broadcasted)', function test( t ) {
1587+
tape( 'the function supports providing a from index and operation dimension (0d ndarray)', function test( t ) {
15871588
var expected;
15881589
var fromIdx;
15891590
var actual;
@@ -1651,3 +1652,44 @@ tape( 'the function supports providing a from index (0d ndarray, broadcasted)',
16511652

16521653
t.end();
16531654
});
1655+
1656+
tape( 'the function supports providing an ndarray from index and search element with operation dimension (1d ndarray)', function test( t ) {
1657+
var searchElement;
1658+
var expected;
1659+
var fromIdx;
1660+
var actual;
1661+
var xbuf;
1662+
var x;
1663+
var y;
1664+
1665+
/*
1666+
* [
1667+
* 1.0, -2.0,
1668+
* 2.0, -3.0,
1669+
* 3.0, -4.0,
1670+
* 2.0, -3.0,
1671+
* 5.0, -6.0
1672+
* ]
1673+
*/
1674+
xbuf = [ 1.0, -2.0, 2.0, -3.0, 3.0, -4.0, 2.0, -3.0, 5.0, -6.0 ];
1675+
x = new ndarray( 'generic', xbuf, [ 5, 2 ], [ 2, 1 ], 0, 'row-major' );
1676+
y = zeros( [ 2 ], {
1677+
'dtype': 'generic'
1678+
});
1679+
1680+
fromIdx = new ndarray( 'int32', new Int32Array( [ 4, 4 ] ), [ 2 ], [ 1 ], 0, 'row-major' );
1681+
searchElement = new ndarray( 'generic', [ 2.0, -3.0 ], [ 2 ], [ 1 ], 0, 'row-major' );
1682+
actual = lastIndexOf( x, searchElement, fromIdx, y, {
1683+
'dim': 0
1684+
});
1685+
expected = [ 3, 3 ];
1686+
1687+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1688+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1689+
t.deepEqual( getShape( actual ), [ 2 ], 'returns expected value' );
1690+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1691+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1692+
t.strictEqual( ( y === actual ), true, 'returns expected value' );
1693+
1694+
t.end();
1695+
});

lib/node_modules/@stdlib/blas/ext/last-index-of/test/test.main.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var tape = require( 'tape' );
2424
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
2525
var ndarray = require( '@stdlib/ndarray/ctor' );
2626
var zeros = require( '@stdlib/ndarray/zeros' );
27+
var Int32Array = require( '@stdlib/array/int32' );
2728
var ndarray2array = require( '@stdlib/ndarray/to-array' );
2829
var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
2930
var getDType = require( '@stdlib/ndarray/dtype' );
@@ -1212,7 +1213,7 @@ tape( 'the function supports providing a from index (0d ndarray, options)', func
12121213
t.end();
12131214
});
12141215

1215-
tape( 'the function supports providing a from index (scalar, broadcasted)', function test( t ) {
1216+
tape( 'the function supports providing a from index and operation dimension', function test( t ) {
12161217
var expected;
12171218
var actual;
12181219
var xbuf;
@@ -1267,7 +1268,7 @@ tape( 'the function supports providing a from index (scalar, broadcasted)', func
12671268
t.end();
12681269
});
12691270

1270-
tape( 'the function supports providing a from index (0d ndarray, broadcasted)', function test( t ) {
1271+
tape( 'the function supports providing a from index and operation dimension (0d ndarray)', function test( t ) {
12711272
var expected;
12721273
var fromIdx;
12731274
var actual;
@@ -1325,3 +1326,39 @@ tape( 'the function supports providing a from index (0d ndarray, broadcasted)',
13251326

13261327
t.end();
13271328
});
1329+
1330+
tape( 'the function supports providing an ndarray from index and search element with operation dimension (1d ndarray)', function test( t ) {
1331+
var searchElement;
1332+
var expected;
1333+
var fromIdx;
1334+
var actual;
1335+
var xbuf;
1336+
var x;
1337+
1338+
/*
1339+
* [
1340+
* 1.0, -2.0,
1341+
* 2.0, -3.0,
1342+
* 3.0, -4.0,
1343+
* 2.0, -3.0,
1344+
* 5.0, -6.0
1345+
* ]
1346+
*/
1347+
xbuf = [ 1.0, -2.0, 2.0, -3.0, 3.0, -4.0, 2.0, -3.0, 5.0, -6.0 ];
1348+
x = new ndarray( 'generic', xbuf, [ 5, 2 ], [ 2, 1 ], 0, 'row-major' );
1349+
1350+
fromIdx = new ndarray( 'int32', new Int32Array( [ 4, 4 ] ), [ 2 ], [ 1 ], 0, 'row-major' );
1351+
searchElement = new ndarray( 'generic', [ 2.0, -3.0 ], [ 2 ], [ 1 ], 0, 'row-major' );
1352+
actual = lastIndexOf( x, searchElement, fromIdx, {
1353+
'dim': 0
1354+
});
1355+
expected = [ 3, 3 ];
1356+
1357+
t.strictEqual( isndarrayLike( actual ), true, 'returns expected value' );
1358+
t.strictEqual( getDType( actual ), 'generic', 'returns expected value' );
1359+
t.deepEqual( getShape( actual ), [ 2 ], 'returns expected value' );
1360+
t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
1361+
t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
1362+
1363+
t.end();
1364+
});

0 commit comments

Comments
 (0)