replace multi-step list initialization with list literal

code-suggestions
cneud 1 week ago
parent 5326104d26
commit b9030f5203

@ -135,8 +135,7 @@ def return_x_start_end_mothers_childs_and_type_of_reading_order(
min_ys=np.min(y_sep)
max_ys=np.max(y_sep)
y_mains=[]
y_mains.append(min_ys)
y_mains= [min_ys]
y_mains_sep_ohne_grenzen=[]
for ii in range(len(new_main_sep_y)):
@ -492,8 +491,7 @@ def find_num_col(regions_without_separators, num_col_classifier, tables, multipl
# print(forest[np.argmin(z[forest]) ] )
if not isNaN(forest[np.argmin(z[forest])]):
peaks_neg_true.append(forest[np.argmin(z[forest])])
forest = []
forest.append(peaks_neg_fin[i + 1])
forest = [peaks_neg_fin[i + 1]]
if i == (len(peaks_neg_fin) - 1):
# print(print(forest[np.argmin(z[forest]) ] ))
if not isNaN(forest[np.argmin(z[forest])]):
@ -661,8 +659,7 @@ def find_num_col_only_image(regions_without_separators, multiplier=3.8):
# print(forest[np.argmin(z[forest]) ] )
if not isNaN(forest[np.argmin(z[forest])]):
peaks_neg_true.append(forest[np.argmin(z[forest])])
forest = []
forest.append(peaks_neg_fin[i + 1])
forest = [peaks_neg_fin[i + 1]]
if i == (len(peaks_neg_fin) - 1):
# print(print(forest[np.argmin(z[forest]) ] ))
if not isNaN(forest[np.argmin(z[forest])]):
@ -1219,8 +1216,7 @@ def order_of_regions(textline_mask, contours_main, contours_header, y_ref):
y_max_header = np.array([np.max(contours_header[j][:, 0, 1]) for j in range(len(contours_header))])
# print(cy_main,'mainy')
peaks_neg_new = []
peaks_neg_new.append(0 + y_ref)
peaks_neg_new = [0 + y_ref]
for iii in range(len(peaks_neg)):
peaks_neg_new.append(peaks_neg[iii] + y_ref)
peaks_neg_new.append(textline_mask.shape[0] + y_ref)
@ -1388,8 +1384,7 @@ def combine_hor_lines_and_delete_cross_points_and_get_lines_features_back_new(
return img_p_in[:,:,0], special_separators
def return_points_with_boundies(peaks_neg_fin, first_point, last_point):
peaks_neg_tot = []
peaks_neg_tot.append(first_point)
peaks_neg_tot = [first_point]
for ii in range(len(peaks_neg_fin)):
peaks_neg_tot.append(peaks_neg_fin[ii])
peaks_neg_tot.append(last_point)
@ -1571,8 +1566,7 @@ def find_number_of_columns_in_document(region_pre_p, num_col_classifier, tables,
args_cy_splitter=np.argsort(cy_main_splitters)
cy_main_splitters_sort=cy_main_splitters[args_cy_splitter]
splitter_y_new=[]
splitter_y_new.append(0)
splitter_y_new= [0]
for i in range(len(cy_main_splitters_sort)):
splitter_y_new.append( cy_main_splitters_sort[i] )
splitter_y_new.append(region_pre_p.shape[0])
@ -1646,8 +1640,7 @@ def return_boxes_of_images_by_order_of_reading_new(
num_col, peaks_neg_fin = find_num_col(
regions_without_separators[int(splitter_y_new[i]):int(splitter_y_new[i+1]),:],
num_col_classifier, tables, multiplier=3.)
peaks_neg_fin_early=[]
peaks_neg_fin_early.append(0)
peaks_neg_fin_early= [0]
#print(peaks_neg_fin,'peaks_neg_fin')
for p_n in peaks_neg_fin:
peaks_neg_fin_early.append(p_n)

@ -1180,8 +1180,7 @@ def separate_lines_new_inside_tiles(img_path, thetha):
# print(forest[np.argmin(z[forest]) ] )
if not np.isnan(forest[np.argmin(z[forest])]):
peaks_neg_true.append(forest[np.argmin(z[forest])])
forest = []
forest.append(peaks_neg[i + 1])
forest = [peaks_neg[i + 1]]
if i == (len(peaks_neg) - 1):
# print(print(forest[np.argmin(z[forest]) ] ))
if not np.isnan(forest[np.argmin(z[forest])]):
@ -1203,8 +1202,7 @@ def separate_lines_new_inside_tiles(img_path, thetha):
# print(forest[np.argmin(z[forest]) ] )
if not np.isnan(forest[np.argmax(z[forest])]):
peaks_pos_true.append(forest[np.argmax(z[forest])])
forest = []
forest.append(peaks[i + 1])
forest = [peaks[i + 1]]
if i == (len(peaks) - 1):
# print(print(forest[np.argmin(z[forest]) ] ))
if not np.isnan(forest[np.argmax(z[forest])]):

Loading…
Cancel
Save