@@ -1184,6 +1184,18 @@ tape( 'the function supports providing a `sortOrder` argument (scalar, options)'
1184
1184
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1185
1185
t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1186
1186
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
+
1187
1199
t . end ( ) ;
1188
1200
} ) ;
1189
1201
@@ -1221,6 +1233,18 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', fun
1221
1233
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1222
1234
t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1223
1235
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
+
1224
1248
t . end ( ) ;
1225
1249
} ) ;
1226
1250
@@ -1258,6 +1282,18 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray, optio
1258
1282
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1259
1283
t . strictEqual ( isSameArray ( getData ( actual ) , expected ) , true , 'returns expected value' ) ;
1260
1284
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
+
1261
1297
t . end ( ) ;
1262
1298
} ) ;
1263
1299
@@ -1295,6 +1331,20 @@ tape( 'the function supports providing a `sortOrder` argument (scalar, broadcast
1295
1331
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1296
1332
t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1297
1333
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
+
1298
1348
t . end ( ) ;
1299
1349
} ) ;
1300
1350
@@ -1336,6 +1386,20 @@ tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broad
1336
1386
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1337
1387
t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1338
1388
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
+
1339
1403
t . end ( ) ;
1340
1404
} ) ;
1341
1405
@@ -1475,5 +1539,21 @@ tape( 'the function supports providing a `sortOrder` argument (ndarray)', functi
1475
1539
t . strictEqual ( getOrder ( actual ) , getOrder ( x ) , 'returns expected value' ) ;
1476
1540
t . deepEqual ( ndarray2array ( actual ) , expected , 'returns expected value' ) ;
1477
1541
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
+
1478
1558
t . end ( ) ;
1479
1559
} ) ;
0 commit comments