def test_relate_pattern(): g = pygeos.linestrings([(0, 0), (1, 0), (1, 1)]) polygon = pygeos.box(0, 0, 2, 2) assert pygeos.relate(g, polygon) == "11F00F212" assert pygeos.relate_pattern(g, polygon, "11F00F212") assert pygeos.relate_pattern(g, polygon, "*********") assert not pygeos.relate_pattern(g, polygon, "F********")
def test_relate_pattern_non_scalar(): with pytest.raises(ValueError, match="only supports scalar"): pygeos.relate_pattern([point] * 2, polygon, ["*********"] * 2)
def test_relate_pattern_non_string(pattern): with pytest.raises(TypeError, match="expected string"): pygeos.relate_pattern(point, polygon, pattern)
def test_relate_pattern_incorrect_length(): with pytest.raises(pygeos.GEOSException, match="Should be length 9"): pygeos.relate_pattern(point, polygon, "**") with pytest.raises(pygeos.GEOSException, match="Should be length 9"): pygeos.relate_pattern(point, polygon, "**********")
def test_relate_pattern_none(g1, g2): assert pygeos.relate_pattern(g1, g2, "*" * 9).item() is False
def test_relate_pattern_empty(): assert pygeos.relate_pattern(empty, empty, "*" * 9).item() is True