@@ -1201,9 +1201,8 @@ def test_pprint_thing(self):
12011201
12021202 def test_wide_repr (self ):
12031203 with option_context ('mode.sim_interactive' , True , 'display.show_dimensions' , True ):
1204- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
12051204 max_cols = get_option ('display.max_columns' )
1206- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1205+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
12071206 set_option ('display.expand_frame_repr' , False )
12081207 rep_str = repr (df )
12091208
@@ -1227,9 +1226,8 @@ def test_wide_repr_wide_columns(self):
12271226
12281227 def test_wide_repr_named (self ):
12291228 with option_context ('mode.sim_interactive' , True ):
1230- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
12311229 max_cols = get_option ('display.max_columns' )
1232- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1230+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
12331231 df .index .name = 'DataFrame Index'
12341232 set_option ('display.expand_frame_repr' , False )
12351233
@@ -1249,11 +1247,10 @@ def test_wide_repr_named(self):
12491247
12501248 def test_wide_repr_multiindex (self ):
12511249 with option_context ('mode.sim_interactive' , True ):
1252- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1253- midx = pandas .MultiIndex .from_arrays ([np .array (col (10 , 5 )),
1254- np .array (col (10 , 5 ))])
1250+ midx = pandas .MultiIndex .from_arrays (
1251+ tm .rands_array (5 , size = (2 , 10 )))
12551252 max_cols = get_option ('display.max_columns' )
1256- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] ,
1253+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) ,
12571254 index = midx )
12581255 df .index .names = ['Level 0' , 'Level 1' ]
12591256 set_option ('display.expand_frame_repr' , False )
@@ -1274,12 +1271,11 @@ def test_wide_repr_multiindex(self):
12741271 def test_wide_repr_multiindex_cols (self ):
12751272 with option_context ('mode.sim_interactive' , True ):
12761273 max_cols = get_option ('display.max_columns' )
1277- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1278- midx = pandas .MultiIndex .from_arrays ([np .array (col (10 , 5 )),
1279- np .array (col (10 , 5 ))])
1280- mcols = pandas .MultiIndex .from_arrays ([np .array (col (max_cols - 1 , 3 )),
1281- np .array (col (max_cols - 1 , 3 ))])
1282- df = DataFrame ([col (max_cols - 1 , 25 ) for _ in range (10 )],
1274+ midx = pandas .MultiIndex .from_arrays (
1275+ tm .rands_array (5 , size = (2 , 10 )))
1276+ mcols = pandas .MultiIndex .from_arrays (
1277+ tm .rands_array (3 , size = (2 , max_cols - 1 )))
1278+ df = DataFrame (tm .rands_array (25 , (10 , max_cols - 1 )),
12831279 index = midx , columns = mcols )
12841280 df .index .names = ['Level 0' , 'Level 1' ]
12851281 set_option ('display.expand_frame_repr' , False )
@@ -1296,9 +1292,8 @@ def test_wide_repr_multiindex_cols(self):
12961292
12971293 def test_wide_repr_unicode (self ):
12981294 with option_context ('mode.sim_interactive' , True ):
1299- col = lambda l , k : [tm .randu (k ) for _ in range (l )]
13001295 max_cols = get_option ('display.max_columns' )
1301- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1296+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
13021297 set_option ('display.expand_frame_repr' , False )
13031298 rep_str = repr (df )
13041299 set_option ('display.expand_frame_repr' , True )
@@ -1877,30 +1872,31 @@ def test_repr_html(self):
18771872 self .reset_display_options ()
18781873
18791874 def test_repr_html_wide (self ):
1880- row = lambda l , k : [tm .rands (k ) for _ in range (l )]
18811875 max_cols = get_option ('display.max_columns' )
1882- df = DataFrame ([ row ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1876+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
18831877 reg_repr = df ._repr_html_ ()
18841878 assert "..." not in reg_repr
18851879
1886- wide_df = DataFrame ([ row ( max_cols + 1 , 25 ) for _ in range ( 10 )] )
1880+ wide_df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols + 1 )) )
18871881 wide_repr = wide_df ._repr_html_ ()
18881882 assert "..." in wide_repr
18891883
18901884 def test_repr_html_wide_multiindex_cols (self ):
1891- row = lambda l , k : [tm .rands (k ) for _ in range (l )]
18921885 max_cols = get_option ('display.max_columns' )
18931886
1894- tuples = list (itertools .product (np .arange (max_cols // 2 ), ['foo' , 'bar' ]))
1895- mcols = pandas .MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
1896- df = DataFrame ([row (len (mcols ), 25 ) for _ in range (10 )], columns = mcols )
1887+ mcols = pandas .MultiIndex .from_product ([np .arange (max_cols // 2 ),
1888+ ['foo' , 'bar' ]],
1889+ names = ['first' , 'second' ])
1890+ df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
1891+ columns = mcols )
18971892 reg_repr = df ._repr_html_ ()
18981893 assert '...' not in reg_repr
18991894
1900-
1901- tuples = list (itertools .product (np .arange (1 + (max_cols // 2 )), ['foo' , 'bar' ]))
1902- mcols = pandas .MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
1903- df = DataFrame ([row (len (mcols ), 25 ) for _ in range (10 )], columns = mcols )
1895+ mcols = pandas .MultiIndex .from_product ((np .arange (1 + (max_cols // 2 )),
1896+ ['foo' , 'bar' ]),
1897+ names = ['first' , 'second' ])
1898+ df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
1899+ columns = mcols )
19041900 wide_repr = df ._repr_html_ ()
19051901 assert '...' in wide_repr
19061902
0 commit comments