Skip to content

Commit 8633e09

Browse files
committed
Handle edge cases in _generate_display_table()
1 parent 3cc44d6 commit 8633e09

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pointblank/validate.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,10 @@ def _generate_display_table(
14441444
column_values = gt.gt._get_column_of_values(built_gt, column_name=column, context="html")
14451445

14461446
# Get the maximum number of characters in the column
1447-
max_length_col_vals.append(max([len(str(val)) for val in column_values]))
1447+
if column_values: # Check if column_values is not empty
1448+
max_length_col_vals.append(max([len(str(val)) for val in column_values]))
1449+
else:
1450+
max_length_col_vals.append(0) # Use 0 for empty columns
14481451

14491452
length_col_names = [len(column) for column in col_dtype_dict.keys()]
14501453
length_data_types = [len(dtype) for dtype in col_dtype_dict_short.values()]
@@ -1515,8 +1518,12 @@ def _generate_display_table(
15151518

15161519
# Get the highest number in the `row_number_list` and calculate a width that will
15171520
# safely fit a number of that magnitude
1518-
max_row_num = max(row_number_list)
1519-
max_row_num_width = len(str(max_row_num)) * 7.8 + 10
1521+
if row_number_list: # Check if list is not empty
1522+
max_row_num = max(row_number_list)
1523+
max_row_num_width = len(str(max_row_num)) * 7.8 + 10
1524+
else:
1525+
# If row_number_list is empty, use a default width
1526+
max_row_num_width = 7.8 * 2 + 10 # Width for 2-digit numbers
15201527

15211528
# Update the col_width_dict to include the row number column
15221529
col_width_dict = {"_row_num_": f"{max_row_num_width}px"} | col_width_dict

0 commit comments

Comments
 (0)