예제 #1
0
def test_invalid_bbox():
    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=10.0, y1=10.0, y2=11.0)

    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=11.0, y1=10.0, y2=10.0)
예제 #2
0
def test_eq():
    bb1 = BoundingBox(x1=10, x2=20, y1=30, y2=40)
    bb2 = BoundingBox(x1=10, x2=20, y1=30, y2=40)

    assert bb1 == bb2
    assert bb1 != BoundingBox(x1=11, x2=20, y1=30, y2=40)
예제 #3
0
    assert b.area == expected


def test_invalid_bbox():
    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=10.0, y1=10.0, y2=11.0)

    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=11.0, y1=10.0, y2=10.0)


@pytest.mark.parametrize(
    "bb1,bb2,expected",
    [
        (
            BoundingBox(x1=10, x2=20, y1=30, y2=40),
            BoundingBox(x1=10, x2=20, y1=30, y2=40),
            100,
        ),
        (
            BoundingBox(x1=10, x2=20, y1=30, y2=40),
            BoundingBox(x1=5, x2=15, y1=30, y2=40),
            50,
        ),
        (
            BoundingBox(x1=10, x2=20, y1=30, y2=40),
            BoundingBox(x1=0, x2=10, y1=30, y2=40),
            0,
        ),
        (
            BoundingBox(x1=10, x2=20, y1=30, y2=40),
예제 #4
0
def test_bbox_area(x1, x2, y1, y2, expected):
    b = BoundingBox(x1=x1, x2=x2, y1=y1, y2=y2)
    assert b.area == expected
예제 #5
0
])
def test_bbox_area(x1, x2, y1, y2, expected):
    b = BoundingBox(x1=x1, x2=x2, y1=y1, y2=y2)
    assert b.area == expected


def test_invalid_bbox():
    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=10.0, y1=10.0, y2=11.0)

    with pytest.raises(ValueError):
        BoundingBox(x1=10.0, x2=11.0, y1=10.0, y2=10.0)


@pytest.mark.parametrize("bb1,bb2,expected", [
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=10, x2=20, y1=30, y2=40), 100),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=5, x2=15, y1=30, y2=40), 50),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=0, x2=10, y1=30, y2=40), 0),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=0, x2=9, y1=30, y2=40), 0),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=0, x2=11, y1=30, y2=40), 10),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=0, x2=11, y1=35, y2=40), 5),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=0, x2=11, y1=40, y2=41), 0),
    (BoundingBox(x1=10, x2=20, y1=30,
                 y2=40), BoundingBox(x1=-10, x2=-20, y1=30, y2=40), 0),
])