def test_events(operation: BoundOperation) -> None: events_before = operation.events operation.process_segments() events_after = operation.events assert isinstance(events_before, list) assert isinstance(events_after, list) assert not events_before assert not len(events_after) % 2 assert all(isinstance(event, BoundSweepEvent) for event in events_after)
def test_events(operation: BoundOperation, event: BoundSweepEvent, point: BoundPoint) -> None: events_before = operation.events operation.divide_segment(event, point) events_after = operation.events assert isinstance(events_before, list) assert isinstance(events_after, list) assert not events_before assert len(events_after) == 2 assert all(isinstance(event, BoundSweepEvent) for event in events_after)
def test_basic(left: BoundPolygon, right: BoundPolygon, operation_type: BoundOperationType) -> None: result = BoundOperation(left, right, operation_type) assert result.left == left assert result.right == right assert result.type == operation_type
def test_basic(operation: BoundOperation, events_pair: Tuple[BoundSweepEvent, BoundSweepEvent]) -> None: first_event, second_event = events_pair result = operation.possible_intersection(first_event, second_event) assert result in {0, 1, 2, 3}
def to_operations_with_events_lists_pair( operations: Tuple[BoundOperation, PortedOperation] ) -> Tuple[Tuple[BoundOperation, PortedOperation], Tuple[ List[BoundSweepEvent], List[PortedSweepEvent]]]: bound, ported = operations return operations, (BoundOperation.collect_events(bound.sweep()), PortedOperation.collect_events(ported.sweep()))
def test_basic( events_with_position_and_processed: Tuple[List[BoundSweepEvent], int, List[bool]] ) -> None: events, position, processed = events_with_position_and_processed result = BoundOperation.to_next_position(position, events, processed) assert isinstance(result, int)
def test_properties( events_with_position_and_processed: Tuple[List[BoundSweepEvent], int, List[bool]] ) -> None: events, position, processed = events_with_position_and_processed result = BoundOperation.to_next_position(position, events, processed) assert result in range(len(events))
def test_basic(events_lists_pair: Tuple[List[BoundSweepEvent], List[PortedSweepEvent]]) -> None: bound_events, ported_events = events_lists_pair bound_result = BoundOperation.collect_events(bound_events) ported_result = PortedOperation.collect_events(ported_events) assert are_bound_ported_sweep_events_lists_equal(bound_result, ported_result)
def to_bound_with_ported_operations_pair( left_polygons_pair: Tuple[BoundPolygon, PortedPolygon], right_polygons_pair: Tuple[BoundPolygon, PortedPolygon], operations_types_pair: Tuple[BoundOperationType, PortedOperationType], ) -> Tuple[BoundOperation, PortedOperation]: bound_left, ported_left = left_polygons_pair bound_right, ported_right = right_polygons_pair (bound_operation_type, ported_operation_type) = operations_types_pair return (BoundOperation(bound_left, bound_right, bound_operation_type), PortedOperation(ported_left, ported_right, ported_operation_type))
def test_basic( events_pair_with_position_and_processed: Tuple[Tuple[ List[BoundSweepEvent], List[PortedSweepEvent]], int, List[bool]] ) -> None: ((bound_events, ported_events), position, processed) = events_pair_with_position_and_processed bound_result = BoundOperation.to_next_position(position, bound_events, processed) ported_result = PortedOperation.to_next_position(position, ported_events, processed) assert bound_result == ported_result
def test_basic( left_polygons_pair: Tuple[BoundPolygon, PortedPolygon], right_polygons_pair: Tuple[BoundPolygon, PortedPolygon], operations_types_pair: Tuple[BoundOperationType, PortedOperationType]) -> None: bound_left, ported_left = left_polygons_pair bound_right, ported_right = right_polygons_pair bound_operation_type, ported_operation_type = operations_types_pair bound = BoundOperation(bound_left, bound_right, bound_operation_type) ported = PortedOperation(ported_left, ported_right, ported_operation_type) assert are_bound_ported_operations_equal(bound, ported)
def to_operation_with_events_list(operation: BoundOperation ) -> Tuple[ BoundOperation, List[BoundSweepEvent]]: return operation, BoundOperation.collect_events(operation.sweep())
def test_basic(operation: BoundOperation) -> None: result = operation.process_segments() assert result is None
def test_properties(operation: BoundOperation, event: BoundSweepEvent, previous_event: Optional[BoundSweepEvent]) -> None: operation.compute_fields(event, previous_event) assert event.in_result is operation.in_result(event)
def test_basic(operation: BoundOperation, event: BoundSweepEvent) -> None: assert isinstance(operation.in_result(event), bool)
def test_basic(events: List[BoundSweepEvent]) -> None: result = BoundOperation.collect_events(events) assert isinstance(result, list) assert all(isinstance(element, BoundSweepEvent) for element in result)
def test_same_event(operation: BoundOperation, event: BoundSweepEvent) -> None: with pytest.raises(ValueError): operation.possible_intersection(event, event)
def test_basic(operation: BoundOperation) -> None: result = operation.sweep() assert isinstance(result, list) assert all(isinstance(element, BoundSweepEvent) for element in result)
def to_operation_with_non_overlapping_arguments( polygons_pair: Tuple[BoundPolygon, BoundPolygon], operation_type: BoundOperationType ) -> BoundOperation: return BoundOperation(*polygons_pair, operation_type)
def pre_process_operation(operation: BoundOperation) -> BoundOperation: operation.process_segments() return operation
def test_basic(operation: BoundOperation) -> None: result = operation.run() assert result is None
def test_basic(operation: BoundOperation, event: BoundSweepEvent, point: BoundPoint) -> None: result = operation.divide_segment(event, point) assert result is None
def test_basic(operation: BoundOperation, event: BoundSweepEvent, previous_event: Optional[BoundSweepEvent]) -> None: result = operation.compute_fields(event, previous_event) assert result is None