Exemplo n.º 1
0
def test_properties(data: DataObject,
                    coordinates_limits_type_pair: Tuple[ScalarsLimitsType,
                                                        ScalarsLimitsType]
                    ) -> None:
    (x_coordinates_limits_type,
     y_coordinates_limits_type) = coordinates_limits_type_pair
    ((x_coordinates, (min_x_value, max_x_value)),
     x_type) = x_coordinates_limits_type
    ((y_coordinates, (min_y_value, max_y_value)),
     y_type) = y_coordinates_limits_type

    strategy = segments(x_coordinates, y_coordinates)

    result = data.draw(strategy)

    assert is_segment(result)
    assert segment_has_coordinates_types(result,
                                         x_type=x_type,
                                         y_type=y_type)
    assert segment_has_coordinates_in_range(result,
                                            min_x_value=min_x_value,
                                            max_x_value=max_x_value,
                                            min_y_value=min_y_value,
                                            max_y_value=max_y_value)
    assert result.start != result.end
Exemplo n.º 2
0
def test_same_coordinates(data: DataObject,
                          coordinates_limits_type: ScalarsLimitsType
                          ) -> None:
    (coordinates, (min_value, max_value)), type_ = coordinates_limits_type

    strategy = segments(coordinates)

    result = data.draw(strategy)

    assert is_segment(result)
    assert segment_has_coordinates_types(result,
                                         x_type=type_,
                                         y_type=type_)
    assert segment_has_coordinates_in_range(result,
                                            min_x_value=min_value,
                                            max_x_value=max_value,
                                            min_y_value=min_value,
                                            max_y_value=max_value)
    assert result.start != result.end
Exemplo n.º 3
0
def coordinates_to_polygons_with_segments(
        coordinates: Strategy[Scalar]) -> Strategy[PolygonWithSegment]:
    return strategies.tuples(planar.polygons(coordinates),
                             planar.segments(coordinates))
Exemplo n.º 4
0
def coordinates_to_multisegments_with_segments(
        coordinates: Strategy[Scalar]) -> Strategy[MultisegmentWithSegment]:
    return strategies.tuples(planar.multisegments(coordinates),
                             planar.segments(coordinates))
Exemplo n.º 5
0
def test_basic(coordinates: Strategy[Scalar]) -> None:
    result = segments(coordinates)

    assert isinstance(result, Strategy)
Exemplo n.º 6
0
                         transpose_pairs)

booleans = strategies.booleans()
coordinates = integers_32
points_pairs = strategies.builds(to_bound_with_ported_points_pair,
                                 coordinates, coordinates)


def raw_segment_to_segments_pair(raw: RawSegment) -> BoundPortedSegmentsPair:
    return (BoundSegment(BoundPoint(raw.start.x, raw.start.y),
                         BoundPoint(raw.end.x, raw.end.y)),
            PortedSegment(PortedPoint(raw.start.x, raw.start.y),
                          PortedPoint(raw.end.x, raw.end.y)))


segments_pairs = planar.segments(coordinates).map(raw_segment_to_segments_pair)


def points_pair_to_coordinates(points_pair: BoundPortedPointsPair
                               ) -> Tuple[int, int]:
    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,