@@ -961,7 +961,8 @@ def test_pprint_thing(self):
961
961
962
962
def test_wide_repr (self ):
963
963
with option_context ('mode.sim_interactive' , True ,
964
- 'display.show_dimensions' , True ):
964
+ 'display.show_dimensions' , True ,
965
+ 'display.max_columns' , 20 ):
965
966
max_cols = get_option ('display.max_columns' )
966
967
df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
967
968
set_option ('display.expand_frame_repr' , False )
@@ -979,15 +980,17 @@ def test_wide_repr(self):
979
980
reset_option ('display.expand_frame_repr' )
980
981
981
982
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 ):
983
985
df = DataFrame (np .random .randn (5 , 3 ),
984
986
columns = ['a' * 90 , 'b' * 90 , 'c' * 90 ])
985
987
rep_str = repr (df )
986
988
987
989
assert len (rep_str .splitlines ()) == 20
988
990
989
991
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 ):
991
994
max_cols = get_option ('display.max_columns' )
992
995
df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
993
996
df .index .name = 'DataFrame Index'
@@ -1008,7 +1011,8 @@ def test_wide_repr_named(self):
1008
1011
reset_option ('display.expand_frame_repr' )
1009
1012
1010
1013
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 ):
1012
1016
midx = MultiIndex .from_arrays (tm .rands_array (5 , size = (2 , 10 )))
1013
1017
max_cols = get_option ('display.max_columns' )
1014
1018
df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )),
@@ -1030,7 +1034,8 @@ def test_wide_repr_multiindex(self):
1030
1034
reset_option ('display.expand_frame_repr' )
1031
1035
1032
1036
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 ):
1034
1039
max_cols = get_option ('display.max_columns' )
1035
1040
midx = MultiIndex .from_arrays (tm .rands_array (5 , size = (2 , 10 )))
1036
1041
mcols = MultiIndex .from_arrays (
@@ -1044,15 +1049,16 @@ def test_wide_repr_multiindex_cols(self):
1044
1049
wide_repr = repr (df )
1045
1050
assert rep_str != wide_repr
1046
1051
1047
- with option_context ('display.width' , 150 ):
1052
+ with option_context ('display.width' , 150 , 'display.max_columns' , 20 ):
1048
1053
wider_repr = repr (df )
1049
1054
assert len (wider_repr ) < len (wide_repr )
1050
1055
1051
1056
reset_option ('display.expand_frame_repr' )
1052
1057
1053
1058
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
1056
1062
df = DataFrame (tm .rands_array (25 , size = (10 , max_cols - 1 )))
1057
1063
set_option ('display.expand_frame_repr' , False )
1058
1064
rep_str = repr (df )
@@ -1442,17 +1448,17 @@ def test_repr_html_mathjax(self):
1442
1448
assert 'tex2jax_ignore' in df ._repr_html_ ()
1443
1449
1444
1450
def test_repr_html_wide (self ):
1445
- max_cols = get_option ( 'display.max_columns' )
1451
+ max_cols = 20
1446
1452
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_ ()
1449
1455
1450
1456
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_ ()
1453
1459
1454
1460
def test_repr_html_wide_multiindex_cols (self ):
1455
- max_cols = get_option ( 'display.max_columns' )
1461
+ max_cols = 20
1456
1462
1457
1463
mcols = MultiIndex .from_product ([np .arange (max_cols // 2 ),
1458
1464
['foo' , 'bar' ]],
@@ -1467,8 +1473,8 @@ def test_repr_html_wide_multiindex_cols(self):
1467
1473
names = ['first' , 'second' ])
1468
1474
df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
1469
1475
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_ ()
1472
1478
1473
1479
def test_repr_html_long (self ):
1474
1480
with option_context ('display.max_rows' , 60 ):
@@ -1512,14 +1518,15 @@ def test_repr_html_float(self):
1512
1518
assert u ('2 columns' ) in long_repr
1513
1519
1514
1520
def test_repr_html_long_multiindex (self ):
1515
- max_rows = get_option ( 'display.max_rows' )
1521
+ max_rows = 60
1516
1522
max_L1 = max_rows // 2
1517
1523
1518
1524
tuples = list (itertools .product (np .arange (max_L1 ), ['foo' , 'bar' ]))
1519
1525
idx = MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
1520
1526
df = DataFrame (np .random .randn (max_L1 * 2 , 2 ), index = idx ,
1521
1527
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_ ()
1523
1530
assert '...' not in reg_repr
1524
1531
1525
1532
tuples = list (itertools .product (np .arange (max_L1 + 1 ), ['foo' , 'bar' ]))
@@ -1530,20 +1537,22 @@ def test_repr_html_long_multiindex(self):
1530
1537
assert '...' in long_repr
1531
1538
1532
1539
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
1535
1542
1536
1543
h , w = max_rows - 1 , max_cols - 1
1537
1544
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_ ()
1539
1547
1540
1548
h , w = max_rows + 1 , max_cols + 1
1541
1549
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_ ()
1543
1552
1544
1553
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
1547
1556
# Long
1548
1557
h , w = max_rows + 1 , max_cols - 1
1549
1558
df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
@@ -1555,7 +1564,8 @@ def test_info_repr(self):
1555
1564
h , w = max_rows - 1 , max_cols + 1
1556
1565
df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
1557
1566
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 ):
1559
1569
assert has_info_repr (df )
1560
1570
1561
1571
def test_info_repr_max_cols (self ):
@@ -1575,8 +1585,8 @@ def test_info_repr_max_cols(self):
1575
1585
# fmt.set_option('display.max_info_columns', 4) # exceeded
1576
1586
1577
1587
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
1580
1590
# Long
1581
1591
h , w = max_rows + 1 , max_cols - 1
1582
1592
df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
@@ -1588,7 +1598,8 @@ def test_info_repr_html(self):
1588
1598
h , w = max_rows - 1 , max_cols + 1
1589
1599
df = DataFrame ({k : np .arange (1 , 1 + h ) for k in np .arange (w )})
1590
1600
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 ):
1592
1603
assert '<class' in df ._repr_html_ ()
1593
1604
1594
1605
def test_fake_qtconsole_repr_html (self ):
0 commit comments