Merge pull request #6592 from Russ4262/fix/depth_params_twin_depths
Path: Fix roughly equal depth entries
This commit is contained in:
@@ -718,7 +718,28 @@ class depth_params(object):
|
||||
)[1:]
|
||||
|
||||
depths.reverse()
|
||||
return depths
|
||||
|
||||
if len(depths) < 2:
|
||||
return depths
|
||||
|
||||
return self.__filter_roughly_equal_depths(depths)
|
||||
|
||||
def __filter_roughly_equal_depths(self, depths):
|
||||
"""Depths arrive sorted from largest to smallest, positive to negative.
|
||||
Return unique list of depths, using PathGeom.isRoughly() method to determine
|
||||
if the two values are equal. Only one of two consecutive equals are removed.
|
||||
|
||||
The assumption is that there are not enough consecutively roughly-equal depths
|
||||
to be removed, so as to eliminate an effective step-down depth with the removal
|
||||
of repetitive roughly-equal values."""
|
||||
|
||||
depthcopy = sorted(depths) # make a copy and sort low to high
|
||||
keep = [depthcopy[0]]
|
||||
for depth in depthcopy[1:]:
|
||||
if not PathGeom.isRoughly(depth, keep[-1]):
|
||||
keep.append(depth)
|
||||
keep.reverse() # reverse results back high to low
|
||||
return keep
|
||||
|
||||
def __equal_steps(self, start, stop, max_size):
|
||||
"""returns a list of depths beginning with the bottom (included), ending
|
||||
|
||||
@@ -43,7 +43,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test10(self):
|
||||
def test001(self):
|
||||
"""Stepping from zero to a negative depth"""
|
||||
|
||||
args = {
|
||||
@@ -62,7 +62,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test20(self):
|
||||
def test002(self):
|
||||
"""Start and end are equal or start lower than finish"""
|
||||
|
||||
args = {
|
||||
@@ -89,7 +89,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test30(self):
|
||||
def test003(self):
|
||||
"""User Parameters passed in"""
|
||||
args = {
|
||||
"clearance_height": 10,
|
||||
@@ -107,7 +107,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test40(self):
|
||||
def test004(self):
|
||||
"""z_finish_step passed in."""
|
||||
args = {
|
||||
"clearance_height": 10,
|
||||
@@ -125,7 +125,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test50(self):
|
||||
def test005(self):
|
||||
"""stepping down with equalstep=True"""
|
||||
args = {
|
||||
"clearance_height": 10,
|
||||
@@ -144,7 +144,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test60(self):
|
||||
def test006(self):
|
||||
"""stepping down with equalstep=True and a finish depth"""
|
||||
args = {
|
||||
"clearance_height": 10,
|
||||
@@ -162,7 +162,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test70(self):
|
||||
def test007(self):
|
||||
"""stepping down with stepdown greater than total depth"""
|
||||
args = {
|
||||
"clearance_height": 10,
|
||||
@@ -180,7 +180,7 @@ class depthTestCases(unittest.TestCase):
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(r, expected)
|
||||
|
||||
def test80(self):
|
||||
def test008(self):
|
||||
"""Test handling of negative step-down, negative finish step, and relative size of step/finish"""
|
||||
|
||||
# negative steps should be converted to positive values
|
||||
@@ -211,3 +211,59 @@ class depthTestCases(unittest.TestCase):
|
||||
"user_depths": None,
|
||||
}
|
||||
self.assertRaises(ValueError, PathUtils.depth_params, **args)
|
||||
|
||||
def test009(self):
|
||||
"""stepping down with single stepdown exactly equal to total depth"""
|
||||
args = {
|
||||
"clearance_height": 20.0,
|
||||
"safe_height": 15.0,
|
||||
"start_depth": 10.0,
|
||||
"step_down": 10.0,
|
||||
"z_finish_step": 0.0,
|
||||
"final_depth": 0.0,
|
||||
"user_depths": None,
|
||||
}
|
||||
|
||||
expected = [0]
|
||||
|
||||
d = PathUtils.depth_params(**args)
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(
|
||||
r, expected, "Expected {}, but result of {}".format(expected, r)
|
||||
)
|
||||
|
||||
def test010(self):
|
||||
"""stepping down with single stepdown roughly equal to total depth"""
|
||||
args = {
|
||||
"clearance_height": 20.0,
|
||||
"safe_height": 15.0,
|
||||
"start_depth": 10.000000001,
|
||||
"step_down": 10.0,
|
||||
"z_finish_step": 0.0,
|
||||
"final_depth": 0.0,
|
||||
"user_depths": None,
|
||||
}
|
||||
|
||||
expected = [0]
|
||||
|
||||
d = PathUtils.depth_params(**args)
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(
|
||||
r, expected, "Expected {}, but result of {}".format(expected, r)
|
||||
)
|
||||
|
||||
args = {
|
||||
"clearance_height": 20.0,
|
||||
"safe_height": 15.0,
|
||||
"start_depth": 10.0,
|
||||
"step_down": 9.9999999,
|
||||
"z_finish_step": 0.0,
|
||||
"final_depth": 0.0,
|
||||
"user_depths": None,
|
||||
}
|
||||
|
||||
d = PathUtils.depth_params(**args)
|
||||
r = [i for i in d]
|
||||
self.assertListEqual(
|
||||
r, expected, "Expected {}, but result of {}".format(expected, r)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user