Esempio n. 1
0
from _wagyu import (Box,
                    Point,
                    Ring)
from hypothesis import strategies

from tests.strategies import (coordinates,
                              floats,
                              sizes)
from tests.utils import to_maybe

booleans = strategies.booleans()
floats = floats
sizes = sizes
points = strategies.builds(Point, coordinates, coordinates)
points_lists = strategies.lists(points)
boxes = strategies.builds(Box, points, points)
maybe_rings = to_maybe(strategies.deferred(lambda: rings))
maybe_rings_lists = strategies.lists(maybe_rings)
rings = strategies.builds(Ring, sizes, maybe_rings_lists, points_lists,
                          booleans)
Esempio n. 2
0
from tests.port_tests.utils import (are_non_overlapping_ported_sweep_events,
                                    ported_operations_types,
                                    to_non_overlapping_ported_polygons_pair)
from tests.strategies import (booleans, scalars_strategies)
from tests.utils import (Scalar, Strategy,
                         are_sweep_events_pair_with_different_polygon_types,
                         cleave_in_tuples, compose, identity,
                         is_sweep_event_non_degenerate,
                         to_double_nested_sweep_events, to_maybe, to_pairs,
                         to_triplets)

points = scalars_strategies.flatmap(scalars_to_ported_points)
sweep_events = scalars_strategies.flatmap(scalars_to_ported_sweep_events)
nested_sweep_events = (
    scalars_strategies.flatmap(scalars_to_nested_ported_sweep_events))
maybe_nested_sweep_events = to_maybe(nested_sweep_events)
non_empty_sweep_events_lists = strategies.lists(sweep_events, min_size=1)


def to_sweep_events_lists_with_indices_and_booleans_lists(
    events: List[PortedSweepEvent]
) -> Strategy[Tuple[List[PortedSweepEvent], int, List[bool]]]:
    return strategies.tuples(
        strategies.just(events), strategies.integers(0,
                                                     len(events) - 1),
        strategies.lists(booleans, min_size=len(events), max_size=len(events)))


non_empty_sweep_events_lists_with_indices_and_booleans_lists = (
    non_empty_sweep_events_lists.flatmap(
        to_sweep_events_lists_with_indices_and_booleans_lists))
Esempio n. 3
0
from hypothesis import strategies
from hypothesis_geometry import planar

from tests.port_tests.hints import (PortedCell, PortedDiagram, PortedEdge,
                                    PortedVertex)
from tests.port_tests.utils import (ported_source_categories,
                                    to_ported_multipoint,
                                    to_ported_multisegment)
from tests.strategies import (doubles, integers_32, sizes)
from tests.utils import to_maybe

booleans = strategies.booleans()
coordinates = doubles
empty_diagrams = strategies.builds(PortedDiagram)
source_categories = strategies.sampled_from(ported_source_categories)
cells = strategies.builds(PortedCell, sizes, source_categories)
vertices = strategies.builds(PortedVertex, coordinates, coordinates)
edges = strategies.builds(PortedEdge, to_maybe(vertices), cells, booleans,
                          booleans)
cells_lists = strategies.lists(cells)
edges_lists = strategies.lists(edges)
vertices_lists = strategies.lists(vertices)
diagrams = strategies.builds(PortedDiagram, cells_lists, edges_lists,
                             vertices_lists)
multipoints = planar.multipoints(integers_32).map(to_ported_multipoint)
multisegments = planar.multisegments(integers_32).map(to_ported_multisegment)
Esempio n. 4
0
from tests.port_tests.utils import (ported_edges_types, ported_polygons_types)
from tests.strategies import (booleans, non_negative_integers,
                              scalars_strategies)
from tests.utils import (cleave_in_tuples, identity, to_maybe, to_pairs,
                         to_triplets)

booleans = booleans
non_negative_integers = non_negative_integers
polygons_types = ported_polygons_types
edges_types = ported_edges_types
points = scalars_strategies.flatmap(scalars_to_ported_points)
leaf_sweep_events = (scalars_strategies.flatmap(
    partial(scalars_to_plain_ported_sweep_events, children=strategies.none())))
leaf_sweep_events_with_points = scalars_strategies.flatmap(
    cleave_in_tuples(
        partial(scalars_to_plain_ported_sweep_events,
                children=strategies.none()), scalars_to_ported_points))
acyclic_sweep_events = (
    scalars_strategies.flatmap(scalars_to_acyclic_ported_sweep_events))
sweep_events_strategies = (
    scalars_strategies.map(scalars_to_ported_sweep_events))
sweep_events = sweep_events_strategies.flatmap(identity)
sweep_events_pairs = sweep_events_strategies.flatmap(to_pairs)
sweep_events_triplets = sweep_events_strategies.flatmap(to_triplets)
nested_sweep_events = (
    scalars_strategies.flatmap(scalars_to_nested_ported_sweep_events))
nested_sweep_events_with_points = scalars_strategies.flatmap(
    cleave_in_tuples(scalars_to_nested_ported_sweep_events,
                     scalars_to_ported_points))
maybe_sweep_events = to_maybe(sweep_events)