Exemplo n.º 1
0
from tests.strategies import (coordinates_strategies, coordinates_to_points,
                              coordinates_to_segments, invalid_segments,
                              rational_coordinates_strategies)
from tests.utils import (cleave_in_tuples, to_pairs, to_triplets)

rational_segments = (
    rational_coordinates_strategies.flatmap(coordinates_to_segments))
segments = coordinates_strategies.flatmap(coordinates_to_segments)
invalid_segments = invalid_segments
segments_strategies = coordinates_strategies.map(coordinates_to_segments)
segments_with_points = (coordinates_strategies.flatmap(
    cleave_in_tuples(coordinates_to_segments, coordinates_to_points)))
segments_pairs = segments_strategies.flatmap(to_pairs)
segments_triplets = segments_strategies.flatmap(to_triplets)
Exemplo n.º 2
0
from tests.strategies import (coordinates_strategies, coordinates_to_points,
                              coordinates_to_polygons, invalid_polygons,
                              rational_coordinates_strategies)
from tests.utils import (cleave_in_tuples, to_pairs, to_triplets)

rational_polygons = (
    rational_coordinates_strategies.flatmap(coordinates_to_polygons))
polygons = coordinates_strategies.flatmap(coordinates_to_polygons)
invalid_polygons = invalid_polygons
polygons_strategies = coordinates_strategies.map(coordinates_to_polygons)
polygons_pairs = polygons_strategies.flatmap(to_pairs)
polygons_triplets = polygons_strategies.flatmap(to_triplets)
polygons_with_points = (coordinates_strategies.flatmap(
    cleave_in_tuples(coordinates_to_polygons, coordinates_to_points)))
Exemplo n.º 3
0
multisegments_pairs = multisegments_strategies.flatmap(to_pairs)
multisegments_triplets = multisegments_strategies.flatmap(to_triplets)
empty_multipolygons_with_multisegments = strategies.tuples(
    empty_multipolygons, multisegments)
multipolygons_with_empty_multisegments = strategies.tuples(
    multipolygons, empty_multisegments)


def coordinates_to_multipolygons_with_multisegments(
    coordinates: Strategy[Coordinate]
) -> Strategy[Tuple[Multipolygon, Multisegment]]:
    return strategies.tuples(planar.multipolygons(coordinates),
                             planar.multisegments(coordinates))


rational_multipolygons_with_multisegments = (
    rational_coordinates_strategies.flatmap(
        coordinates_to_multipolygons_with_multisegments))
multipolygons_with_multisegments = coordinates_strategies.flatmap(
    coordinates_to_multipolygons_with_multisegments)
empty_multipolygons_with_multipolygons = strategies.tuples(
    empty_multipolygons, multipolygons)
empty_multiregions_with_multiregions = strategies.tuples(
    empty_multiregions, multiregions)
multipolygons_strategies = coordinates_strategies.map(planar.multipolygons)
multipolygons_pairs = multipolygons_strategies.flatmap(to_pairs)
multipolygons_triplets = multipolygons_strategies.flatmap(to_triplets)
multiregions_strategies = coordinates_strategies.map(planar.multicontours)
multiregions_pairs = multiregions_strategies.flatmap(to_pairs)
multiregions_triplets = multiregions_strategies.flatmap(to_triplets)
Exemplo n.º 4
0
from hypothesis import strategies

from tests.strategies import (coordinates_strategies,
                              coordinates_to_linear_geometries,
                              coordinates_to_points,
                              rational_coordinates_strategies,
                              rational_cosines_sines)
from tests.utils import (cleave_in_tuples, identity)

linear_geometries = coordinates_strategies.flatmap(
    coordinates_to_linear_geometries)
rational_linear_geometries_with_coordinates_pairs = (
    rational_coordinates_strategies.flatmap(
        cleave_in_tuples(coordinates_to_linear_geometries, identity,
                         identity)))
rational_linear_geometries_points_with_cosines_sines = (strategies.tuples(
    (rational_coordinates_strategies.flatmap(
        cleave_in_tuples(coordinates_to_linear_geometries,
                         coordinates_to_points))), rational_cosines_sines))
Exemplo n.º 5
0
from hypothesis import strategies

from gon.hints import Scalar
from tests.strategies import (coordinates_strategies, coordinates_to_points,
                              coordinates_to_shaped_geometries,
                              rational_coordinates_strategies,
                              rational_cosines_sines)
from tests.utils import (Strategy, cleave_in_tuples, identity)

rational_shaped_geometries = (
    rational_coordinates_strategies.flatmap(coordinates_to_shaped_geometries))
shaped_geometries = (
    coordinates_strategies.flatmap(coordinates_to_shaped_geometries))
rational_shaped_geometries_with_coordinates_pairs = (
    rational_coordinates_strategies.flatmap(
        cleave_in_tuples(coordinates_to_shaped_geometries, identity,
                         identity)))


def coordinates_to_non_zero_coordinates(
        coordinates: Strategy[Scalar]) -> Strategy[Scalar]:
    return coordinates.filter(bool)


rational_shaped_geometries_with_non_zero_coordinates_pairs = (
    rational_coordinates_strategies.flatmap(
        cleave_in_tuples(coordinates_to_shaped_geometries,
                         coordinates_to_non_zero_coordinates,
                         coordinates_to_non_zero_coordinates)))
rational_shaped_geometries_points_with_cosines_sines = (strategies.tuples(
    (rational_coordinates_strategies.flatmap(
Exemplo n.º 6
0

def scale_head(segment_partition: List[Segment],
               scale: Scalar) -> List[Segment]:
    return segment_partition[:-1] + [left_scale_segment(segment_partition[-1],
                                                        scale)]


def scale_tail(segment_partition: List[Segment],
               scale: Scalar) -> List[Segment]:
    return segment_partition[:-1] + [right_scale_segment(segment_partition[-1],
                                                         scale)]


multisegments_with_segments |= (
    (rational_coordinates_strategies.flatmap(planar.segments)
     .flatmap(segment_to_multisegments_with_segments)))
size_three_or_more_multisegments_with_segments |= (
    (rational_coordinates_strategies.flatmap(planar.segments)
     .flatmap(partial(segment_to_multisegments_with_segments,
                      min_size=3))))
multisegments_strategies = coordinates_strategies.map(planar.multisegments)
multisegments_pairs = (coordinates_strategies.map(planar.multisegments)
                       .flatmap(to_pairs))
size_three_or_more_multisegment_with_multisegment = (
    (coordinates_strategies
     .flatmap(cleave_in_tuples(to_size_three_or_more_multisegments,
                               planar.multisegments))))
contours = coordinates_strategies.flatmap(planar.contours)
contours_with_points = (coordinates_strategies
                        .flatmap(cleave_in_tuples(planar.contours,
                                                  planar.points)))