@@ -304,19 +304,19 @@ describe("DataFrame", function () {
304304 const df = new dfd . DataFrame ( data , { columns : cols } ) ;
305305 assert . deepEqual ( df . head ( 2 ) . values , [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] ) ;
306306 } ) ;
307- it ( "Throws error if row specified is greater than values " , function ( ) {
307+ it ( "Throws error if row specified is less than 0 " , function ( ) {
308308 const data = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ;
309309 const cols = [ "A" , "B" , "C" ] ;
310310 const df = new dfd . DataFrame ( data , { columns : cols } ) ;
311- assert . throws ( ( ) => df . head ( 10 ) , Error ,
312- "ParamError: Number of rows cannot be greater than available rows in data " ) ;
311+ assert . throws ( ( ) => df . head ( - 1 ) , Error ,
312+ "ParamError: Number of rows cannot be less than 1 " ) ;
313313 } ) ;
314- it ( "Throws error if row specified is less than 0" , function ( ) {
314+
315+ it ( "Returns all rows when size of DataFrame is less than default (5)" , function ( ) {
315316 const data = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ;
316317 const cols = [ "A" , "B" , "C" ] ;
317318 const df = new dfd . DataFrame ( data , { columns : cols } ) ;
318- assert . throws ( ( ) => df . head ( - 1 ) , Error ,
319- "ParamError: Number of rows cannot be less than 1" ) ;
319+ assert . deepEqual ( df . head ( ) . values , data ) ;
320320 } ) ;
321321
322322 } ) ;
@@ -328,13 +328,6 @@ describe("DataFrame", function () {
328328 const df = new dfd . DataFrame ( data , { columns : cols } ) ;
329329 assert . deepEqual ( df . tail ( 2 ) . values , [ [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ) ;
330330 } ) ;
331- it ( "Throws error if row specified is greater than values" , function ( ) {
332- const data = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ;
333- const cols = [ "A" , "B" , "C" ] ;
334- const df = new dfd . DataFrame ( data , { columns : cols } ) ;
335- assert . throws ( ( ) => df . tail ( 10 ) , Error ,
336- "ParamError: Number of rows cannot be greater than available rows in data" ) ;
337- } ) ;
338331 it ( "Throws error if row specified is less than 0" , function ( ) {
339332 const data = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ;
340333 const cols = [ "A" , "B" , "C" ] ;
@@ -353,6 +346,12 @@ describe("DataFrame", function () {
353346 const df = new dfd . DataFrame ( data ) ;
354347 assert . deepEqual ( df . tail ( 2 ) . values , [ [ 1 , 2 , 34 , 5 , 0 , 6 , 4 , 5 , 6 , 7 ] , [ 20 , 30 , 40 , 39 , 89 , 78 , 45 , 56 , 56 , 45 ] ] ) ;
355348 } ) ;
349+ it ( "Returns all rows when size of DataFrame is less than default (5)" , function ( ) {
350+ const data = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 20 , 30 , 40 ] , [ 39 , 89 , 78 ] ] ;
351+ const cols = [ "A" , "B" , "C" ] ;
352+ const df = new dfd . DataFrame ( data , { columns : cols } ) ;
353+ assert . deepEqual ( df . tail ( ) . values , data ) ;
354+ } ) ;
356355 } ) ;
357356
358357 describe ( "sample" , function ( ) {
0 commit comments