@@ -142,17 +142,17 @@ def etable(
142142 """
143143 if signif_code is None :
144144 signif_code = [0.001 , 0.01 , 0.05 ]
145- assert (
146- isinstance ( signif_code , list ) and len ( signif_code ) == 3
147- ), "signif_code must be a list of length 3"
145+ assert isinstance ( signif_code , list ) and len ( signif_code ) == 3 , (
146+ " signif_code must be a list of length 3"
147+ )
148148 if signif_code :
149- assert all (
150- [ 0 < i < 1 for i in signif_code ]
151- ), "All values of signif_code must be between 0 and 1"
149+ assert all ([ 0 < i < 1 for i in signif_code ]), (
150+ "All values of signif_code must be between 0 and 1"
151+ )
152152 if signif_code :
153- assert (
154- signif_code [ 0 ] < signif_code [ 1 ] < signif_code [ 2 ]
155- ), "signif_code must be in increasing order"
153+ assert signif_code [ 0 ] < signif_code [ 1 ] < signif_code [ 2 ], (
154+ " signif_code must be in increasing order"
155+ )
156156
157157 models = _post_processing_input_checks (models )
158158
@@ -166,12 +166,12 @@ def etable(
166166 if custom_stats :
167167 assert isinstance (custom_stats , dict ), "custom_stats must be a dict"
168168 for key in custom_stats :
169- assert isinstance (
170- custom_stats [ key ], list
171- ), "custom_stats values must be a list"
172- assert len (custom_stats [key ]) == len (
173- models
174- ), f"custom_stats { key } must have the same number as models"
169+ assert isinstance (custom_stats [ key ], list ), (
170+ " custom_stats values must be a list"
171+ )
172+ assert len (custom_stats [key ]) == len (models ), (
173+ f"custom_stats { key } must have the same number as models"
174+ )
175175
176176 assert type in [
177177 "df" ,
@@ -182,9 +182,9 @@ def etable(
182182 ], "type must be either 'df', 'md', 'html', 'gt' or 'tex'"
183183
184184 if model_heads is not None :
185- assert len (model_heads ) == len (
186- models
187- ), "model_heads must have the same length as models"
185+ assert len (model_heads ) == len (models ), (
186+ "model_heads must have the same length as models"
187+ )
188188
189189 # Check if head_order is allowed string & remove h when no model_heads provided
190190 assert head_order in [
@@ -203,9 +203,9 @@ def etable(
203203 for stat , values in custom_model_stats .items ():
204204 assert isinstance (stat , str ), "custom_model_stats keys must be strings"
205205 assert isinstance (values , list ), "custom_model_stats values must lists"
206- assert len (values ) == len (
207- models
208- ), "lists in custom_model_stats values must have the same length as models"
206+ assert len (values ) == len (models ), (
207+ "lists in custom_model_stats values must have the same length as models"
208+ )
209209
210210 dep_var_list = []
211211 nobs_list = []
@@ -336,9 +336,11 @@ def etable(
336336 _number_formatter , ** kwargs
337337 )
338338 elif element in custom_stats :
339- assert (
340- len (custom_stats [element ][i ]) == len (model_tidy_df ["Estimate" ])
341- ), f"custom_stats { element } has unequal length to the number of coefficients in model_tidy_df { i } "
339+ assert len (custom_stats [element ][i ]) == len (
340+ model_tidy_df ["Estimate" ]
341+ ), (
342+ f"custom_stats { element } has unequal length to the number of coefficients in model_tidy_df { i } "
343+ )
342344 model_tidy_df [coef_fmt_title ] += pd .Series (
343345 custom_stats [element ][i ]
344346 ).apply (_number_formatter , ** kwargs )
@@ -357,7 +359,7 @@ def etable(
357359 model_tidy_df ,
358360 id_vars = ["Coefficient" ],
359361 var_name = "Metric" ,
360- value_name = f"est{ i + 1 } " ,
362+ value_name = f"est{ i + 1 } " ,
361363 )
362364 model_tidy_df = model_tidy_df .drop ("Metric" , axis = 1 ).set_index ("Coefficient" )
363365 etable_list .append (model_tidy_df )
@@ -833,9 +835,9 @@ def make_table(
833835 A table in the specified format.
834836 """
835837 assert isinstance (df , pd .DataFrame ), "df must be a pandas DataFrame."
836- assert (
837- not isinstance ( df . index , pd . MultiIndex ) or df . index . nlevels <= 2
838- ), "Row index can have at most two levels."
838+ assert not isinstance ( df . index , pd . MultiIndex ) or df . index . nlevels <= 2 , (
839+ "Row index can have at most two levels."
840+ )
839841 assert type in ["gt" , "tex" ], "type must be either 'gt' or 'tex'."
840842 assert rgroup_sep in [
841843 "tb" ,
@@ -1250,16 +1252,16 @@ def dtable(
12501252 if stats_labels is None :
12511253 stats_labels = {}
12521254 assert isinstance (df , pd .DataFrame ), "df must be a pandas DataFrame."
1253- assert all (
1254- pd . api . types . is_numeric_dtype ( df [ var ]) for var in vars
1255- ), "Variables must be numerical."
1255+ assert all (pd . api . types . is_numeric_dtype ( df [ var ]) for var in vars ), (
1256+ "Variables must be numerical."
1257+ )
12561258 assert type in ["gt" , "tex" , "df" ], "type must be either 'gt' or 'tex' or 'df'."
1257- assert (
1258- byrow is None or byrow in df . columns
1259- ), "byrow must be a column in the DataFrame."
1260- assert bycol is None or all (
1261- col in df . columns for col in bycol
1262- ), "bycol must be a list of columns in the DataFrame."
1259+ assert byrow is None or byrow in df . columns , (
1260+ " byrow must be a column in the DataFrame."
1261+ )
1262+ assert bycol is None or all (col in df . columns for col in bycol ), (
1263+ "bycol must be a list of columns in the DataFrame."
1264+ )
12631265
12641266 # Default stats labels dictionary
12651267 stats_dict = {
0 commit comments