def test_associativity(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_union = unite_segments(first, second) second_third_union = unite_segments(second, third) assert (not is_segment(first_second_union) or not is_segment(second_third_union) or are_compounds_similar( unite_segments(first_second_union, third), unite_segments(first, second_third_union)))
def test_intersection_minuend(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_intersection = intersect_segments(first, second) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_intersection) or not is_segment(second_third_difference) or are_compounds_similar( subtract_segments(first_second_intersection, third), intersect_segments(first, second_third_difference)))
def test_difference_operand(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_difference = subtract_segments(first, second) first_third_union = unite_segments(first, third) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_difference) or not is_segment(first_third_union) or not is_segment(second_third_difference) or are_compounds_similar( unite_segments(first_second_difference, third), subtract_segments(first_third_union, second_third_difference)))
def test_distribution_over_intersection( segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_union = unite_segments(first, second) first_third_union = unite_segments(first, third) second_third_intersection = intersect_segments(second, third) assert (not is_segment(first_second_union) or not is_segment(first_third_union) or not is_segment(second_third_intersection) or are_compounds_similar( unite_segments(first, second_third_intersection), intersect_segments(first_second_union, first_third_union)))
def test_repeated(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_symmetric_difference = symmetric_subtract_segments( first, second) second_third_symmetric_difference = symmetric_subtract_segments( second, third) assert (not is_segment(first_second_symmetric_difference) or not is_segment(second_third_symmetric_difference) or are_compounds_similar( symmetric_subtract_segments(first_second_symmetric_difference, second_third_symmetric_difference), symmetric_subtract_segments(first, third)))
def test_difference_subtrahend(segments_triplet: SegmentsTriplet) -> None: first, second, third = segments_triplet first_second_difference = subtract_segments(first, second) first_third_difference = intersect_segments(first, third) second_third_difference = subtract_segments(second, third) assert (not is_segment(first_second_difference) or not is_segment(first_third_difference) or not is_segment(second_third_difference) or are_compounds_similar( subtract_segments(first, second_third_difference), unite_segments(first_second_difference, first_third_difference)))
def test_equivalents(segments_pair: SegmentsPair) -> None: first, second = segments_pair result = unite_segments(first, second) first_second_symmetric_difference = symmetric_subtract_segments( first, second) first_second_intersection = intersect_segments(first, second) assert (not is_segment(first_second_symmetric_difference) or not is_segment(first_second_intersection) or are_compounds_similar( result, symmetric_subtract_segments(first_second_symmetric_difference, first_second_intersection)))
def test_basic(tree_with_point_and_n: Tuple[Tree, Point, int]) -> None: tree, point, n = tree_with_point_and_n result = tree.n_nearest_to_point_segments(n, point) assert isinstance(result, (list, type(tree.segments))) assert all(is_segment(element) for element in result)
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
def test_basic(context_with_contour: Tuple[Context, Contour]) -> None: context, contour = context_with_contour result = context.contour_segments(contour) assert isinstance(result, abc.Sequence) assert len(result) == len(contour.vertices) assert all(is_segment(element) for element in result)
def test_properties(multisegment_with_segment: MultisegmentWithSegment ) -> None: multisegment, segment = multisegment_with_segment result = unite_segment_with_multisegment(segment, multisegment) relation = segment_in_multisegment(segment, multisegment) assert equivalence(is_multisegment(result), relation in (Relation.DISJOINT, Relation.TOUCH, Relation.CROSS, Relation.OVERLAP, Relation.COMPONENT)) assert equivalence(is_segment(result), relation is Relation.EQUAL or relation is Relation.COMPOSITE)
def test_properties(multisegment_with_segment: MultisegmentWithSegment ) -> None: multisegment, segment = multisegment_with_segment result = subtract_multisegment_from_segment(segment, multisegment) relation = segment_in_multisegment(segment, multisegment) assert equivalence(is_empty(result), relation is Relation.EQUAL or relation is Relation.COMPONENT) assert implication(is_multisegment(result), relation in (Relation.TOUCH, Relation.CROSS, Relation.COMPOSITE, Relation.OVERLAP)) assert implication(is_segment(result), relation in (Relation.DISJOINT, Relation.TOUCH, Relation.CROSS, Relation.COMPOSITE, Relation.OVERLAP))
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
def test_absorption_identity(segments_pair: SegmentsPair) -> None: first, second = segments_pair first_second_union = unite_segments(first, second) assert (not is_segment(first_second_union) or intersect_segments(first, first_second_union) == first)
def test_basic(tree_with_segment: Tuple[Tree, Segment]) -> None: tree, segment = tree_with_segment result = tree.nearest_segment(segment) assert is_segment(result)
def test_basic(tree_with_point: Tuple[Tree, Point]) -> None: tree, point = tree_with_point result = tree.nearest_to_point_segment(point) assert is_segment(result)