Skip to content

Commit 722a43c

Browse files
remove remaining usages from tests or mark to suppress warnings
1 parent d66f7f7 commit 722a43c

7 files changed

Lines changed: 19 additions & 12 deletions

File tree

shapely/geometry/collection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def geoms(self):
5656

5757
def geos_geometrycollection_from_py(ob):
5858
"""Creates a GEOS GeometryCollection from a list of geometries"""
59+
if isinstance(ob, BaseMultipartGeometry):
60+
ob = ob.geoms
5961
L = len(ob)
6062
N = 2
6163
subs = (c_void_p * L)()

tests/test_getitem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import unittest
1+
from . import unittest, shapely20_deprecated
22
from shapely import geometry
33

44

@@ -48,6 +48,7 @@ def test_slice_3d_coords(self):
4848

4949
class MultiGeomGetItemTestCase(unittest.TestCase):
5050

51+
@shapely20_deprecated
5152
def test_index_multigeom(self):
5253
c = [(float(x), float(-x)) for x in range(4)]
5354
g = geometry.MultiPoint(c)
@@ -56,11 +57,13 @@ def test_index_multigeom(self):
5657
self.assertRaises(IndexError, lambda: g[4])
5758
self.assertRaises(IndexError, lambda: g[-5])
5859

60+
@shapely20_deprecated
5961
def test_index_multigeom_misc(self):
6062
g = geometry.MultiLineString() # empty
6163
self.assertRaises(IndexError, lambda: g[0])
6264
self.assertRaises(TypeError, lambda: g[0.0])
6365

66+
@shapely20_deprecated
6467
def test_slice_multigeom(self):
6568
c = [(float(x), float(-x)) for x in range(4)]
6669
g = geometry.MultiPoint(c)

tests/test_multilinestring.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_multilinestring(self):
3232

3333
# Sub-geometry Access
3434
geom = MultiLineString([(((0.0, 0.0), (1.0, 2.0)))])
35-
self.assertIsInstance(geom[0], LineString)
36-
self.assertEqual(dump_coords(geom[0]), [(0.0, 0.0), (1.0, 2.0)])
35+
self.assertIsInstance(geom.geoms[0], LineString)
36+
self.assertEqual(dump_coords(geom.geoms[0]), [(0.0, 0.0), (1.0, 2.0)])
3737
with self.assertRaises(IndexError): # index out of range
3838
geom.geoms[1]
3939

@@ -42,7 +42,6 @@ def test_multilinestring(self):
4242
{'type': 'MultiLineString',
4343
'coordinates': (((0.0, 0.0), (1.0, 2.0)),)})
4444

45-
4645
def test_from_multilinestring_z(self):
4746
coords1 = [(0.0, 1.0, 2.0), (3.0, 4.0, 5.0)]
4847
coords2 = [(6.0, 7.0, 8.0), (9.0, 10.0, 11.0)]
@@ -85,6 +84,7 @@ def test_numpy_adapter(self):
8584

8685
# TODO: is there an inverse?
8786

87+
@shapely20_deprecated
8888
def test_subgeom_access(self):
8989
line0 = LineString([(0.0, 1.0), (2.0, 3.0)])
9090
line1 = LineString([(4.0, 5.0), (6.0, 7.0)])

tests/test_multipoint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_numpy_adapter(self):
8989
pas = asarray(geoma)
9090
assert_array_equal(pas, array([[1., 2.], [3., 4.]]))
9191

92+
@shapely20_deprecated
9293
def test_subgeom_access(self):
9394
p0 = Point(1.0, 2.0)
9495
p1 = Point(3.0, 4.0)

tests/test_multipolygon.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_multipolygon_adapter(self):
7474
self.assertEqual(len(mpa.geoms[0].interiors), 1)
7575
self.assertEqual(len(mpa.geoms[0].interiors[0].coords), 5)
7676

77+
@shapely20_deprecated
7778
def test_subgeom_access(self):
7879
poly0 = Polygon([(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)])
7980
poly1 = Polygon([(0.25, 0.25), (0.25, 0.5), (0.5, 0.5), (0.5, 0.25)])

tests/test_shared_paths.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def test_shared_paths_forward(self):
1717
a, b = result.geoms
1818
self.assertTrue(isinstance(a, MultiLineString))
1919
self.assertTrue(len(a) == 1)
20-
self.assertEqual(a[0].coords[:], [(5, 0), (10, 0)])
20+
self.assertEqual(a.geoms[0].coords[:], [(5, 0), (10, 0)])
2121
self.assertTrue(b.is_empty)
2222

23-
def test_shared_paths_forward(self):
23+
def test_shared_paths_forward2(self):
2424
g1 = LineString([(0, 0), (10, 0), (10, 5), (20, 5)])
2525
g2 = LineString([(15, 0), (5, 0)])
2626
result = shared_paths(g1, g2)
@@ -30,7 +30,7 @@ def test_shared_paths_forward(self):
3030
a, b = result.geoms
3131
self.assertTrue(isinstance(b, MultiLineString))
3232
self.assertTrue(len(b) == 1)
33-
self.assertEqual(b[0].coords[:], [(5, 0), (10, 0)])
33+
self.assertEqual(b.geoms[0].coords[:], [(5, 0), (10, 0)])
3434
self.assertTrue(a.is_empty)
3535

3636
def test_wrong_type(self):

tests/test_split.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def helper(self, geom, splitter, expected_chunks):
2323
raise ValueError
2424
elif expected_chunks == 1:
2525
# not split --> expected equal to line
26-
self.assertTrue(s[0].equals(geom))
26+
self.assertTrue(s.geoms[0].equals(geom))
2727

2828
def test_split_closed_line_with_point(self):
2929
# point at start/end of closed ring -> return equal
@@ -175,15 +175,15 @@ def test_split_closed_ring_with_point(self):
175175
splitter = Point([0.0, 0.5])
176176
self.helper(self.ls, splitter, 2)
177177
result = split(self.ls, splitter)
178-
assert result[0].coords[:] == [(0, 0), (0.0, 0.5)]
179-
assert result[1].coords[:] == [(0.0, 0.5), (0, 1), (1, 1), (1, 0), (0, 0)]
178+
assert result.geoms[0].coords[:] == [(0, 0), (0.0, 0.5)]
179+
assert result.geoms[1].coords[:] == [(0.0, 0.5), (0, 1), (1, 1), (1, 0), (0, 0)]
180180

181181
# previously failed, see GH#585
182182
splitter = Point([0.5, 0.0])
183183
self.helper(self.ls, splitter, 2)
184184
result = split(self.ls, splitter)
185-
assert result[0].coords[:] == [(0, 0), (0, 1), (1, 1), (1, 0), (0.5, 0)]
186-
assert result[1].coords[:] == [(0.5, 0), (0, 0)]
185+
assert result.geoms[0].coords[:] == [(0, 0), (0, 1), (1, 1), (1, 0), (0.5, 0)]
186+
assert result.geoms[1].coords[:] == [(0.5, 0), (0, 0)]
187187

188188
splitter = Point([2.0, 2.0])
189189
self.helper(self.ls, splitter, 1)

0 commit comments

Comments
 (0)