コード例 #1
0
ファイル: geometries.py プロジェクト: lycantropos/ground
def to_crossing_segments_pairs(context: Context,
                               coordinates: Strategy[Scalar]
                               ) -> Strategy[Tuple[Segment, Segment]]:
    segment_factory = pack(context.segment_cls)
    return (to_crossing_segments_pairs_endpoints(context, coordinates)
            .map(cleave(compose(segment_factory, itemgetter(0, 1)),
                        compose(segment_factory, itemgetter(2, 3)))))
コード例 #2
0
ファイル: factories.py プロジェクト: skrat/martinez
def to_acyclic_bound_sweep_events(*,
                                  min_depth: int = 1,
                                  max_depth: int = MAX_NESTING_DEPTH,
                                  **kwargs: Any) -> Strategy[BoundSweepEvent]:
    events_factory = partial(to_plain_bound_sweep_events, **kwargs)
    base = compose(*repeat(events_factory, times=min_depth))(strategies.none())
    return strategies.recursive(base,
                                events_factory,
                                max_leaves=max_depth - min_depth)
コード例 #3
0
def scalars_to_acyclic_ported_sweep_events(scalars: Strategy[Scalar],
                                           *,
                                           min_depth: int = 1,
                                           max_depth: int = MAX_NESTING_DEPTH,
                                           **kwargs: Any
                                           ) -> Strategy[PortedSweepEvent]:
    events_factory = partial(scalars_to_plain_ported_sweep_events, scalars,
                             **kwargs)
    base = compose(*repeat(events_factory,
                           times=min_depth))(strategies.none())
    return strategies.recursive(base, events_factory,
                                max_leaves=max_depth - min_depth)
コード例 #4
0
ファイル: strategies.py プロジェクト: lycantropos/ground
    to_multipoints, to_multipolygons, to_multisegments, to_points, to_polygons,
    to_polygons_sequences, to_segments, to_segments_sequences,
    to_touching_segments_pairs, to_vertices_sequences)
from tests.utils import (MAX_SEQUENCE_SIZE, cleave_in_tuples, compose, pack,
                         to_pairs, to_quadruplets, to_triplets)

indices = strategies.integers(0, sys.maxsize)
contexts = strategies.builds(Context, mode=strategies.sampled_from(list(Mode)))
contexts_with_empty_lists = strategies.tuples(contexts,
                                              strategies.builds(list))
contexts_with_rational_coordinates_strategies = strategies.tuples(
    contexts, rational_coordinates_strategies)
contexts_with_coordinates_strategies = strategies.tuples(
    contexts, coordinates_strategies)
to_contexts_with = partial(cleave_in_tuples,
                           compose(strategies.just, itemgetter(0)))
boxes_factory = pack(to_boxes)
contours_factory = pack(to_contours)
crossing_segments_pairs_factory = pack(to_crossing_segments_pairs)
multipoints_factory = pack(to_multipoints)
multipolygons_factory = pack(to_multipolygons)
multisegments_factory = pack(to_multisegments)
points_factory = pack(to_points)
polygons_factory = pack(to_polygons)
polygons_sequences_factory = pack(to_polygons_sequences)
segments_factory = pack(to_segments)
segments_sequences_factory = pack(to_segments_sequences)
touching_segments_pairs_factory = pack(to_touching_segments_pairs)
vertices_sequences_factories = pack(to_vertices_sequences)

contexts_with_boxes = (contexts_with_coordinates_strategies.flatmap(
コード例 #5
0
ファイル: strategies.py プロジェクト: skrat/martinez
def scalars_to_operations(
        scalars: Strategy[Scalar]) -> Strategy[PortedOperation]:
    return (scalars_to_trivial_operations(scalars)
            | scalars_to_non_trivial_operations(scalars))


operations_strategies = scalars_strategies.map(scalars_to_operations)
operations = operations_strategies.flatmap(identity)
operations_with_sweep_events = scalars_strategies.flatmap(
    cleave_in_tuples(scalars_to_operations, scalars_to_ported_sweep_events))
operations_with_double_nested_sweep_events_and_points = (
    scalars_strategies.flatmap(
        cleave_in_tuples(
            scalars_to_operations,
            compose(to_double_nested_sweep_events,
                    scalars_to_nested_ported_sweep_events),
            scalars_to_ported_points)))
operations_with_sweep_events_and_maybe_sweep_events = (
    scalars_strategies.flatmap(
        cleave_in_tuples(
            scalars_to_operations, scalars_to_ported_sweep_events,
            compose(to_maybe, scalars_to_nested_ported_sweep_events))))
operations_pairs = operations_strategies.flatmap(to_pairs)
operations_triplets = operations_strategies.flatmap(to_triplets)


def pre_process_operation(operation: PortedOperation) -> PortedOperation:
    operation.process_segments()
    return operation