コード例 #1
0
def test_slope() -> None:
    """
        Tests if slope function works correctly.
    """
    point_1 = Point(x=3, y=4)
    point_2 = Point(x=0, y=0)

    assert point_1.slope(point_1) == float('inf')
    assert point_1.slope(point_2) == 4 / 3
    assert point_2.slope(point_1) == 4 / 3
コード例 #2
0
        def _sort_key(_point: Point) -> Tuple[float, float, float]:
            """
            HELPER. Defines sorting order of points.

            Args:
                _point: Point object.

            Returns:
                Tuple consisting of comparison oreder priority (slope, -y, x)
            """
            return _point.slope(start), -_point.y, _point.x