@@ -356,3 +356,70 @@ tape( 'the function returns an array containing ndarrays (ndims=3, writable)', f
356
356
357
357
t . end ( ) ;
358
358
} ) ;
359
+
360
+ tape ( 'the function returns empty views if provided an empty array (ndims=2)' , function test ( t ) {
361
+ var actual ;
362
+ var buf ;
363
+ var ord ;
364
+ var sh ;
365
+ var st ;
366
+ var o ;
367
+ var x ;
368
+
369
+ buf = zeroTo ( 8 , 'float64' ) ;
370
+ st = [ 4 , 1 ] ;
371
+ o = 0 ;
372
+ ord = 'row-major' ;
373
+
374
+ sh = [ 2 , 0 ] ;
375
+ x = new ndarray ( 'float64' , buf , sh , st , o , ord ) ;
376
+
377
+ actual = pop ( x , 0 , false ) ;
378
+
379
+ t . strictEqual ( isndarrayLike ( actual [ 0 ] ) , true , 'returns expected value' ) ;
380
+ t . strictEqual ( isndarrayLike ( actual [ 1 ] ) , true , 'returns expected value' ) ;
381
+ t . strictEqual ( isReadOnly ( actual [ 0 ] ) , true , 'returns expected value' ) ;
382
+ t . strictEqual ( isReadOnly ( actual [ 1 ] ) , true , 'returns expected value' ) ;
383
+ t . deepEqual ( getShape ( actual [ 0 ] ) , [ 1 , 0 ] , 'returns expected value' ) ;
384
+ t . deepEqual ( getShape ( actual [ 1 ] ) , [ 1 , 0 ] , 'returns expected value' ) ;
385
+ t . deepEqual ( ndarray2array ( actual [ 0 ] ) , [ ] , 'returns expected value' ) ;
386
+ t . deepEqual ( ndarray2array ( actual [ 1 ] ) , [ ] , 'returns expected value' ) ;
387
+
388
+ actual = pop ( x , 1 , false ) ;
389
+
390
+ t . strictEqual ( isndarrayLike ( actual [ 0 ] ) , true , 'returns expected value' ) ;
391
+ t . strictEqual ( isndarrayLike ( actual [ 1 ] ) , true , 'returns expected value' ) ;
392
+ t . strictEqual ( isReadOnly ( actual [ 0 ] ) , true , 'returns expected value' ) ;
393
+ t . strictEqual ( isReadOnly ( actual [ 1 ] ) , true , 'returns expected value' ) ;
394
+ t . deepEqual ( getShape ( actual [ 0 ] ) , [ 2 , 0 ] , 'returns expected value' ) ;
395
+ t . deepEqual ( getShape ( actual [ 1 ] ) , [ 2 , 0 ] , 'returns expected value' ) ;
396
+ t . deepEqual ( ndarray2array ( actual [ 0 ] ) , [ ] , 'returns expected value' ) ;
397
+ t . deepEqual ( ndarray2array ( actual [ 1 ] ) , [ ] , 'returns expected value' ) ;
398
+
399
+ sh = [ 0 , 4 ] ;
400
+ x = new ndarray ( 'float64' , buf , sh , st , o , ord ) ;
401
+
402
+ actual = pop ( x , 0 , false ) ;
403
+
404
+ t . strictEqual ( isndarrayLike ( actual [ 0 ] ) , true , 'returns expected value' ) ;
405
+ t . strictEqual ( isndarrayLike ( actual [ 1 ] ) , true , 'returns expected value' ) ;
406
+ t . strictEqual ( isReadOnly ( actual [ 0 ] ) , true , 'returns expected value' ) ;
407
+ t . strictEqual ( isReadOnly ( actual [ 1 ] ) , true , 'returns expected value' ) ;
408
+ t . deepEqual ( getShape ( actual [ 0 ] ) , [ 0 , 4 ] , 'returns expected value' ) ;
409
+ t . deepEqual ( getShape ( actual [ 1 ] ) , [ 0 , 4 ] , 'returns expected value' ) ;
410
+ t . deepEqual ( ndarray2array ( actual [ 0 ] ) , [ ] , 'returns expected value' ) ;
411
+ t . deepEqual ( ndarray2array ( actual [ 1 ] ) , [ ] , 'returns expected value' ) ;
412
+
413
+ actual = pop ( x , 1 , false ) ;
414
+
415
+ t . strictEqual ( isndarrayLike ( actual [ 0 ] ) , true , 'returns expected value' ) ;
416
+ t . strictEqual ( isndarrayLike ( actual [ 1 ] ) , true , 'returns expected value' ) ;
417
+ t . strictEqual ( isReadOnly ( actual [ 0 ] ) , true , 'returns expected value' ) ;
418
+ t . strictEqual ( isReadOnly ( actual [ 1 ] ) , true , 'returns expected value' ) ;
419
+ t . deepEqual ( getShape ( actual [ 0 ] ) , [ 0 , 3 ] , 'returns expected value' ) ;
420
+ t . deepEqual ( getShape ( actual [ 1 ] ) , [ 0 , 1 ] , 'returns expected value' ) ;
421
+ t . deepEqual ( ndarray2array ( actual [ 0 ] ) , [ ] , 'returns expected value' ) ;
422
+ t . deepEqual ( ndarray2array ( actual [ 1 ] ) , [ ] , 'returns expected value' ) ;
423
+
424
+ t . end ( ) ;
425
+ } ) ;
0 commit comments