rename piecewise_regression_on_path to simplify_path

This commit is contained in:
Pim Nelissen
2026-01-28 08:59:05 +01:00
parent d162f9fee3
commit ffb7aa0541

View File

@ -43,13 +43,14 @@ class Path:
self, self,
coord_list: Sequence[tuple[float, float]], coord_list: Sequence[tuple[float, float]],
z: float = 0, z: float = 0,
simplify_path = False path_simplify = False
): ):
"""Construct a path of sequences based on a list of coordinates. """Construct a path of sequences based on a list of coordinates.
Args: Args:
coord_list (Sequence[tuple[float, float]]): List of x,y coordinates. coord_list (Sequence[tuple[float, float]]): List of x,y coordinates.
z (float, optional): Height of the path. Defaults to 0. z (float, optional): Height of the path. Defaults to 0.
path_simplify (bool, optional): Whether to pg_rad.path.simplify_path(). Defaults to False.
""" """
if len(coord_list) < 2: if len(coord_list) < 2:
@ -57,9 +58,9 @@ class Path:
x, y = tuple(zip(*coord_list)) x, y = tuple(zip(*coord_list))
if simplify_path: if path_simplify:
try: try:
x, y = piecewise_regression_on_path(list(x), list(y)) x, y = simplify_path(list(x), list(y))
except ConvergenceError: except ConvergenceError:
logger.warning("Continuing without simplifying path.") logger.warning("Continuing without simplifying path.")
@ -89,7 +90,7 @@ class Path:
""" """
plt.plot(self.x_list, self.y_list, **kwargs) plt.plot(self.x_list, self.y_list, **kwargs)
def piecewise_regression_on_path( def simplify_path(
x: Sequence[float], x: Sequence[float],
y: Sequence[float], y: Sequence[float],
keep_endpoints_equal: bool = False, keep_endpoints_equal: bool = False,