@@ -1184,6 +1184,18 @@ tape( 'the function supports providing a `sortOrder` argument (scalar, options)'
11841184 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
11851185 t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
11861186
1187+ xbuf = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1188+ x = new ndarray ( 'generic' , xbuf , [ 2 , 2 ] , [ 2 , 1 ] , 0 , 'row-major' ) ;
1189+
1190+ actual = sorthp ( x , 0.0 , { } ) ;
1191+ expected = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1192+
1193+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1194+ t . strictEqual ( getDType ( actual ) , 'generic' , 'returns expected value' ) ;
1195+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1196+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1197+ t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1198+
11871199 t . end ( ) ;
11881200} ) ;
11891201
@@ -1221,6 +1233,18 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', fun
12211233 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
12221234 t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
12231235
1236+ xbuf = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1237+ x = new ndarray ( opts . dtype , xbuf , [ 2 , 2 ] , [ 2 , 1 ] , 0 , 'column-major' ) ;
1238+
1239+ actual = sorthp ( x , scalar2ndarray ( 0.0 , opts ) ) ;
1240+ expected = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1241+
1242+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1243+ t . strictEqual ( getDType ( actual ) , opts . dtype , 'returns expected value' ) ;
1244+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1245+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1246+ t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1247+
12241248 t . end ( ) ;
12251249} ) ;
12261250
@@ -1258,6 +1282,18 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray, optio
12581282 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
12591283 t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
12601284
1285+ xbuf = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1286+ x = new ndarray ( opts . dtype , xbuf , [ 2 , 2 ] , [ 2 , 1 ] , 0 , 'column-major' ) ;
1287+
1288+ actual = sorthp ( x , scalar2ndarray ( 0.0 , opts ) , { } ) ;
1289+ expected = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1290+
1291+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1292+ t . strictEqual ( getDType ( actual ) , opts . dtype , 'returns expected value' ) ;
1293+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1294+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1295+ t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1296+
12611297 t . end ( ) ;
12621298} ) ;
12631299
@@ -1295,6 +1331,20 @@ tape( 'the function supports providing a `sortOrder` argument (scalar, broadcast
12951331 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
12961332 t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
12971333
1334+ xbuf = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1335+ x = new ndarray ( 'generic' , xbuf , [ 2 , 2 ] , [ 1 , 2 ] , 0 , 'column-major' ) ;
1336+
1337+ actual = sorthp ( x , 0.0 , {
1338+ 'dims' : [ 0 ]
1339+ } ) ;
1340+ expected = [ [ - 1.0 , - 3.0 ] , [ 2.0 , 4.0 ] ] ;
1341+
1342+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1343+ t . strictEqual ( getDType ( actual ) , 'generic' , 'returns expected value' ) ;
1344+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1345+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1346+ t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1347+
12981348 t . end ( ) ;
12991349} ) ;
13001350
@@ -1336,6 +1386,20 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broad
13361386 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
13371387 t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
13381388
1389+ xbuf = [ - 1.0 , 2.0 , - 3.0 , 4.0 ] ;
1390+ x = new ndarray ( opts . dtype , xbuf , [ 2 , 2 ] , [ 1 , 2 ] , 0 , 'column-major' ) ;
1391+
1392+ actual = sorthp ( x , scalar2ndarray ( 0.0 , opts ) , {
1393+ 'dims' : [ 0 ]
1394+ } ) ;
1395+ expected = [ [ - 1.0 , - 3.0 ] , [ 2.0 , 4.0 ] ] ;
1396+
1397+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1398+ t . strictEqual ( getDType ( actual ) , opts . dtype , 'returns expected value' ) ;
1399+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1400+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1401+ t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1402+
13391403 t . end ( ) ;
13401404} ) ;
13411405
@@ -1475,5 +1539,21 @@ tape( 'the function supports providing a `sortOrder` argument (ndarray)', functi
14751539 t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
14761540 t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
14771541
1542+ xbuf = [ 1.0 , - 2.0 , - 3.0 , 4.0 ] ;
1543+ x = new ndarray ( opts . dtype , xbuf , [ 2 , 2 ] , [ 2 , 1 ] , 0 , 'row-major' ) ;
1544+
1545+ obuf = [ 0.0 , - 1.0 ] ;
1546+ sortOrder = new ndarray ( opts . dtype , obuf , [ 2 ] , [ 1 ] , 0 , 'row-major' ) ;
1547+ actual = sorthp ( x , sortOrder , {
1548+ 'dims' : [ 1 ]
1549+ } ) ;
1550+ expected = [ [ 1.0 , - 2.0 ] , [ 4.0 , - 3.0 ] ] ;
1551+
1552+ t . strictEqual ( actual , x , 'returns expected value' ) ;
1553+ t . strictEqual ( getDType ( actual ) , opts . dtype , 'returns expected value' ) ;
1554+ t . deepEqual ( getShape ( actual ) , getShape ( x ) , 'returns expected value' ) ;
1555+ t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1556+ t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1557+
14781558 t . end ( ) ;
14791559} ) ;
0 commit comments