Use max instead of if-else for numerical checks (as per linter warning)

This commit is contained in:
Roy-043
2024-09-12 14:10:33 +02:00
committed by Yorik van Havre
parent 9ec88feabc
commit d10b1ba96a
2 changed files with 4 additions and 7 deletions

View File

@@ -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)

View File

@@ -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