def to_ring_managers_pairs_indices_pair( pair: BoundPortedRingManagersPair ) -> Strategy[Tuple[BoundPortedRingManagersPair, Tuple[int, int]]]: bound, _ = pair indices = strategies.integers(0, len(bound.hot_pixels)) return (strategies.tuples(strategies.just(pair), to_pairs(indices).map(sort_pair)))
def to_boxes(scalars: Strategy[Scalar]) -> Strategy[Box]: return (to_pairs(strategies.lists(scalars, min_size=2, max_size=2, unique=True) .map(sorted)) .map(pack(add)) .map(pack(Box)))
def to_boxes(context: Context, coordinates: Strategy[Scalar]) -> Strategy[Box]: return (to_pairs(strategies.lists(coordinates, unique=True, min_size=2, max_size=2) .map(sorted)) .map(pack(add)) .map(pack(context.box_cls)))
def scalars_to_segments(scalars: Strategy[Scalar]) -> Strategy[Segment]: return (to_pairs(scalars_to_points(scalars)).filter(pack(ne)).map( pack(Segment)))
to_bound_with_ported_sweep_events) from tests.integration_tests.utils import ( bound_with_ported_operations_types_pairs, to_non_overlapping_contours_lists) from tests.port_tests.hints import (PortedOperation, PortedOperationType, PortedPolygon, PortedSweepEvent) from tests.port_tests.utils import are_non_overlapping_ported_sweep_events from tests.strategies import (booleans, single_precision_floats as floats) from tests.utils import (MAX_CONTOURS_COUNT, MAX_NESTING_DEPTH, Strategy, are_sweep_events_pair_with_different_polygon_types, to_double_nested_sweep_event, to_pairs, transpose) booleans = booleans points_pairs = strategies.builds(to_bound_with_ported_points_pair, floats, floats) nones_pairs = to_pairs(strategies.none()) leaf_sweep_events_pairs = to_bound_with_ported_sweep_events(nones_pairs) acyclic_sweep_events_pairs = strategies.recursive( leaf_sweep_events_pairs, to_bound_with_ported_sweep_events, max_leaves=MAX_NESTING_DEPTH) sweep_events_pairs = make_cyclic_bound_with_ported_sweep_events( acyclic_sweep_events_pairs) nested_sweep_events_pairs = to_bound_with_ported_sweep_events( sweep_events_pairs) def to_double_nested_sweep_events_pair( events_pair: Tuple[BoundSweepEvent, PortedSweepEvent] ) -> Tuple[BoundSweepEvent, PortedSweepEvent]: bound, ported = events_pair
from hypothesis import strategies from tests.integration_tests.utils import (to_bound_with_ported_boxes_pair, to_bound_with_ported_points_pair) from tests.strategies import coordinates from tests.utils import (pack, to_pairs) points_pairs = strategies.builds(to_bound_with_ported_points_pair, coordinates, coordinates) points_pairs_pairs = to_pairs(points_pairs) boxes_pairs = points_pairs_pairs.map(pack(to_bound_with_ported_boxes_pair))
from typing import Tuple from hypothesis import strategies from tests.bind_tests.hints import (BoundSweepEvent, BoundSweepLineKey) from tests.integration_tests.factories import ( make_cyclic_bound_with_ported_sweep_events, to_bound_with_ported_sweep_events) from tests.port_tests.hints import (PortedSweepEvent, PortedSweepLineKey) from tests.strategies import booleans from tests.utils import (MAX_NESTING_DEPTH, to_pairs) booleans = booleans nones_pairs = to_pairs(strategies.none()) leaf_sweep_events_pairs = to_bound_with_ported_sweep_events(nones_pairs) acyclic_sweep_events_pairs = strategies.recursive( leaf_sweep_events_pairs, to_bound_with_ported_sweep_events, max_leaves=MAX_NESTING_DEPTH) sweep_events_pairs = make_cyclic_bound_with_ported_sweep_events( acyclic_sweep_events_pairs) def to_sweep_line_keys_pair( sweep_events_pair: Tuple[BoundSweepEvent, PortedSweepEvent] ) -> Tuple[BoundSweepLineKey, PortedSweepLineKey]: bound_event, ported_event = sweep_events_pair return BoundSweepLineKey(bound_event), PortedSweepLineKey(ported_event) sweep_line_keys_pairs = strategies.builds(to_sweep_line_keys_pair,
from tests.strategies import (coordinates, floats, integers_32, sizes, trits) from tests.utils import (Strategy, sort_pair, subsequences, to_maybe_pairs, to_pairs, transpose_pairs) from wagyu.hints import Coordinate coordinates = coordinates coordinates_lists = strategies.lists(coordinates) sorted_coordinates_pairs = to_pairs(coordinates).map(sort_pair) fill_kinds_pairs = strategies.sampled_from(list(zip(bound_fill_kinds, ported_fill_kinds))) polygon_kinds_pairs = strategies.sampled_from(list(zip(bound_polygon_kinds, ported_polygon_kinds))) operation_kinds_pairs = strategies.sampled_from( list(zip(bound_operation_kinds, ported_operation_kinds))) def to_linear_rings_with_polygon_kinds( linear_rings_pairs: List[BoundPortedLocalMinimumListsPair] ) -> Strategy[Tuple[List[BoundLinearRingWithPolygonKind], List[PortedLinearRingWithPolygonKind]]]: bound_linear_rings, ported_linear_rings = transpose_pairs( linear_rings_pairs)
def coordinates_to_segments( coordinates: Strategy[Coordinate]) -> Strategy[Segment]: return (to_pairs(coordinates_to_points(coordinates)).filter(pack(ne)).map( pack(Segment)))
.map(lambda factory : cleave_in_tuples(factory, coordinates_to_points)), rational_coordinates_strategies) .flatmap(identity))) compounds_with_points = ( (strategies.builds(call, compounds_factories .map(lambda factory : cleave_in_tuples(factory, coordinates_to_points)), coordinates_strategies) .flatmap(identity))) empty_compounds_with_compounds = strategies.tuples(empty_compounds, compounds) rational_compounds_pairs = (strategies.builds(call, to_pairs(compounds_factories) .map(pack(cleave_in_tuples)), rational_coordinates_strategies) .flatmap(identity)) rational_compounds_triplets = ( strategies.builds(call, to_triplets(compounds_factories) .map(pack(cleave_in_tuples)), rational_coordinates_strategies).flatmap(identity)) compounds_pairs = ((non_empty_compounds .map(compound_to_compound_with_multipoint)) | (strategies.builds(call, to_pairs(compounds_factories) .map(pack(cleave_in_tuples)), coordinates_strategies) .flatmap(identity))) compounds_triplets = (strategies.builds(call,
from tests.integration_tests.utils import to_bound_with_ported_big_ints_pair from tests.strategies import (integers_32, integers_64, unsigned_integers_32) from tests.utils import (to_pairs, to_quadruplets, to_triplets, transpose_pairs) from voronoi.big_int import MAX_DIGITS_COUNT integers_32 = integers_32 integers_32 = integers_64 signs = strategies.sampled_from([-1, 0, 1]) non_negative_signs = strategies.sampled_from([0, 1]) digits = strategies.lists(unsigned_integers_32, max_size=MAX_DIGITS_COUNT) big_ints_pairs = strategies.builds(to_bound_with_ported_big_ints_pair, signs, digits) non_negative_big_ints_pairs = strategies.builds( to_bound_with_ported_big_ints_pair, non_negative_signs, digits) big_ints_pairs_pairs = to_pairs(big_ints_pairs).map(transpose_pairs) non_negative_big_ints_pairs_pairs = (to_pairs(non_negative_big_ints_pairs) .map(transpose_pairs)) big_ints_pairs_triplets = to_triplets(big_ints_pairs).map(transpose_pairs) non_negative_big_ints_pairs_triplets = ( to_triplets(non_negative_big_ints_pairs).map(transpose_pairs)) big_ints_pairs_quadruplets = (to_quadruplets(big_ints_pairs) .map(transpose_pairs)) non_negative_big_ints_pairs_quadruplets = ( to_quadruplets(non_negative_big_ints_pairs).map(transpose_pairs))
to_non_overlapping_contours_lists) from tests.port_tests.hints import PortedPolygon from tests.port_tests.utils import to_non_overlapping_ported_polygons_pair from tests.strategies import single_precision_floats as floats from tests.utils import (MAX_CONTOURS_COUNT, to_pairs, transpose) operations_types_pairs = bound_with_ported_operations_types_pairs contours_vertices_pairs = to_bound_with_ported_contours_vertices_pair(floats) contours_pairs = strategies.builds(to_bound_with_ported_contours_pair, contours_vertices_pairs, strategies.builds(list), strategies.just(True)) contours_lists_pairs = (strategies.lists( contours_pairs, max_size=MAX_CONTOURS_COUNT).map(transpose).map( to_non_overlapping_contours_lists)) empty_contours_lists_pairs = to_pairs(strategies.builds(list)) non_empty_contours_lists_pairs = (strategies.lists( contours_pairs, min_size=1, max_size=1).map(transpose).map(to_non_overlapping_contours_lists)) polygons_pairs = strategies.builds(to_bound_with_ported_polygons_pair, contours_lists_pairs) empty_polygons_pairs = strategies.builds(to_bound_with_ported_polygons_pair, empty_contours_lists_pairs) non_empty_polygons_pairs = strategies.builds( to_bound_with_ported_polygons_pair, non_empty_contours_lists_pairs) def to_non_overlapping_polygons_pairs( first_pairs_pair: Tuple[BoundPolygon, PortedPolygon], second_pairs_pair: Tuple[BoundPolygon, PortedPolygon] ) -> Tuple[Tuple[BoundPolygon, PortedPolygon], Tuple[BoundPolygon,
from hypothesis import strategies from tests.integration_tests.utils import (are_endpoints_non_degenerate, to_bound_with_ported_edges_pair, to_bound_with_ported_points_pair) from tests.strategies import (coordinates, floats) from tests.utils import (pack, to_pairs) floats = floats points_pairs = strategies.builds(to_bound_with_ported_points_pair, coordinates, coordinates) points_pairs_pairs = (to_pairs(points_pairs) .filter(are_endpoints_non_degenerate)) edges_pairs = points_pairs_pairs.map(pack(to_bound_with_ported_edges_pair))
from itertools import repeat from hypothesis import strategies from tests.integration_tests.factories import ( to_bound_with_ported_points_pair, to_bound_with_ported_segments_pair) from tests.strategies import single_precision_floats as floats from tests.utils import (to_pairs, transpose) points_pairs = strategies.builds(to_bound_with_ported_points_pair, floats, floats) points_triplets_pairs = (strategies.tuples(*repeat(points_pairs, 3)) .map(transpose)) segments_pairs = strategies.builds(to_bound_with_ported_segments_pair, points_pairs, points_pairs) segments_pairs_pairs = to_pairs(segments_pairs).map(transpose)
bound, _ = points_pair return bound.x, bound.y multipoints_pairs = planar.multipoints(coordinates).map( to_bound_ported_multipoints_pair) multisegments_pairs = (planar.multisegments(coordinates) .map(to_bound_ported_multisegments_pair)) source_categories_pairs = strategies.sampled_from( list(zip(bound_source_categories, ported_source_categories))) site_events_pairs = strategies.builds(to_bound_with_ported_site_events_pair, points_pairs, points_pairs, sizes, sizes, booleans, source_categories_pairs) site_events_lists_pairs = (strategies.lists(site_events_pairs) .map(transpose_pairs)) empty_lists_pairs = to_pairs(strategies.builds(list)) empty_builders_pairs = strategies.builds(to_bound_with_ported_builders_pair, sizes, empty_lists_pairs) def to_valid_multipoints_builders_pair(builders: BoundPortedBuildersPair, multipoints: BoundPortedPointsListsPair ) -> BoundPortedBuildersPair: bound, ported = builders for bound_point, ported_point in zip(*multipoints): bound.insert_point(bound_point) ported.insert_point(ported_point) return bound, ported def to_valid_multisegments_builders_pair(builders: BoundPortedBuildersPair,
def coordinates_to_points( coordinates: Strategy[Coordinate]) -> Strategy[Point]: return to_pairs(coordinates)