Skip to content

Commit

Permalink
Textual changes + test
Browse files Browse the repository at this point in the history
  • Loading branch information
caspervdw committed Dec 20, 2019
1 parent 736faa2 commit 8a7664b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 5 additions & 5 deletions pygeos/linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ def line_merge(line):
return lib.line_merge(line)


def shared_paths(geom1, geom2):
def shared_paths(a, b, **kwargs):
"""Returns the shared paths between geom1 and geom2.
Both geometries should be linestrings or arrays of linestrings.
A geometrycollection or array of geometrycollections is returned
with each geometrycollection two elements. The first element is a
with two elements in each geometrycollection. The first element is a
multilinestring containing shared paths with the same direction
for both inputs. The second element is a multilinestring containing
shared paths with the opposite direction for the two inputs.
Parameters
----------
geom1 : Geometry or array_like
geom2 : Geometry or array_like
a : Geometry or array_like
b : Geometry or array_like
Examples
--------
Expand All @@ -111,4 +111,4 @@ def shared_paths(geom1, geom2):
>>> shared_paths(geom1, geom2)
<pygeos.Geometry GEOMETRYCOLLECTION (MULTILINESTRING EMPTY, MULTILINESTRING ((1 0, 1 1)))>
"""
return lib.shared_paths(geom1, geom2)
return lib.shared_paths(a, b, **kwargs)
10 changes: 8 additions & 2 deletions pygeos/test/test_linear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pygeos
import numpy as np
import pytest

from .common import empty_point
from .common import empty_line_string
Expand All @@ -8,8 +9,6 @@
from .common import linear_ring
from .common import multi_line_string

pygeos.linestrings([(0, 0), (1, 0), (1, 1)])


def test_line_interpolate_point_geom_array():
actual = pygeos.line_interpolate_point([line_string, linear_ring], -1)
Expand Down Expand Up @@ -77,3 +76,10 @@ def test_shared_paths_none():
assert pygeos.shared_paths(line_string, None) is None
assert pygeos.shared_paths(None, line_string) is None
assert pygeos.shared_paths(None, None) is None


def test_shared_paths_non_linestring():
g1 = pygeos.linestrings([(0, 0), (1, 0), (1, 1)])
g2 = pygeos.points(0, 1)
with pytest.raises(pygeos.GEOSException):
pygeos.shared_paths(g1, g2)

0 comments on commit 8a7664b

Please sign in to comment.