def test_step(segments: List[Segment]) -> None: first_segment, *rest_segments = segments result = segments_intersect(rest_segments) next_result = segments_intersect(segments) assert next_result is (result or any( segments_intersections(first_segment, segment) for segment in rest_segments))
def test_step(context: Context, segments: List[Segment]) -> None: first_segment, *rest_segments = segments result = segments_intersect(rest_segments) next_result = segments_intersect(segments) assert (next_result is (result or any( segments_pair_intersections(first_segment.start, first_segment.end, segment.start, segment.end) for segment in rest_segments)))
def generate_N_non_intersecting_lines(self, N): lines = [] pbar = tqdm(total=N) while len(lines) < N: lines.append(self.generateLine()) if (segments_intersect(lines)): lines = lines[:-1] else: pbar.update(1) return lines
def test_degenerate_segments(segments: List[Segment]) -> None: with pytest.raises(ValueError): segments_intersect(segments)
def test_reversed_coordinates(segments: List[Segment]) -> None: result = segments_intersect(segments) assert result is segments_intersect( [reverse_segment_coordinates(segment) for segment in segments])
def test_reversed(segments: List[Segment]) -> None: result = segments_intersect(segments) assert result is segments_intersect(segments[::-1])
def test_base_case(segments: List[Segment]) -> None: result = segments_intersect(segments) assert not result
def test_basic(segments: List[Segment]) -> None: result = segments_intersect(segments) assert isinstance(result, bool)