Skip to content

Commit a80651a

Browse files
committed
fixed pylint
1 parent 8c06dc8 commit a80651a

3 files changed

Lines changed: 17 additions & 23 deletions

File tree

ctc_metrics/metrics/biological/bc.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ def is_matching(
103103
# Check if start frames of the daughters are close enough <= i_max
104104
temporal_error = abs(t_ref - t_comp)
105105
if temporal_error > max_i:
106-
break
106+
continue
107107
# Verify if children are overlapping spatially
108108
t_max = max(t_ref, t_comp)
109+
# Check if the daughter match is unique, i.e. the computed track is only assigned to one gt
110+
if mapped_comp[t_max].count(j) != 1:
111+
continue
109112
if i in mapped_ref[t_max] and j in mapped_comp[t_max]:
110113
ind = mapped_ref[t_max].index(i)
111114
if mapped_comp[t_max][ind] == j:
112-
# Check if the daughter match is unique, i.e. the computed track is only assigned to one gt
113-
if mapped_comp[t_max].count(j) == 1:
114-
# There is a match!
115-
if j not in matched_children:
116-
matched_children.append(j)
117-
break
115+
# There is a match!
116+
if j not in matched_children:
117+
matched_children.append(j)
118+
break
119+
118120

119121
if len(matched_children) != len(ref_children):
120122
return False

ctc_metrics/scripts/evaluate.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import warnings
12
import argparse
23
from os.path import join, basename
34
from multiprocessing import Pool, cpu_count
45
import numpy as np
5-
import warnings
66

77
from ctc_metrics.metrics import (
88
valid, det, seg, tra, ct, tf, bc, raw_division_metrics, cca, mota, hota, idf1, chota, mtml, faf,
@@ -177,9 +177,7 @@ def calculate_metrics(
177177
for m in metrics:
178178
if m.startswith("BC("):
179179
try:
180-
i = int(m[3:-1])
181-
if i > max_i_for_bci:
182-
max_i_for_bci = i
180+
max_i_for_bci = max(max_i_for_bci, int(m[3:-1]))
183181
if "BC" not in metrics:
184182
metrics.append("BC")
185183
except ValueError:
@@ -426,12 +424,7 @@ def main():
426424
res = evaluate_sequence(
427425
res=args.res, gt=args.gt, metrics=metrics, threads=args.num_threads)
428426
# Visualize and store results
429-
print_out = res if type(res) is list else [(args.res, res)]
430-
for name, output in print_out:
431-
print("----------")
432-
print(f"{name}")
433-
for k,v in output.items():
434-
print(f"{k}: {v}")
427+
print_results(res)
435428
if args.csv_file is not None:
436429
store_results(args.csv_file, res)
437430

ctc_metrics/utils/handle_results.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@ def print_results(results: dict):
88
results: A dictionary containing the results.
99
"""
1010

11-
def print_line(metrics: dict):
11+
def print_block(metrics: dict):
1212
"""
1313
Prints a line of the table.
1414
1515
Args:
1616
metrics: A list containing the arguments for the line.
1717
"""
18-
19-
print(*[f"{k}: {'N/A' if v is None else float(v):.5},\t" for k, v
20-
in metrics.items()])
18+
for k, v in metrics.items():
19+
print(f"{k}: {'N/A' if v is None else float(v):.5}")
2120

2221
if isinstance(results, dict):
23-
print_line(results)
22+
print_block(results)
2423
elif isinstance(results, list):
2524
for res in results:
2625
print(res[0], end=":\t\t")
27-
print_line(res[1])
26+
print_block(res[1])
2827

2928

3029
def store_results(

0 commit comments

Comments
 (0)