@@ -26,6 +26,7 @@ var ndarray = require( '@stdlib/ndarray/ctor' );
26
26
var zeros = require ( '@stdlib/ndarray/zeros' ) ;
27
27
var ndarray2array = require ( '@stdlib/ndarray/to-array' ) ;
28
28
var scalar2ndarray = require ( '@stdlib/ndarray/from-scalar' ) ;
29
+ var Int32Array = require ( '@stdlib/array/int32' ) ;
29
30
var getDType = require ( '@stdlib/ndarray/dtype' ) ;
30
31
var getShape = require ( '@stdlib/ndarray/shape' ) ;
31
32
var getOrder = require ( '@stdlib/ndarray/order' ) ;
@@ -1518,7 +1519,7 @@ tape( 'the function supports providing a from index (0d ndarray, options)', func
1518
1519
t . end ( ) ;
1519
1520
} ) ;
1520
1521
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 ) {
1522
1523
var expected ;
1523
1524
var actual ;
1524
1525
var xbuf ;
@@ -1583,7 +1584,7 @@ tape( 'the function supports providing a from index (scalar, broadcasted)', func
1583
1584
t . end ( ) ;
1584
1585
} ) ;
1585
1586
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 ) {
1587
1588
var expected ;
1588
1589
var fromIdx ;
1589
1590
var actual ;
@@ -1651,3 +1652,44 @@ tape( 'the function supports providing a from index (0d ndarray, broadcasted)',
1651
1652
1652
1653
t . end ( ) ;
1653
1654
} ) ;
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
+ } ) ;
0 commit comments