-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_coords.py
40 lines (31 loc) · 1.16 KB
/
test_coords.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from . import unittest, numpy
from shapely import geometry
class CoordsTestCase(unittest.TestCase):
"""
Shapely assumes contiguous C-order float64 data for internal ops.
Data should be converted to contiguous float64 if numpy exists.
c9a0707 broke this a little bit.
"""
@unittest.skipIf(not numpy, 'Numpy required')
def test_data_promotion(self):
coords = numpy.array([[ 12, 34 ], [ 56, 78 ]], dtype=numpy.float32)
processed_coords = numpy.array(
geometry.LineString(coords).coords
)
self.assertEqual(
coords.tolist(),
processed_coords.tolist()
)
@unittest.skipIf(not numpy, 'Numpy required')
def test_data_destriding(self):
coords = numpy.array([[ 12, 34 ], [ 56, 78 ]], dtype=numpy.float32)
# Easy way to introduce striding: reverse list order
processed_coords = numpy.array(
geometry.LineString(coords[::-1]).coords
)
self.assertEqual(
coords[::-1].tolist(),
processed_coords.tolist()
)
def test_suite():
return unittest.TestLoader().loadTestsFromTestCase(CoordsTestCase)