@@ -480,28 +480,42 @@ def test_frame_info_encoding(self):
480
480
fmt .set_printoptions (max_rows = 200 )
481
481
482
482
def test_large_frame_repr (self ):
483
- old_max_rows = pd .get_option ('display.max_rows' )
484
- old_max_info_rows = pd .get_option ('display.max_info_rows' )
485
-
486
- nrows , ncols = 3 , 2
483
+ def wrap_rows_options (f ):
484
+ def _f (* args , ** kwargs ):
485
+ old_max_rows = pd .get_option ('display.max_rows' )
486
+ old_max_info_rows = pd .get_option ('display.max_info_rows' )
487
+ o = f (* args , ** kwargs )
488
+ pd .set_option ('display.max_rows' , old_max_rows )
489
+ pd .set_option ('display.max_info_rows' , old_max_info_rows )
490
+ return o
491
+ return _f
492
+
493
+ @wrap_rows_options
494
+ def test_setting (value , nrows = 3 , ncols = 2 ):
495
+ if value is None :
496
+ expected_difference = 0
497
+ elif isinstance (value , int ):
498
+ expected_difference = ncols
499
+ else :
500
+ raise ValueError ("'value' must be int or None" )
487
501
488
- # need to set max rows so that we get an info-style repr
489
- pd .set_option ('display.max_rows' , nrows - 1 )
490
- pd .set_option ('display.max_info_rows' , nrows )
502
+ pd .set_option ('display.max_rows' , nrows - 1 )
503
+ pd .set_option ('display.max_info_rows' , value )
491
504
492
- smallx = DataFrame (np .random .rand (nrows , ncols ))
493
- repr_small = repr (smallx )
505
+ smallx = DataFrame (np .random .rand (nrows , ncols ))
506
+ repr_small = repr (smallx )
494
507
495
- bigx = DataFrame (np .random .rand (nrows + 1 , ncols ))
496
- repr_big = repr (bigx )
508
+ bigx = DataFrame (np .random .rand (nrows + 1 , ncols ))
509
+ repr_big = repr (bigx )
497
510
498
- diff = len (repr_small .splitlines ()) - len (repr_big .splitlines ())
511
+ diff = len (repr_small .splitlines ()) - len (repr_big .splitlines ())
499
512
500
- # the difference in line count is the number of columns
501
- self .assertEqual (diff , ncols )
513
+ # the difference in line count is the number of columns
514
+ self .assertEqual (diff , expected_difference )
502
515
503
- pd .set_option ('display.max_rows' , old_max_rows )
504
- pd .set_option ('display.max_info_rows' , old_max_info_rows )
516
+ test_setting (None )
517
+ test_setting (3 )
518
+ self .assertRaises (ValueError , test_setting , 'string' )
505
519
506
520
def test_wide_repr (self ):
507
521
with option_context ('mode.sim_interactive' , True ):
0 commit comments