from operator import (add, ne) from _seidel import (Edge, Leaf, Node, Point, Trapezoid, XNode, YNode) from hypothesis import strategies from tests.strategies import (floats, recursive, to_pairs) from tests.utils import (Strategy, pack, sort_points) points = strategies.builds(Point, floats, floats) sorted_points_pairs = to_pairs(points).filter(pack(ne)).map(sort_points) edges = sorted_points_pairs.map(pack(Edge)) trapezoids = (strategies.tuples(sorted_points_pairs, to_pairs(edges)).map( pack(add)).map(pack(Trapezoid))) leaves = trapezoids.map(Leaf) def to_nodes(nodes: Strategy[Node]) -> Strategy[Node]: return to_x_nodes(nodes) | to_y_nodes(nodes) def to_x_nodes(nodes: Strategy[Node]) -> Strategy[YNode]: return strategies.builds(XNode, points, nodes, nodes) def to_y_nodes(nodes: Strategy[Node]) -> Strategy[YNode]: return strategies.builds(YNode, edges, nodes, nodes) nodes = recursive(leaves, to_nodes) x_nodes = to_x_nodes(nodes)
from hypothesis import strategies from tests.strategies import (floats, to_bound_with_ported_edges_pair, to_bound_with_ported_points_pair, to_pairs) from tests.utils import (are_endpoints_non_degenerate, pack, sort_endpoints) points_pairs = strategies.builds(to_bound_with_ported_points_pair, floats, floats) sorted_points_pairs_pairs = (to_pairs(points_pairs).filter( are_endpoints_non_degenerate).map(sort_endpoints)) edges_pairs = (sorted_points_pairs_pairs.map( pack(to_bound_with_ported_edges_pair)))
from operator import add from hypothesis import strategies from tests.strategies import (floats, to_bound_with_ported_edges_pair, to_bound_with_ported_points_pair, to_bound_with_ported_trapezoids_pair, to_pairs) from tests.utils import (are_endpoints_non_degenerate, pack, sort_endpoints) points_pairs = strategies.builds(to_bound_with_ported_points_pair, floats, floats) sorted_points_pairs_pairs = (to_pairs(points_pairs).filter( are_endpoints_non_degenerate).map(sort_endpoints)) edges_pairs = (sorted_points_pairs_pairs.map( pack(to_bound_with_ported_edges_pair))) trapezoids_pairs = (strategies.tuples( sorted_points_pairs_pairs, to_pairs(edges_pairs)).map(pack(add)).map( pack(to_bound_with_ported_trapezoids_pair)))
from operator import ne from _seidel import (Edge, Point) from hypothesis import strategies from tests.strategies import (floats, to_pairs) from tests.utils import (pack, sort_points) points = strategies.builds(Point, floats, floats) sorted_points = to_pairs(points).filter(pack(ne)).map(sort_points) edges = sorted_points.map(pack(Edge))