@@ -961,7 +961,8 @@ def test_pprint_thing(self):
961961
962962 def test_wide_repr (self ):
963963 with option_context ('mode.sim_interactive' , True ,
964- 'display.show_dimensions' , True ):
964+ 'display.show_dimensions' , True ,
965+ 'display.max_columns' , 20 ):
965966 max_cols = get_option ('display.max_columns' )
966967 df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
967968 set_option ('display.expand_frame_repr' , False )
@@ -979,15 +980,17 @@ def test_wide_repr(self):
979980 reset_option ('display.expand_frame_repr' )
980981
981982 def test_wide_repr_wide_columns (self ):
982- with option_context ('mode.sim_interactive' , True ):
983+ with option_context ('mode.sim_interactive' , True ,
984+ 'display.max_columns' , 20 ):
983985 df = DataFrame (np .random .randn (5 , 3 ),
984986 columns = ['a' * 90 , 'b' * 90 , 'c' * 90 ])
985987 rep_str = repr (df )
986988
987989 assert len (rep_str .splitlines ()) == 20
988990
989991 def test_wide_repr_named (self ):
990- with option_context ('mode.sim_interactive' , True ):
992+ with option_context ('mode.sim_interactive' , True ,
993+ 'display.max_columns' , 20 ):
991994 max_cols = get_option ('display.max_columns' )
992995 df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
993996 df .index .name = 'DataFrame Index'
@@ -1008,7 +1011,8 @@ def test_wide_repr_named(self):
10081011 reset_option ('display.expand_frame_repr' )
10091012
10101013 def test_wide_repr_multiindex (self ):
1011- with option_context ('mode.sim_interactive' , True ):
1014+ with option_context ('mode.sim_interactive' , True ,
1015+ 'display.max_columns' , 20 ):
10121016 midx = MultiIndex .from_arrays (tm .rands_array (5 , size = (2 , 10 )))
10131017 max_cols = get_option ('display.max_columns' )
10141018 df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )),
@@ -1030,7 +1034,8 @@ def test_wide_repr_multiindex(self):
10301034 reset_option ('display.expand_frame_repr' )
10311035
10321036 def test_wide_repr_multiindex_cols (self ):
1033- with option_context ('mode.sim_interactive' , True ):
1037+ with option_context ('mode.sim_interactive' , True ,
1038+ 'display.max_columns' , 20 ):
10341039 max_cols = get_option ('display.max_columns' )
10351040 midx = MultiIndex .from_arrays (tm .rands_array (5 , size = (2 , 10 )))
10361041 mcols = MultiIndex .from_arrays (
@@ -1044,15 +1049,16 @@ def test_wide_repr_multiindex_cols(self):
10441049 wide_repr = repr (df )
10451050 assert rep_str != wide_repr
10461051
1047- with option_context ('display.width' , 150 ):
1052+ with option_context ('display.width' , 150 , 'display.max_columns' , 20 ):
10481053 wider_repr = repr (df )
10491054 assert len (wider_repr ) < len (wide_repr )
10501055
10511056 reset_option ('display.expand_frame_repr' )
10521057
10531058 def test_wide_repr_unicode (self ):
1054- with option_context ('mode.sim_interactive' , True ):
1055- max_cols = get_option ('display.max_columns' )
1059+ with option_context ('mode.sim_interactive' , True ,
1060+ 'display.max_columns' , 20 ):
1061+ max_cols = 20
10561062 df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
10571063 set_option ('display.expand_frame_repr' , False )
10581064 rep_str = repr (df )
@@ -1442,17 +1448,17 @@ def test_repr_html_mathjax(self):
14421448 assert 'tex2jax_ignore' in df ._repr_html_ ()
14431449
14441450 def test_repr_html_wide (self ):
1445- max_cols = get_option ( 'display.max_columns' )
1451+ max_cols = 20
14461452 df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
1447- reg_repr = df . _repr_html_ ()
1448- assert "..." not in reg_repr
1453+ with option_context ( 'display.max_rows' , 60 , 'display.max_columns' , 20 ):
1454+ assert "..." not in df . _repr_html_ ()
14491455
14501456 wide_df = DataFrame (tm .rands_array (25 , size = (10 , max_cols + 1 )))
1451- wide_repr = wide_df . _repr_html_ ()
1452- assert "..." in wide_repr
1457+ with option_context ( 'display.max_rows' , 60 , 'display.max_columns' , 20 ):
1458+ assert "..." in wide_df . _repr_html_ ()
14531459
14541460 def test_repr_html_wide_multiindex_cols (self ):
1455- max_cols = get_option ( 'display.max_columns' )
1461+ max_cols = 20
14561462
14571463 mcols = MultiIndex .from_product ([np .arange (max_cols // 2 ),
14581464 ['foo' , 'bar' ]],
@@ -1467,8 +1473,8 @@ def test_repr_html_wide_multiindex_cols(self):
14671473 names = ['first' , 'second' ])
14681474 df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
14691475 columns = mcols )
1470- wide_repr = df . _repr_html_ ()
1471- assert '...' in wide_repr
1476+ with option_context ( 'display.max_rows' , 60 , 'display.max_columns' , 20 ):
1477+ assert '...' in df . _repr_html_ ()
14721478
14731479 def test_repr_html_long (self ):
14741480 with option_context ('display.max_rows' , 60 ):
@@ -1512,14 +1518,15 @@ def test_repr_html_float(self):
15121518 assert u ('2 columns' ) in long_repr
15131519
15141520 def test_repr_html_long_multiindex (self ):
1515- max_rows = get_option ( 'display.max_rows' )
1521+ max_rows = 60
15161522 max_L1 = max_rows // 2
15171523
15181524 tuples = list (itertools .product (np .arange (max_L1 ), ['foo' , 'bar' ]))
15191525 idx = MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
15201526 df = DataFrame (np .random .randn (max_L1 * 2 , 2 ), index = idx ,
15211527 columns = ['A' , 'B' ])
1522- reg_repr = df ._repr_html_ ()
1528+ with option_context ('display.max_rows' , 60 , 'display.max_columns' , 20 ):
1529+ reg_repr = df ._repr_html_ ()
15231530 assert '...' not in reg_repr
15241531
15251532 tuples = list (itertools .product (np .arange (max_L1 + 1 ), ['foo' , 'bar' ]))
@@ -1530,20 +1537,22 @@ def test_repr_html_long_multiindex(self):
15301537 assert '...' in long_repr
15311538
15321539 def test_repr_html_long_and_wide (self ):
1533- max_cols = get_option ( 'display.max_columns' )
1534- max_rows = get_option ( 'display.max_rows' )
1540+ max_cols = 20
1541+ max_rows = 60
15351542
15361543 h , w = max_rows - 1 , max_cols - 1
15371544 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
1538- assert '...' not in df ._repr_html_ ()
1545+ with option_context ('display.max_rows' , 60 , 'display.max_columns' , 20 ):
1546+ assert '...' not in df ._repr_html_ ()
15391547
15401548 h , w = max_rows + 1 , max_cols + 1
15411549 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
1542- assert '...' in df ._repr_html_ ()
1550+ with option_context ('display.max_rows' , 60 , 'display.max_columns' , 20 ):
1551+ assert '...' in df ._repr_html_ ()
15431552
15441553 def test_info_repr (self ):
1545- max_rows = get_option ( 'display.max_rows' )
1546- max_cols = get_option ( 'display.max_columns' )
1554+ max_rows = 60
1555+ max_cols = 20
15471556 # Long
15481557 h , w = max_rows + 1 , max_cols - 1
15491558 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
@@ -1555,7 +1564,8 @@ def test_info_repr(self):
15551564 h , w = max_rows - 1 , max_cols + 1
15561565 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
15571566 assert has_horizontally_truncated_repr (df )
1558- with option_context ('display.large_repr' , 'info' ):
1567+ with option_context ('display.large_repr' , 'info' ,
1568+ 'display.max_columns' , max_cols ):
15591569 assert has_info_repr (df )
15601570
15611571 def test_info_repr_max_cols (self ):
@@ -1575,8 +1585,8 @@ def test_info_repr_max_cols(self):
15751585 # fmt.set_option('display.max_info_columns', 4) # exceeded
15761586
15771587 def test_info_repr_html (self ):
1578- max_rows = get_option ( 'display.max_rows' )
1579- max_cols = get_option ( 'display.max_columns' )
1588+ max_rows = 60
1589+ max_cols = 20
15801590 # Long
15811591 h , w = max_rows + 1 , max_cols - 1
15821592 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
@@ -1588,7 +1598,8 @@ def test_info_repr_html(self):
15881598 h , w = max_rows - 1 , max_cols + 1
15891599 df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
15901600 assert '<class' not in df ._repr_html_ ()
1591- with option_context ('display.large_repr' , 'info' ):
1601+ with option_context ('display.large_repr' , 'info' ,
1602+ 'display.max_columns' , max_cols ):
15921603 assert '<class' in df ._repr_html_ ()
15931604
15941605 def test_fake_qtconsole_repr_html (self ):
0 commit comments