зеркало из https://github.com/microsoft/torchgeo.git
Add xfail for invalid BoundingBox
This commit is contained in:
Родитель
cec1f8b764
Коммит
b546e18bc7
|
@ -1,19 +1,30 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from torchgeo.datasets import BoundingBox, collate_dict
|
||||
from torchgeo.datasets.utils import working_dir
|
||||
|
||||
|
||||
def test_bounding_box() -> None:
|
||||
bbox = BoundingBox(0, 1, 2, 3, 4, 5)
|
||||
assert bbox.minx == 0
|
||||
assert bbox.maxx == 1
|
||||
assert bbox.miny == 2
|
||||
assert bbox.maxy == 3
|
||||
assert bbox.mint == 4
|
||||
assert bbox.maxt == 5
|
||||
class TestBoundingBox:
|
||||
def test_bounding_box(self) -> None:
|
||||
bbox = BoundingBox(0, 1, 2, 3, 4, 5)
|
||||
assert bbox.minx == 0
|
||||
assert bbox.maxx == 1
|
||||
assert bbox.miny == 2
|
||||
assert bbox.maxy == 3
|
||||
assert bbox.mint == 4
|
||||
assert bbox.maxt == 5
|
||||
|
||||
@pytest.mark.xfail(reason="not yet implemented")
|
||||
def test_invalid_box(self) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
BoundingBox(1, 0, 2, 3, 4, 5)
|
||||
with pytest.raises(ValueError):
|
||||
BoundingBox(0, 1, 3, 2, 4, 5)
|
||||
with pytest.raises(ValueError):
|
||||
BoundingBox(0, 1, 2, 3, 5, 4)
|
||||
|
||||
|
||||
def test_collate_dict() -> None:
|
||||
|
|
|
@ -9,6 +9,11 @@ from torch import Tensor
|
|||
class BoundingBox(NamedTuple):
|
||||
"""Named tuple for indexing spatiotemporal data."""
|
||||
|
||||
# TODO: is there a way we can ensure that the bounding box is valid?
|
||||
# i.e. maxx > minx, maxy > miny, maxt > mint
|
||||
# NamedTuple doesn't seem to allow getters/setters to validate input.
|
||||
# dataclasses may help, could we just subclass a normal tuple?
|
||||
|
||||
minx: Union[int, float]
|
||||
maxx: Union[int, float]
|
||||
miny: Union[int, float]
|
||||
|
|
Загрузка…
Ссылка в новой задаче