Skip to content

Commit

Permalink
Complete strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed May 19, 2020
1 parent 9523bf3 commit decac92
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions tests/planar_tests/strategies.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from functools import partial
from itertools import repeat
from typing import Tuple
from itertools import (combinations,
repeat)
from typing import (List,
Tuple)

from hypothesis import strategies

from bentley_ottmann.hints import Point
from bentley_ottmann.hints import (Point,
Segment)
from tests.strategies import (points_strategies,
segments_strategies)
from tests.utils import Strategy
Expand All @@ -21,11 +24,28 @@
degenerate_contours = (points_strategies
.flatmap(partial(strategies.lists,
max_size=2)))
segments_lists = segments_strategies.flatmap(strategies.lists)


def points_to_segments_lists(points: Strategy[Point]
) -> Strategy[List[Segment]]:
def points_to_segments_list(points: List[Point]) -> List[Segment]:
return list(combinations(points, 2))

return (strategies.lists(points,
min_size=2,
max_size=8,
unique=True)
.map(points_to_segments_list))


non_empty_segments_lists = points_strategies.flatmap(points_to_segments_lists)
segments_lists = (segments_strategies.flatmap(strategies.lists)
| non_empty_segments_lists)
empty_segments_lists = strategies.builds(list)
non_empty_segments_lists = (segments_strategies
.flatmap(partial(strategies.lists,
min_size=1)))
non_empty_segments_lists = ((segments_strategies
.flatmap(partial(strategies.lists,
min_size=1)))
| non_empty_segments_lists)


def points_to_degenerate_segments(points: Strategy[Point]
Expand Down

0 comments on commit decac92

Please sign in to comment.