-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
167a83a
commit 69a376b
Showing
1 changed file
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,37 @@ | ||
from functools import partial | ||
from itertools import permutations | ||
from typing import List | ||
|
||
from hypothesis import strategies | ||
|
||
from bentley_ottmann.hints import (Point, | ||
Segment) | ||
from tests.strategies import (points_strategies, | ||
segments_strategies) | ||
from tests.utils import Strategy | ||
|
||
contours = points_strategies.flatmap(strategies.lists) | ||
non_empty_contours = (points_strategies | ||
.flatmap(partial(strategies.lists, | ||
min_size=3))) | ||
segments_lists = segments_strategies.flatmap(strategies.lists) | ||
|
||
|
||
def to_permutations(points: Strategy[Point], | ||
*, | ||
min_size: int = 0) -> Strategy[List[Segment]]: | ||
return (strategies.lists(points, | ||
min_size=2 * min_size, | ||
unique=True) | ||
.map(partial(permutations, | ||
r=2)) | ||
.map(list)) | ||
|
||
|
||
segments_lists = (segments_strategies.flatmap(strategies.lists) | ||
| points_strategies.flatmap(to_permutations)) | ||
empty_contours = 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)) | ||
| points_strategies.flatmap(partial(to_permutations, | ||
min_size=1))) |