add Cython profiling option for later use (currently not working)

This commit is contained in:
2025-10-23 13:55:24 +02:00
parent 26563dcfde
commit 4b42f0f03a
4 changed files with 972 additions and 60 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ def measure_length(
cnts = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
if cnts is None:
if cnts is None: # pragma: no cover
raise errors.ContourCalculationError(
"No contours were found in the provided image. Can not continue analysis."
)
@@ -82,7 +82,7 @@ def measure_length(
cnts, _ = contours.sort_contours(cnts)
x_coords = [cv2.boundingRect(c)[0] for c in cnts]
is_sorted = np.all(x1 <= x2 for x1, x2 in zip(x_coords, x_coords[1:])) # type: ignore
if not is_sorted:
if not is_sorted: # pragma: no cover
raise errors.ContourCalculationError(
"Contour detection not valid: contours are not "
"properly sorted from left to right."
@@ -128,13 +128,13 @@ def measure_length(
]
)
if not filtered_cnts:
if not filtered_cnts: # pragma: no cover
raise errors.ContourCalculationError(
"Contour detection not valid: no contours recognized"
)
num_contours = len(filtered_cnts)
if num_contours != const.NUM_VALID_ELECTRODES:
if num_contours != const.NUM_VALID_ELECTRODES: # pragma: no cover
raise errors.InvalidElectrodeCount(
f"Number of counted electrodes does not match the "
f"expected value: count = {num_contours}, expected = {const.NUM_VALID_ELECTRODES}"