17 lines
490 B
Python
17 lines
490 B
Python
import pytest
|
|
import numpy
|
|
|
|
from ..shapes import Polygon
|
|
|
|
|
|
def test_manhattanize() -> None:
|
|
pytest.importorskip("float_raster")
|
|
pytest.importorskip("skimage.measure")
|
|
poly = Polygon([[0, 5], [5, 10], [10, 5], [5, 0]])
|
|
grid = numpy.arange(0, 11, 1)
|
|
|
|
manhattan_polys = poly.manhattanize(grid, grid)
|
|
assert len(manhattan_polys) >= 1
|
|
for mp in manhattan_polys:
|
|
dv = numpy.diff(mp.vertices, axis=0)
|
|
assert numpy.all((dv[:, 0] == 0) | (dv[:, 1] == 0))
|