From 3fd57efbb05a4f3c0a61f0bf07313b041305217d Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Thu, 12 Sep 2024 14:10:33 +0200 Subject: [PATCH] Use max instead of if-else for numerical checks (as per linter warning) --- src/Mod/Draft/draftgeoutils/geo_arrays.py | 5 ++--- src/Mod/Draft/draftobjects/patharray.py | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/draftgeoutils/geo_arrays.py b/src/Mod/Draft/draftgeoutils/geo_arrays.py index dee2ba3d52..a39c29a1a2 100644 --- a/src/Mod/Draft/draftgeoutils/geo_arrays.py +++ b/src/Mod/Draft/draftgeoutils/geo_arrays.py @@ -64,7 +64,7 @@ def get_init_values(path, count=6): edge = path.Shape.Edges[0] edge_length = edge.Length - n = (count - 1) if count > 1 else 1 + n = max((count - 1), 1) step = edge_length / n inc = 360 / n @@ -85,8 +85,7 @@ def get_n_params(edge, number, step, norm): def get_twisted_placements(path, count=15, rot_factor=0.25): """Get the placements of the twisted array elements.""" - if count < 1: - count = 1 + count = max(count, 1) (norm, edge, step, inc) = get_init_values(path, count) diff --git a/src/Mod/Draft/draftobjects/patharray.py b/src/Mod/Draft/draftobjects/patharray.py index 79466a5796..5941e8d57b 100644 --- a/src/Mod/Draft/draftobjects/patharray.py +++ b/src/Mod/Draft/draftobjects/patharray.py @@ -475,11 +475,9 @@ def placements_on_path(shapeRotation, pathwire, count, xlate, align, end = endOffset cdist = cdist - start - end - if count < 1: - count = 1 + count = max(count, 1) n = count if (DraftGeomUtils.isReallyClosed(pathwire) and not (start or end)) else count - 1 - if n == 0: - n = 1 + n = max(n, 1) step = cdist / n remains = 0 travel = start