Skip to content

Commit

Permalink
ipy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Apr 26, 2024
1 parent 9e1945d commit 409faad
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions tests/compas/geometry/test_curves_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,18 @@ def test_line_point_from_start(p1, p2):
([-11.1, 22.2, 33.3], [1.1, -2.2, -3.3]),
],
)
@pytest.mark.parametrize(
"distance",
[0, 1, 4, -9, 3.3, 0.00001, -0.00001],
)
def test_line_point_from_end(p1, p2, distance):
line = Line(p1, p2)
point = line.point_from_end(distance)
distance_to_start = distance_point_point(point, p1)
distance_to_end = distance_point_point(point, p2)
# Check that the distance is correct
assert TOL.is_close(distance_to_end, abs(distance))
# Check that negative distance gives a point far away from start
if distance < 0:
assert distance_to_start > line.length
distances = [0, 1, 4, -9, 3.3, 0.00001, -0.00001]

This comment has been minimized.

Copy link
@gonzalocasas

gonzalocasas Apr 26, 2024

Member

you could still use pytest.mark.parametrize, but the problem here was that the param list didn't match, right? p1 and p2 were missing in the parametrization

This comment has been minimized.

Copy link
@yck011522

yck011522 Apr 26, 2024

Author Contributor

I was trying to do a double parameter set, so it a matrix of test. I defined the line and the distance in two separate decorators .

I think this does work with ipy

for distance in distances:
line = Line(p1, p2)
point = line.point_from_end(distance)
distance_to_start = distance_point_point(point, p1)
distance_to_end = distance_point_point(point, p2)
# Check that the distance is correct
assert TOL.is_close(distance_to_end, abs(distance))
# Check that negative distance gives a point far away from start
if distance < 0:
assert distance_to_start > line.length


@pytest.mark.parametrize(
Expand Down

0 comments on commit 409faad

Please sign in to comment.