generated from dopt-python/py311
add Cython profiling option for later use (currently not working)
This commit is contained in:
parent
26563dcfde
commit
4b42f0f03a
@ -53,6 +53,7 @@ log_cli = true
|
|||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
relative_files = true
|
relative_files = true
|
||||||
|
plugins = ["Cython.Coverage"]
|
||||||
source = [
|
source = [
|
||||||
"src/",
|
"src/",
|
||||||
"tests/",
|
"tests/",
|
||||||
|
|||||||
8
setup.py
8
setup.py
@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from Cython.Build import cythonize
|
from Cython.Build import cythonize
|
||||||
from Cython.Compiler import Options
|
from Cython.Compiler import Options
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
@ -13,8 +15,14 @@ ext_modules = cythonize(
|
|||||||
"language_level": 3,
|
"language_level": 3,
|
||||||
"embedsignature": False,
|
"embedsignature": False,
|
||||||
"annotation_typing": True,
|
"annotation_typing": True,
|
||||||
|
"linetrace": True,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
DEBUG = bool(os.getenv("DOPT_DEBUG", None))
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
ext_modules[0].define_macros.append(("CYTHON_TRACE", "1"))
|
||||||
|
|
||||||
setup(ext_modules=ext_modules)
|
setup(ext_modules=ext_modules)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,7 @@ def measure_length(
|
|||||||
|
|
||||||
cnts = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
cnts = cv2.findContours(edged.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
cnts = imutils.grab_contours(cnts)
|
cnts = imutils.grab_contours(cnts)
|
||||||
if cnts is None:
|
if cnts is None: # pragma: no cover
|
||||||
raise errors.ContourCalculationError(
|
raise errors.ContourCalculationError(
|
||||||
"No contours were found in the provided image. Can not continue analysis."
|
"No contours were found in the provided image. Can not continue analysis."
|
||||||
)
|
)
|
||||||
@ -82,7 +82,7 @@ def measure_length(
|
|||||||
cnts, _ = contours.sort_contours(cnts)
|
cnts, _ = contours.sort_contours(cnts)
|
||||||
x_coords = [cv2.boundingRect(c)[0] for c in 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
|
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(
|
raise errors.ContourCalculationError(
|
||||||
"Contour detection not valid: contours are not "
|
"Contour detection not valid: contours are not "
|
||||||
"properly sorted from left to right."
|
"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(
|
raise errors.ContourCalculationError(
|
||||||
"Contour detection not valid: no contours recognized"
|
"Contour detection not valid: no contours recognized"
|
||||||
)
|
)
|
||||||
|
|
||||||
num_contours = len(filtered_cnts)
|
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(
|
raise errors.InvalidElectrodeCount(
|
||||||
f"Number of counted electrodes does not match the "
|
f"Number of counted electrodes does not match the "
|
||||||
f"expected value: count = {num_contours}, expected = {const.NUM_VALID_ELECTRODES}"
|
f"expected value: count = {num_contours}, expected = {const.NUM_VALID_ELECTRODES}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user