@@ -121,3 +121,59 @@ def test_customcell():
121121 cell = CustomCell ((0 , 0 ), visible_edges = t , width = 1 , height = 1 )
122122 code = tuple (s for _ , s in cell .get_path ().iter_segments ())
123123 assert_equal (c , code )
124+
125+
126+ @image_comparison (baseline_images = ['table_auto_column' ],
127+ extensions = ['png' ])
128+ def test_auto_column ():
129+ fig = plt .figure ()
130+
131+ #iteratble list input
132+ ax1 = fig .add_subplot (4 , 1 , 1 )
133+ ax1 .axis ('off' )
134+ tb1 = ax1 .table (cellText = [['Fit Text' , 2 ],
135+ ['very long long text, Longer text than default' , 1 ]],
136+ rowLabels = ["A" , "B" ],
137+ colLabels = ["Col1" , "Col2" ],
138+ loc = "center" )
139+ tb1 .auto_set_font_size (False )
140+ tb1 .set_fontsize (12 )
141+ tb1 .auto_set_column_width ([- 1 , 0 , 1 ])
142+
143+ #iteratble tuple input
144+ ax2 = fig .add_subplot (4 , 1 , 2 )
145+ ax2 .axis ('off' )
146+ tb2 = ax2 .table (cellText = [['Fit Text' , 2 ],
147+ ['very long long text, Longer text than default' , 1 ]],
148+ rowLabels = ["A" , "B" ],
149+ colLabels = ["Col1" , "Col2" ],
150+ loc = "center" )
151+ tb2 .auto_set_font_size (False )
152+ tb2 .set_fontsize (12 )
153+ tb2 .auto_set_column_width ((- 1 , 0 , 1 ))
154+
155+ #3 single inputs
156+ ax3 = fig .add_subplot (4 , 1 , 3 )
157+ ax3 .axis ('off' )
158+ tb3 = ax3 .table (cellText = [['Fit Text' , 2 ],
159+ ['very long long text, Longer text than default' , 1 ]],
160+ rowLabels = ["A" , "B" ],
161+ colLabels = ["Col1" , "Col2" ],
162+ loc = "center" )
163+ tb3 .auto_set_font_size (False )
164+ tb3 .set_fontsize (12 )
165+ tb3 .auto_set_column_width (- 1 )
166+ tb3 .auto_set_column_width (0 )
167+ tb3 .auto_set_column_width (1 )
168+
169+ #4 non integer interable input
170+ ax4 = fig .add_subplot (4 , 1 , 4 )
171+ ax4 .axis ('off' )
172+ tb4 = ax4 .table (cellText = [['Fit Text' , 2 ],
173+ ['very long long text, Longer text than default' , 1 ]],
174+ rowLabels = ["A" , "B" ],
175+ colLabels = ["Col1" , "Col2" ],
176+ loc = "center" )
177+ tb4 .auto_set_font_size (False )
178+ tb4 .set_fontsize (12 )
179+ tb4 .auto_set_column_width ("-101" )
0 commit comments