Skip to content

Commit 7f31a06

Browse files
committed
Some LGTM fixes and potential bugfixes
1 parent b96df3a commit 7f31a06

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/ccutil/unicharmap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ UNICHAR_ID UNICHARMAP::unichar_to_id(const char* const unichar_repr,
3939
assert(length > 0 && length <= UNICHAR_LEN);
4040

4141
int index = 0;
42-
if (index >= length || unichar_repr[index] == '\0') return INVALID_UNICHAR_ID;
42+
if (unichar_repr[index] == '\0') return INVALID_UNICHAR_ID;
4343
do {
4444
if (index + 1 >= length || unichar_repr[index + 1] == '\0')
4545
return current_nodes[static_cast<unsigned char>(unichar_repr[index])].id;

src/classify/trainingsampleset.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ void TrainingSampleSet::ComputeCanonicalSamples(const IntFeatureMap& map,
618618
if (dist > max_dist) {
619619
max_dist = dist;
620620
if (dist > max_max_dist) {
621+
max_max_dist = dist;
621622
max_s1 = s1;
622623
max_s2 = s2;
623624
}

src/training/tesstrain_utils.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def __init__(self):
5656
self.extract_font_properties = True
5757
self.distort_image = False
5858

59+
def __eq__(self, other):
60+
return (argparse.Namespace.__eq__(self, other) and
61+
self.uname = other.uname and self.lang_code = other.lang_code and
62+
self.timestamp = other.timestamp and self.font_config_cache = other.font_config_cache and
63+
self.fonts_dir = other.fonts_dir and self.max_pages = other.max_pages and
64+
self.save_box_tiff = other.save_box_tiff and self.overwrite = other.overwrite and
65+
self.linedata = other.linedata and self.run_shape_clustering = other.run_shape_clustering and
66+
self.extract_font_properties = other.extract_font_properties and
67+
self.distort_image = other.distort_image)
68+
5969

6070
def err_exit(msg):
6171
log.critical(msg)
@@ -356,7 +366,7 @@ def generate_font_image(ctx, font, exposure, char_spacing):
356366

357367

358368
# Phase I : Generate (I)mages from training text for each font.
359-
def phase_I_generate_image(ctx, par_factor):
369+
def phase_I_generate_image(ctx, par_factor=None):
360370
if not par_factor or par_factor <= 0:
361371
par_factor = 1
362372

@@ -386,7 +396,7 @@ def phase_I_generate_image(ctx, par_factor):
386396

387397
with tqdm(
388398
total=len(ctx.fonts)
389-
) as pbar, concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
399+
) as pbar, concurrent.futures.ThreadPoolExecutor(max_workers=par_factor) as executor:
390400
futures = [
391401
executor.submit(generate_font_image, ctx, font, exposure, char_spacing)
392402
for font in ctx.fonts

0 commit comments

Comments
 (0)