ZTWHHH commited on
Commit
96858cd
·
verified ·
1 Parent(s): cc602b0

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. vllm/lib/python3.10/site-packages/cupyx/cudnn.cpython-310-x86_64-linux-gnu.so +3 -0
  3. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.10.0_pickle_py33_np18.pkl +3 -0
  4. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.10.0_pickle_py33_np18.pkl.bz2 +3 -0
  5. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py27_np16.pkl_02.npy +3 -0
  6. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py27_np16.pkl_04.npy +3 -0
  7. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py34_np19.pkl_01.npy +3 -0
  8. vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.4.dev0_compressed_cache_size_pickle_py35_np19.gz +3 -0
  9. vllm/lib/python3.10/site-packages/shapely/geometry/__pycache__/__init__.cpython-310.pyc +0 -0
  10. vllm/lib/python3.10/site-packages/shapely/tests/__init__.py +0 -0
  11. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  12. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/common.cpython-310.pyc +0 -0
  13. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_constructive.cpython-310.pyc +0 -0
  14. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_coordinates.cpython-310.pyc +0 -0
  15. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_creation.cpython-310.pyc +0 -0
  16. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_creation_indices.cpython-310.pyc +0 -0
  17. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_geometry.cpython-310.pyc +0 -0
  18. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_io.cpython-310.pyc +0 -0
  19. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_linear.cpython-310.pyc +0 -0
  20. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_measurement.cpython-310.pyc +0 -0
  21. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_misc.cpython-310.pyc +0 -0
  22. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_plotting.cpython-310.pyc +0 -0
  23. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_predicates.cpython-310.pyc +0 -0
  24. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_ragged_array.cpython-310.pyc +0 -0
  25. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_set_operations.cpython-310.pyc +0 -0
  26. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_strtree.cpython-310.pyc +0 -0
  27. vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_testing.cpython-310.pyc +0 -0
  28. vllm/lib/python3.10/site-packages/shapely/tests/common.py +125 -0
  29. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/__init__.cpython-310.pyc +0 -0
  30. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_collection.cpython-310.pyc +0 -0
  31. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_coords.cpython-310.pyc +0 -0
  32. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_decimal.cpython-310.pyc +0 -0
  33. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_emptiness.cpython-310.pyc +0 -0
  34. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_equality.cpython-310.pyc +0 -0
  35. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_format.cpython-310.pyc +0 -0
  36. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_geometry_base.cpython-310.pyc +0 -0
  37. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_hash.cpython-310.pyc +0 -0
  38. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_linestring.cpython-310.pyc +0 -0
  39. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multi.cpython-310.pyc +0 -0
  40. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multilinestring.cpython-310.pyc +0 -0
  41. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multipoint.cpython-310.pyc +0 -0
  42. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multipolygon.cpython-310.pyc +0 -0
  43. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_point.cpython-310.pyc +0 -0
  44. vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_polygon.cpython-310.pyc +0 -0
  45. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_collection.py +82 -0
  46. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_coords.py +102 -0
  47. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_decimal.py +117 -0
  48. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_emptiness.py +98 -0
  49. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_equality.py +237 -0
  50. vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_geometry_base.py +281 -0
.gitattributes CHANGED
@@ -1800,3 +1800,4 @@ vllm/lib/python3.10/site-packages/cupy/_core/_fusion_trace.cpython-310-x86_64-li
1800
  parrot/lib/python3.10/site-packages/scipy/optimize/_lsq/givens_elimination.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1801
  vllm/lib/python3.10/site-packages/shapely/_geos.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1802
  vllm/lib/python3.10/site-packages/shapely/lib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
 
 
1800
  parrot/lib/python3.10/site-packages/scipy/optimize/_lsq/givens_elimination.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1801
  vllm/lib/python3.10/site-packages/shapely/_geos.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1802
  vllm/lib/python3.10/site-packages/shapely/lib.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
1803
+ vllm/lib/python3.10/site-packages/cupyx/cudnn.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
vllm/lib/python3.10/site-packages/cupyx/cudnn.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdc9b696bd071426ccbb30e5a2c43f03afd0c5ff54a08b8f39bd245e140a263f
3
+ size 4677920
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.10.0_pickle_py33_np18.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e064c2eecfdc58d552844467da7bd56eca596098322bfd266a7e1312abdd5735
3
+ size 1068
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.10.0_pickle_py33_np18.pkl.bz2 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e86d6f6ecfe2626cf691827ac38a81d64ec3ebb527c5432eb344b8496781b45a
3
+ size 1000
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py27_np16.pkl_02.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c1cf36cb781fbcc21b953bb0a0b45df092da0eae0e765882e5963ccd70105b1
3
+ size 120
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py27_np16.pkl_04.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ecbe244294ba93e08479b16c1b9a9411e3569ff660ed0459dca1d241381df05
3
+ size 104
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.2_pickle_py34_np19.pkl_01.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0efbd7d9ce7eec3a6e0a0db41e795e0396cca3d6b037dad6c61b464843d28809
3
+ size 120
vllm/lib/python3.10/site-packages/joblib/test/data/joblib_0.9.4.dev0_compressed_cache_size_pickle_py35_np19.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2361f589b31d2863627edcb96612280ae5c0a59c9496d89dab7de493670f93b
3
+ size 802
vllm/lib/python3.10/site-packages/shapely/geometry/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (919 Bytes). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (163 Bytes). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/common.cpython-310.pyc ADDED
Binary file (4.06 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_constructive.cpython-310.pyc ADDED
Binary file (22.6 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_coordinates.cpython-310.pyc ADDED
Binary file (8.3 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_creation.cpython-310.pyc ADDED
Binary file (15.8 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_creation_indices.cpython-310.pyc ADDED
Binary file (10.3 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_geometry.cpython-310.pyc ADDED
Binary file (18.9 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_io.cpython-310.pyc ADDED
Binary file (22.9 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_linear.cpython-310.pyc ADDED
Binary file (6.9 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_measurement.cpython-310.pyc ADDED
Binary file (9.1 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_misc.cpython-310.pyc ADDED
Binary file (5.93 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_plotting.cpython-310.pyc ADDED
Binary file (3.6 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_predicates.cpython-310.pyc ADDED
Binary file (10 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_ragged_array.cpython-310.pyc ADDED
Binary file (7.94 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_set_operations.cpython-310.pyc ADDED
Binary file (12.2 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_strtree.cpython-310.pyc ADDED
Binary file (38 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/__pycache__/test_testing.cpython-310.pyc ADDED
Binary file (3.1 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/common.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from contextlib import contextmanager
2
+
3
+ import numpy as np
4
+ import pytest
5
+
6
+ import shapely
7
+
8
+ shapely20_todo = pytest.mark.xfail(
9
+ strict=False, reason="Not yet implemented for Shapely 2.0"
10
+ )
11
+
12
+ point_polygon_testdata = (
13
+ shapely.points(np.arange(6), np.arange(6)),
14
+ shapely.box(2, 2, 4, 4),
15
+ )
16
+ point = shapely.Point(2, 3)
17
+ line_string = shapely.LineString([(0, 0), (1, 0), (1, 1)])
18
+ linear_ring = shapely.LinearRing([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)])
19
+ polygon = shapely.Polygon([(0, 0), (2, 0), (2, 2), (0, 2), (0, 0)])
20
+ multi_point = shapely.MultiPoint([(0, 0), (1, 2)])
21
+ multi_line_string = shapely.MultiLineString([[(0, 0), (1, 2)]])
22
+ multi_polygon = shapely.multipolygons(
23
+ [
24
+ [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)],
25
+ [(2.1, 2.1), (2.2, 2.1), (2.2, 2.2), (2.1, 2.2), (2.1, 2.1)],
26
+ ]
27
+ )
28
+ geometry_collection = shapely.GeometryCollection(
29
+ [shapely.Point(51, -1), shapely.LineString([(52, -1), (49, 2)])]
30
+ )
31
+ point_z = shapely.Point(2, 3, 4)
32
+ line_string_z = shapely.LineString([(0, 0, 4), (1, 0, 4), (1, 1, 4)])
33
+ polygon_z = shapely.Polygon([(0, 0, 4), (2, 0, 4), (2, 2, 4), (0, 2, 4), (0, 0, 4)])
34
+ geometry_collection_z = shapely.GeometryCollection([point_z, line_string_z])
35
+ polygon_with_hole = shapely.Polygon(
36
+ [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)],
37
+ holes=[[(2, 2), (2, 4), (4, 4), (4, 2), (2, 2)]],
38
+ )
39
+ empty_point = shapely.from_wkt("POINT EMPTY")
40
+ empty_point_z = shapely.from_wkt("POINT Z EMPTY")
41
+ empty_line_string = shapely.from_wkt("LINESTRING EMPTY")
42
+ empty_line_string_z = shapely.from_wkt("LINESTRING Z EMPTY")
43
+ empty_polygon = shapely.from_wkt("POLYGON EMPTY")
44
+ empty = shapely.from_wkt("GEOMETRYCOLLECTION EMPTY")
45
+ multi_point_z = shapely.MultiPoint([(0, 0, 4), (1, 2, 4)])
46
+ multi_line_string_z = shapely.MultiLineString([[(0, 0, 4), (1, 2, 4)]])
47
+ multi_polygon_z = shapely.multipolygons(
48
+ [
49
+ [(0, 0, 4), (1, 0, 4), (1, 1, 4), (0, 1, 4), (0, 0, 4)],
50
+ [(2.1, 2.1, 4), (2.2, 2.1, 4), (2.2, 2.2, 4), (2.1, 2.2, 4), (2.1, 2.1, 4)],
51
+ ]
52
+ )
53
+ polygon_with_hole_z = shapely.Polygon(
54
+ [(0, 0, 4), (0, 10, 4), (10, 10, 4), (10, 0, 4), (0, 0, 4)],
55
+ holes=[[(2, 2, 4), (2, 4, 4), (4, 4, 4), (4, 2, 4), (2, 2, 4)]],
56
+ )
57
+
58
+ all_types = (
59
+ point,
60
+ line_string,
61
+ linear_ring,
62
+ polygon,
63
+ multi_point,
64
+ multi_line_string,
65
+ multi_polygon,
66
+ geometry_collection,
67
+ empty,
68
+ )
69
+
70
+ all_types_z = (
71
+ point_z,
72
+ line_string_z,
73
+ polygon_z,
74
+ multi_point_z,
75
+ multi_line_string_z,
76
+ multi_polygon_z,
77
+ polygon_with_hole_z,
78
+ geometry_collection_z,
79
+ empty_point_z,
80
+ empty_line_string_z,
81
+ )
82
+
83
+
84
+ @contextmanager
85
+ def ignore_invalid(condition=True):
86
+ if condition:
87
+ with np.errstate(invalid="ignore"):
88
+ yield
89
+ else:
90
+ yield
91
+
92
+
93
+ with ignore_invalid():
94
+ line_string_nan = shapely.LineString([(np.nan, np.nan), (np.nan, np.nan)])
95
+
96
+
97
+ class ArrayLike:
98
+ """
99
+ Simple numpy Array like class that implements the
100
+ ufunc protocol.
101
+ """
102
+
103
+ def __init__(self, array):
104
+ self._array = np.asarray(array)
105
+
106
+ def __len__(self):
107
+ return len(self._array)
108
+
109
+ def __getitem(self, key):
110
+ return self._array[key]
111
+
112
+ def __iter__(self):
113
+ return self._array.__iter__()
114
+
115
+ def __array__(self):
116
+ return np.asarray(self._array)
117
+
118
+ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
119
+ if method == "__call__":
120
+ inputs = [
121
+ arg._array if isinstance(arg, self.__class__) else arg for arg in inputs
122
+ ]
123
+ return self.__class__(ufunc(*inputs, **kwargs))
124
+ else:
125
+ return NotImplemented
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (172 Bytes). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_collection.cpython-310.pyc ADDED
Binary file (2.57 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_coords.cpython-310.pyc ADDED
Binary file (4.61 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_decimal.cpython-310.pyc ADDED
Binary file (2.09 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_emptiness.cpython-310.pyc ADDED
Binary file (3.51 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_equality.cpython-310.pyc ADDED
Binary file (5.01 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_format.cpython-310.pyc ADDED
Binary file (3.27 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_geometry_base.cpython-310.pyc ADDED
Binary file (8.66 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_hash.cpython-310.pyc ADDED
Binary file (811 Bytes). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_linestring.cpython-310.pyc ADDED
Binary file (6.85 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multi.cpython-310.pyc ADDED
Binary file (697 Bytes). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multilinestring.cpython-310.pyc ADDED
Binary file (3.05 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multipoint.cpython-310.pyc ADDED
Binary file (3.01 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_multipolygon.cpython-310.pyc ADDED
Binary file (2.49 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_point.cpython-310.pyc ADDED
Binary file (5.21 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/__pycache__/test_polygon.cpython-310.pyc ADDED
Binary file (13.4 kB). View file
 
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_collection.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from shapely import GeometryCollection, LineString, Point, wkt
5
+ from shapely.geometry import shape
6
+
7
+
8
+ @pytest.fixture()
9
+ def geometrycollection_geojson():
10
+ return {
11
+ "type": "GeometryCollection",
12
+ "geometries": [
13
+ {"type": "Point", "coordinates": (0, 3, 0)},
14
+ {"type": "LineString", "coordinates": ((2, 0), (1, 0))},
15
+ ],
16
+ }
17
+
18
+
19
+ @pytest.mark.parametrize(
20
+ "geom",
21
+ [
22
+ GeometryCollection(),
23
+ shape({"type": "GeometryCollection", "geometries": []}),
24
+ wkt.loads("GEOMETRYCOLLECTION EMPTY"),
25
+ ],
26
+ )
27
+ def test_empty(geom):
28
+ assert geom.geom_type == "GeometryCollection"
29
+ assert geom.is_empty
30
+ assert len(geom.geoms) == 0
31
+ assert list(geom.geoms) == []
32
+
33
+
34
+ def test_empty_subgeoms():
35
+ geom = GeometryCollection([Point(), LineString()])
36
+ assert geom.geom_type == "GeometryCollection"
37
+ assert geom.is_empty
38
+ assert len(geom.geoms) == 2
39
+ assert list(geom.geoms) == [Point(), LineString()]
40
+
41
+
42
+ def test_child_with_deleted_parent():
43
+ # test that we can remove a collection while keeping
44
+ # children around
45
+ a = LineString([(0, 0), (1, 1), (1, 2), (2, 2)])
46
+ b = LineString([(0, 0), (1, 1), (2, 1), (2, 2)])
47
+ collection = a.intersection(b)
48
+
49
+ child = collection.geoms[0]
50
+ # delete parent of child
51
+ del collection
52
+
53
+ # access geometry, this should not seg fault as 1.2.15 did
54
+ assert child.wkt is not None
55
+
56
+
57
+ def test_from_geojson(geometrycollection_geojson):
58
+ geom = shape(geometrycollection_geojson)
59
+ assert geom.geom_type == "GeometryCollection"
60
+ assert len(geom.geoms) == 2
61
+
62
+ geom_types = [g.geom_type for g in geom.geoms]
63
+ assert "Point" in geom_types
64
+ assert "LineString" in geom_types
65
+
66
+
67
+ def test_geointerface(geometrycollection_geojson):
68
+ geom = shape(geometrycollection_geojson)
69
+ assert geom.__geo_interface__ == geometrycollection_geojson
70
+
71
+
72
+ def test_len_raises(geometrycollection_geojson):
73
+ geom = shape(geometrycollection_geojson)
74
+ with pytest.raises(TypeError):
75
+ len(geom)
76
+
77
+
78
+ def test_numpy_object_array():
79
+ geom = GeometryCollection([LineString([(0, 0), (1, 1)])])
80
+ ar = np.empty(1, object)
81
+ ar[:] = [geom]
82
+ assert ar[0] == geom
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_coords.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from shapely import LineString
5
+ from shapely.tests.common import line_string, line_string_z, point, point_z
6
+
7
+
8
+ class TestCoords:
9
+ """
10
+ Shapely assumes contiguous C-order float64 data for internal ops.
11
+ Data should be converted to contiguous float64 if numpy exists.
12
+ c9a0707 broke this a little bit.
13
+ """
14
+
15
+ def test_data_promotion(self):
16
+ coords = np.array([[12, 34], [56, 78]], dtype=np.float32)
17
+ processed_coords = np.array(LineString(coords).coords)
18
+
19
+ assert coords.tolist() == processed_coords.tolist()
20
+
21
+ def test_data_destriding(self):
22
+ coords = np.array([[12, 34], [56, 78]], dtype=np.float32)
23
+
24
+ # Easy way to introduce striding: reverse list order
25
+ processed_coords = np.array(LineString(coords[::-1]).coords)
26
+
27
+ assert coords[::-1].tolist() == processed_coords.tolist()
28
+
29
+
30
+ class TestCoordsGetItem:
31
+ def test_index_2d_coords(self):
32
+ c = [(float(x), float(-x)) for x in range(4)]
33
+ g = LineString(c)
34
+ for i in range(-4, 4):
35
+ assert g.coords[i] == c[i]
36
+ with pytest.raises(IndexError):
37
+ g.coords[4]
38
+ with pytest.raises(IndexError):
39
+ g.coords[-5]
40
+
41
+ def test_index_3d_coords(self):
42
+ c = [(float(x), float(-x), float(x * 2)) for x in range(4)]
43
+ g = LineString(c)
44
+ for i in range(-4, 4):
45
+ assert g.coords[i] == c[i]
46
+ with pytest.raises(IndexError):
47
+ g.coords[4]
48
+ with pytest.raises(IndexError):
49
+ g.coords[-5]
50
+
51
+ def test_index_coords_misc(self):
52
+ g = LineString() # empty
53
+ with pytest.raises(IndexError):
54
+ g.coords[0]
55
+ with pytest.raises(TypeError):
56
+ g.coords[0.0]
57
+
58
+ def test_slice_2d_coords(self):
59
+ c = [(float(x), float(-x)) for x in range(4)]
60
+ g = LineString(c)
61
+ assert g.coords[1:] == c[1:]
62
+ assert g.coords[:-1] == c[:-1]
63
+ assert g.coords[::-1] == c[::-1]
64
+ assert g.coords[::2] == c[::2]
65
+ assert g.coords[:4] == c[:4]
66
+ assert g.coords[4:] == c[4:] == []
67
+
68
+ def test_slice_3d_coords(self):
69
+ c = [(float(x), float(-x), float(x * 2)) for x in range(4)]
70
+ g = LineString(c)
71
+ assert g.coords[1:] == c[1:]
72
+ assert g.coords[:-1] == c[:-1]
73
+ assert g.coords[::-1] == c[::-1]
74
+ assert g.coords[::2] == c[::2]
75
+ assert g.coords[:4] == c[:4]
76
+ assert g.coords[4:] == c[4:] == []
77
+
78
+
79
+ class TestXY:
80
+ """New geometry/coordseq method 'xy' makes numpy interop easier"""
81
+
82
+ def test_arrays(self):
83
+ x, y = LineString([(0, 0), (1, 1)]).xy
84
+ assert len(x) == 2
85
+ assert list(x) == [0.0, 1.0]
86
+ assert len(y) == 2
87
+ assert list(y) == [0.0, 1.0]
88
+
89
+
90
+ @pytest.mark.parametrize("geom", [point, point_z, line_string, line_string_z])
91
+ def test_coords_array_copy(geom):
92
+ """Test CoordinateSequence.__array__ method."""
93
+ coord_seq = geom.coords
94
+ assert np.array(coord_seq) is not np.array(coord_seq)
95
+ assert np.array(coord_seq, copy=True) is not np.array(coord_seq, copy=True)
96
+
97
+ # Behaviour of copy=False is different between NumPy 1.x and 2.x
98
+ if int(np.version.short_version.split(".", 1)[0]) >= 2:
99
+ with pytest.raises(ValueError, match="A copy is always created"):
100
+ np.array(coord_seq, copy=False)
101
+ else:
102
+ assert np.array(coord_seq, copy=False) is np.array(coord_seq, copy=False)
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_decimal.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from decimal import Decimal
2
+
3
+ import pytest
4
+
5
+ from shapely import (
6
+ GeometryCollection,
7
+ LinearRing,
8
+ LineString,
9
+ MultiLineString,
10
+ MultiPoint,
11
+ MultiPolygon,
12
+ Point,
13
+ Polygon,
14
+ )
15
+
16
+ items2d = [
17
+ [(0.0, 0.0), (70.0, 120.0), (140.0, 0.0), (0.0, 0.0)],
18
+ [(60.0, 80.0), (80.0, 80.0), (70.0, 60.0), (60.0, 80.0)],
19
+ ]
20
+
21
+ items2d_mixed = [
22
+ [
23
+ (Decimal(0.0), Decimal(0.0)),
24
+ (Decimal(70.0), 120.0),
25
+ (140.0, Decimal(0.0)),
26
+ (0.0, 0.0),
27
+ ],
28
+ [
29
+ (Decimal(60.0), Decimal(80.0)),
30
+ (Decimal(80.0), 80.0),
31
+ (70.0, Decimal(60.0)),
32
+ (60.0, 80.0),
33
+ ],
34
+ ]
35
+
36
+ items2d_decimal = [
37
+ [
38
+ (Decimal(0.0), Decimal(0.0)),
39
+ (Decimal(70.0), Decimal(120.0)),
40
+ (Decimal(140.0), Decimal(0.0)),
41
+ (Decimal(0.0), Decimal(0.0)),
42
+ ],
43
+ [
44
+ (Decimal(60.0), Decimal(80.0)),
45
+ (Decimal(80.0), Decimal(80.0)),
46
+ (Decimal(70.0), Decimal(60.0)),
47
+ (Decimal(60.0), Decimal(80.0)),
48
+ ],
49
+ ]
50
+
51
+ items3d = [
52
+ [(0.0, 0.0, 1), (70.0, 120.0, 2), (140.0, 0.0, 3), (0.0, 0.0, 1)],
53
+ [(60.0, 80.0, 1), (80.0, 80.0, 2), (70.0, 60.0, 3), (60.0, 80.0, 1)],
54
+ ]
55
+
56
+ items3d_mixed = [
57
+ [
58
+ (Decimal(0.0), Decimal(0.0), Decimal(1)),
59
+ (Decimal(70.0), 120.0, Decimal(2)),
60
+ (140.0, Decimal(0.0), 3),
61
+ (0.0, 0.0, 1),
62
+ ],
63
+ [
64
+ (Decimal(60.0), Decimal(80.0), Decimal(1)),
65
+ (Decimal(80.0), 80.0, 2),
66
+ (70.0, Decimal(60.0), Decimal(3)),
67
+ (60.0, 80.0, 1),
68
+ ],
69
+ ]
70
+
71
+ items3d_decimal = [
72
+ [
73
+ (Decimal(0.0), Decimal(0.0), Decimal(1)),
74
+ (Decimal(70.0), Decimal(120.0), Decimal(2)),
75
+ (Decimal(140.0), Decimal(0.0), Decimal(3)),
76
+ (Decimal(0.0), Decimal(0.0), Decimal(1)),
77
+ ],
78
+ [
79
+ (Decimal(60.0), Decimal(80.0), Decimal(1)),
80
+ (Decimal(80.0), Decimal(80.0), Decimal(2)),
81
+ (Decimal(70.0), Decimal(60.0), Decimal(3)),
82
+ (Decimal(60.0), Decimal(80.0), Decimal(1)),
83
+ ],
84
+ ]
85
+
86
+ all_geoms = [
87
+ [
88
+ Point(items[0][0]),
89
+ Point(*items[0][0]),
90
+ MultiPoint(items[0]),
91
+ LinearRing(items[0]),
92
+ LineString(items[0]),
93
+ MultiLineString(items),
94
+ Polygon(items[0]),
95
+ MultiPolygon(
96
+ [
97
+ Polygon(items[1]),
98
+ Polygon(items[0], holes=items[1:]),
99
+ ]
100
+ ),
101
+ GeometryCollection([Point(items[0][0]), Polygon(items[0])]),
102
+ ]
103
+ for items in [
104
+ items2d,
105
+ items2d_mixed,
106
+ items2d_decimal,
107
+ items3d,
108
+ items3d_mixed,
109
+ items3d_decimal,
110
+ ]
111
+ ]
112
+
113
+
114
+ @pytest.mark.parametrize("geoms", list(zip(*all_geoms)))
115
+ def test_decimal(geoms):
116
+ assert geoms[0] == geoms[1] == geoms[2]
117
+ assert geoms[3] == geoms[4] == geoms[5]
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_emptiness.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+
3
+ import numpy as np
4
+ import pytest
5
+
6
+ from shapely import (
7
+ GeometryCollection,
8
+ LinearRing,
9
+ LineString,
10
+ MultiLineString,
11
+ MultiPoint,
12
+ MultiPolygon,
13
+ Point,
14
+ Polygon,
15
+ )
16
+ from shapely.geometry import mapping, shape
17
+ from shapely.geometry.base import BaseGeometry, EmptyGeometry
18
+
19
+
20
+ def empty_generator():
21
+ return iter([])
22
+
23
+
24
+ class TestEmptiness:
25
+ def test_empty_class(self):
26
+ with pytest.warns(FutureWarning):
27
+ g = EmptyGeometry()
28
+ assert g.is_empty
29
+
30
+ def test_empty_base(self):
31
+ with pytest.warns(FutureWarning):
32
+ g = BaseGeometry()
33
+ assert g.is_empty
34
+
35
+ def test_empty_point(self):
36
+ assert Point().is_empty
37
+
38
+ def test_empty_multipoint(self):
39
+ assert MultiPoint().is_empty
40
+
41
+ def test_empty_geometry_collection(self):
42
+ assert GeometryCollection().is_empty
43
+
44
+ def test_empty_linestring(self):
45
+ assert LineString().is_empty
46
+ assert LineString(None).is_empty
47
+ assert LineString([]).is_empty
48
+ assert LineString(empty_generator()).is_empty
49
+
50
+ def test_empty_multilinestring(self):
51
+ assert MultiLineString([]).is_empty
52
+
53
+ def test_empty_polygon(self):
54
+ assert Polygon().is_empty
55
+ assert Polygon(None).is_empty
56
+ assert Polygon([]).is_empty
57
+ assert Polygon(empty_generator()).is_empty
58
+
59
+ def test_empty_multipolygon(self):
60
+ assert MultiPolygon([]).is_empty
61
+
62
+ def test_empty_linear_ring(self):
63
+ assert LinearRing().is_empty
64
+ assert LinearRing(None).is_empty
65
+ assert LinearRing([]).is_empty
66
+ assert LinearRing(empty_generator()).is_empty
67
+
68
+
69
+ def test_numpy_object_array():
70
+ geoms = [Point(), GeometryCollection()]
71
+ arr = np.empty(2, object)
72
+ arr[:] = geoms
73
+
74
+
75
+ def test_shape_empty():
76
+ empty_mp = MultiPolygon()
77
+ empty_json = mapping(empty_mp)
78
+ empty_shape = shape(empty_json)
79
+ assert empty_shape.is_empty
80
+
81
+
82
+ @pytest.mark.parametrize(
83
+ "geom",
84
+ [
85
+ Point(),
86
+ LineString(),
87
+ Polygon(),
88
+ MultiPoint(),
89
+ MultiLineString(),
90
+ MultiPolygon(),
91
+ GeometryCollection(),
92
+ LinearRing(),
93
+ ],
94
+ )
95
+ def test_empty_geometry_bounds(geom):
96
+ """The bounds of an empty geometry is a tuple of NaNs"""
97
+ assert len(geom.bounds) == 4
98
+ assert all(math.isnan(v) for v in geom.bounds)
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_equality.py ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pytest
3
+
4
+ import shapely
5
+ from shapely import LinearRing, LineString, MultiLineString, Point, Polygon
6
+ from shapely.tests.common import all_types, all_types_z, ignore_invalid
7
+
8
+
9
+ @pytest.mark.parametrize("geom", all_types + all_types_z)
10
+ def test_equality(geom):
11
+ assert geom == geom
12
+ transformed = shapely.transform(geom, lambda x: x, include_z=True)
13
+ assert geom == transformed
14
+ assert not (geom != transformed)
15
+
16
+
17
+ @pytest.mark.parametrize(
18
+ "left, right",
19
+ [
20
+ # (slightly) different coordinate values
21
+ (LineString([(0, 0), (1, 1)]), LineString([(0, 0), (1, 2)])),
22
+ (LineString([(0, 0), (1, 1)]), LineString([(0, 0), (1, 1 + 1e-12)])),
23
+ # different coordinate order
24
+ (LineString([(0, 0), (1, 1)]), LineString([(1, 1), (0, 0)])),
25
+ # different number of coordinates (but spatially equal)
26
+ (LineString([(0, 0), (1, 1)]), LineString([(0, 0), (1, 1), (1, 1)])),
27
+ (LineString([(0, 0), (1, 1)]), LineString([(0, 0), (0.5, 0.5), (1, 1)])),
28
+ # different order of sub-geometries
29
+ (
30
+ MultiLineString([[(1, 1), (2, 2)], [(2, 2), (3, 3)]]),
31
+ MultiLineString([[(2, 2), (3, 3)], [(1, 1), (2, 2)]]),
32
+ ),
33
+ ],
34
+ )
35
+ def test_equality_false(left, right):
36
+ assert left != right
37
+
38
+
39
+ with ignore_invalid():
40
+ cases1 = [
41
+ (LineString([(0, 1), (2, np.nan)]), LineString([(0, 1), (2, np.nan)])),
42
+ (
43
+ LineString([(0, 1), (np.nan, np.nan)]),
44
+ LineString([(0, 1), (np.nan, np.nan)]),
45
+ ),
46
+ (LineString([(np.nan, 1), (2, 3)]), LineString([(np.nan, 1), (2, 3)])),
47
+ (LineString([(0, np.nan), (2, 3)]), LineString([(0, np.nan), (2, 3)])),
48
+ (
49
+ LineString([(np.nan, np.nan), (np.nan, np.nan)]),
50
+ LineString([(np.nan, np.nan), (np.nan, np.nan)]),
51
+ ),
52
+ # NaN as explicit Z coordinate
53
+ # TODO: if first z is NaN -> considered as 2D -> tested below explicitly
54
+ # (
55
+ # LineString([(0, 1, np.nan), (2, 3, np.nan)]),
56
+ # LineString([(0, 1, np.nan), (2, 3, np.nan)]),
57
+ # ),
58
+ (
59
+ LineString([(0, 1, 2), (2, 3, np.nan)]),
60
+ LineString([(0, 1, 2), (2, 3, np.nan)]),
61
+ ),
62
+ # (
63
+ # LineString([(0, 1, np.nan), (2, 3, 4)]),
64
+ # LineString([(0, 1, np.nan), (2, 3, 4)]),
65
+ # ),
66
+ ]
67
+
68
+
69
+ @pytest.mark.parametrize("left, right", cases1)
70
+ def test_equality_with_nan(left, right):
71
+ # TODO currently those evaluate as not equal, but we are considering to change this
72
+ # assert left == right
73
+ assert not (left == right)
74
+ # assert not (left != right)
75
+ assert left != right
76
+
77
+
78
+ with ignore_invalid():
79
+ cases2 = [
80
+ (
81
+ LineString([(0, 1, np.nan), (2, 3, np.nan)]),
82
+ LineString([(0, 1, np.nan), (2, 3, np.nan)]),
83
+ ),
84
+ (
85
+ LineString([(0, 1, np.nan), (2, 3, 4)]),
86
+ LineString([(0, 1, np.nan), (2, 3, 4)]),
87
+ ),
88
+ ]
89
+
90
+
91
+ @pytest.mark.parametrize("left, right", cases2)
92
+ def test_equality_with_nan_z(left, right):
93
+ # TODO: those are currently considered equal because z dimension is ignored
94
+ if shapely.geos_version < (3, 12, 0):
95
+ assert left == right
96
+ assert not (left != right)
97
+ else:
98
+ # on GEOS main z dimension is not ignored -> NaNs cause inequality
99
+ assert left != right
100
+
101
+
102
+ with ignore_invalid():
103
+ cases3 = [
104
+ (LineString([(0, np.nan), (2, 3)]), LineString([(0, 1), (2, 3)])),
105
+ (LineString([(0, 1), (2, np.nan)]), LineString([(0, 1), (2, 3)])),
106
+ (LineString([(0, 1, np.nan), (2, 3, 4)]), LineString([(0, 1, 2), (2, 3, 4)])),
107
+ (LineString([(0, 1, 2), (2, 3, np.nan)]), LineString([(0, 1, 2), (2, 3, 4)])),
108
+ ]
109
+
110
+
111
+ @pytest.mark.parametrize("left, right", cases3)
112
+ def test_equality_with_nan_false(left, right):
113
+ assert left != right
114
+
115
+
116
+ def test_equality_with_nan_z_false():
117
+ with ignore_invalid():
118
+ left = LineString([(0, 1, np.nan), (2, 3, np.nan)])
119
+ right = LineString([(0, 1, np.nan), (2, 3, 4)])
120
+
121
+ if shapely.geos_version < (3, 10, 0):
122
+ # GEOS <= 3.9 fill the NaN with 0, so the z dimension is different
123
+ # assert left != right
124
+ # however, has_z still returns False, so z dimension is ignored in .coords
125
+ assert left == right
126
+ elif shapely.geos_version < (3, 12, 0):
127
+ # GEOS 3.10-3.11 ignore NaN for Z also when explicitly created with 3D
128
+ # and so the geometries are considered as 2D (and thus z dimension is ignored)
129
+ assert left == right
130
+ else:
131
+ assert left != right
132
+
133
+
134
+ def test_equality_z():
135
+ # different dimensionality
136
+ geom1 = Point(0, 1)
137
+ geom2 = Point(0, 1, 0)
138
+ assert geom1 != geom2
139
+
140
+ # different dimensionality with NaN z
141
+ geom2 = Point(0, 1, np.nan)
142
+ if shapely.geos_version < (3, 10, 0):
143
+ # GEOS < 3.8 fill the NaN with 0, so the z dimension is different
144
+ # assert geom1 != geom2
145
+ # however, has_z still returns False, so z dimension is ignored in .coords
146
+ assert geom1 == geom2
147
+ elif shapely.geos_version < (3, 12, 0):
148
+ # GEOS 3.10-3.11 ignore NaN for Z also when explicitly created with 3D
149
+ # and so the geometries are considered as 2D (and thus z dimension is ignored)
150
+ assert geom1 == geom2
151
+ else:
152
+ assert geom1 != geom2
153
+
154
+
155
+ def test_equality_exact_type():
156
+ # geometries with different type but same coord seq are not equal
157
+ geom1 = LineString([(0, 0), (1, 1), (0, 1), (0, 0)])
158
+ geom2 = LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)])
159
+ geom3 = Polygon([(0, 0), (1, 1), (0, 1), (0, 0)])
160
+ assert geom1 != geom2
161
+ assert geom1 != geom3
162
+ assert geom2 != geom3
163
+
164
+ # empty with different type
165
+ geom1 = shapely.from_wkt("POINT EMPTY")
166
+ geom2 = shapely.from_wkt("LINESTRING EMPTY")
167
+ assert geom1 != geom2
168
+
169
+
170
+ def test_equality_polygon():
171
+ # different exterior rings
172
+ geom1 = shapely.from_wkt("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))")
173
+ geom2 = shapely.from_wkt("POLYGON ((0 0, 10 0, 10 10, 0 15, 0 0))")
174
+ assert geom1 != geom2
175
+
176
+ # different number of holes
177
+ geom1 = shapely.from_wkt(
178
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 1))"
179
+ )
180
+ geom2 = shapely.from_wkt(
181
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 1), (3 3, 4 3, 4 4, 3 3))"
182
+ )
183
+ assert geom1 != geom2
184
+
185
+ # different order of holes
186
+ geom1 = shapely.from_wkt(
187
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (3 3, 4 3, 4 4, 3 3), (1 1, 2 1, 2 2, 1 1))"
188
+ )
189
+ geom2 = shapely.from_wkt(
190
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 1), (3 3, 4 3, 4 4, 3 3))"
191
+ )
192
+ assert geom1 != geom2
193
+
194
+
195
+ @pytest.mark.parametrize("geom", all_types)
196
+ def test_comparison_notimplemented(geom):
197
+ # comparing to a non-geometry class should return NotImplemented in __eq__
198
+ # to ensure proper delegation to other (eg to ensure comparison of scalar
199
+ # with array works)
200
+ # https://github.com/shapely/shapely/issues/1056
201
+ assert geom.__eq__(1) is NotImplemented
202
+
203
+ # with array
204
+ arr = np.array([geom, geom], dtype=object)
205
+
206
+ result = arr == geom
207
+ assert isinstance(result, np.ndarray)
208
+ assert result.all()
209
+
210
+ result = geom == arr
211
+ assert isinstance(result, np.ndarray)
212
+ assert result.all()
213
+
214
+ result = arr != geom
215
+ assert isinstance(result, np.ndarray)
216
+ assert not result.any()
217
+
218
+ result = geom != arr
219
+ assert isinstance(result, np.ndarray)
220
+ assert not result.any()
221
+
222
+
223
+ def test_comparison_not_supported():
224
+ geom1 = Point(1, 1)
225
+ geom2 = Point(2, 2)
226
+
227
+ with pytest.raises(TypeError, match="not supported between instances"):
228
+ geom1 > geom2
229
+
230
+ with pytest.raises(TypeError, match="not supported between instances"):
231
+ geom1 < geom2
232
+
233
+ with pytest.raises(TypeError, match="not supported between instances"):
234
+ geom1 >= geom2
235
+
236
+ with pytest.raises(TypeError, match="not supported between instances"):
237
+ geom1 <= geom2
vllm/lib/python3.10/site-packages/shapely/tests/geometry/test_geometry_base.py ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import platform
2
+ import weakref
3
+
4
+ import numpy as np
5
+ import pytest
6
+
7
+ import shapely
8
+ from shapely import (
9
+ GeometryCollection,
10
+ LinearRing,
11
+ LineString,
12
+ MultiLineString,
13
+ MultiPoint,
14
+ MultiPolygon,
15
+ Point,
16
+ Polygon,
17
+ )
18
+ from shapely.errors import ShapelyDeprecationWarning
19
+ from shapely.testing import assert_geometries_equal
20
+
21
+
22
+ def test_polygon():
23
+ assert bool(Polygon()) is False
24
+
25
+
26
+ def test_linestring():
27
+ assert bool(LineString()) is False
28
+
29
+
30
+ def test_point():
31
+ assert bool(Point()) is False
32
+
33
+
34
+ def test_geometry_collection():
35
+ assert bool(GeometryCollection()) is False
36
+
37
+
38
+ geometries_all_types = [
39
+ Point(1, 1),
40
+ LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]),
41
+ LineString([(0, 0), (1, 1), (0, 1), (0, 0)]),
42
+ Polygon([(0, 0), (1, 1), (0, 1), (0, 0)]),
43
+ MultiPoint([(1, 1)]),
44
+ MultiLineString([[(0, 0), (1, 1), (0, 1), (0, 0)]]),
45
+ MultiPolygon([Polygon([(0, 0), (1, 1), (0, 1), (0, 0)])]),
46
+ GeometryCollection([Point(1, 1)]),
47
+ ]
48
+
49
+
50
+ @pytest.mark.skipif(
51
+ platform.python_implementation() == "PyPy",
52
+ reason="Setting custom attributes doesn't fail on PyPy",
53
+ )
54
+ @pytest.mark.parametrize("geom", geometries_all_types)
55
+ def test_setattr_disallowed(geom):
56
+ with pytest.raises(AttributeError):
57
+ geom.name = "test"
58
+
59
+
60
+ @pytest.mark.parametrize("geom", geometries_all_types)
61
+ def test_weakrefable(geom):
62
+ _ = weakref.ref(geom)
63
+
64
+
65
+ def test_base_class_not_callable():
66
+ with pytest.raises(TypeError):
67
+ shapely.Geometry("POINT (1 1)")
68
+
69
+
70
+ def test_GeometryType_deprecated():
71
+ geom = Point(1, 1)
72
+
73
+ with pytest.warns(ShapelyDeprecationWarning):
74
+ geom_type = geom.geometryType()
75
+
76
+ assert geom_type == geom.geom_type
77
+
78
+
79
+ def test_type_deprecated():
80
+ geom = Point(1, 1)
81
+
82
+ with pytest.warns(ShapelyDeprecationWarning):
83
+ geom_type = geom.type
84
+
85
+ assert geom_type == geom.geom_type
86
+
87
+
88
+ @pytest.mark.skipif(shapely.geos_version < (3, 10, 0), reason="GEOS < 3.10")
89
+ def test_segmentize():
90
+ line = LineString([(0, 0), (0, 10)])
91
+ result = line.segmentize(max_segment_length=5)
92
+ assert result.equals(LineString([(0, 0), (0, 5), (0, 10)]))
93
+
94
+
95
+ @pytest.mark.skipif(shapely.geos_version < (3, 7, 0), reason="GEOS < 3.7")
96
+ def test_reverse():
97
+ coords = [(0, 0), (1, 2)]
98
+ line = LineString(coords)
99
+ result = line.reverse()
100
+ assert result.coords[:] == coords[::-1]
101
+
102
+
103
+ @pytest.mark.skipif(shapely.geos_version < (3, 9, 0), reason="GEOS < 3.9")
104
+ @pytest.mark.parametrize(
105
+ "op", ["union", "intersection", "difference", "symmetric_difference"]
106
+ )
107
+ @pytest.mark.parametrize("grid_size", [0, 1, 2])
108
+ def test_binary_op_grid_size(op, grid_size):
109
+ geom1 = shapely.box(0, 0, 2.5, 2.5)
110
+ geom2 = shapely.box(2, 2, 3, 3)
111
+
112
+ result = getattr(geom1, op)(geom2, grid_size=grid_size)
113
+ expected = getattr(shapely, op)(geom1, geom2, grid_size=grid_size)
114
+ assert result == expected
115
+
116
+
117
+ @pytest.mark.skipif(shapely.geos_version < (3, 10, 0), reason="GEOS < 3.10")
118
+ def test_dwithin():
119
+ point = Point(1, 1)
120
+ line = LineString([(0, 0), (0, 10)])
121
+ assert point.dwithin(line, 0.5) is False
122
+ assert point.dwithin(line, 1.5) is True
123
+
124
+
125
+ def test_contains_properly():
126
+ polygon = Polygon([(0, 0), (10, 10), (10, -10)])
127
+ line = LineString([(0, 0), (10, 0)])
128
+ assert polygon.contains_properly(line) is False
129
+ assert polygon.contains(line) is True
130
+
131
+
132
+ @pytest.mark.parametrize(
133
+ "op", ["convex_hull", "envelope", "oriented_envelope", "minimum_rotated_rectangle"]
134
+ )
135
+ def test_constructive_properties(op):
136
+ geom = LineString([(0, 0), (0, 10), (10, 10)])
137
+ result = getattr(geom, op)
138
+ expected = getattr(shapely, op)(geom)
139
+ assert result == expected
140
+
141
+
142
+ @pytest.mark.parametrize(
143
+ "op",
144
+ [
145
+ "crosses",
146
+ "contains",
147
+ "contains_properly",
148
+ "covered_by",
149
+ "covers",
150
+ "disjoint",
151
+ "equals",
152
+ "intersects",
153
+ "overlaps",
154
+ "touches",
155
+ "within",
156
+ ],
157
+ )
158
+ def test_array_argument_binary_predicates(op):
159
+ polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
160
+ points = shapely.points([(0, 0), (0.5, 0.5), (1, 1)])
161
+
162
+ result = getattr(polygon, op)(points)
163
+ assert isinstance(result, np.ndarray)
164
+ expected = np.array([getattr(polygon, op)(p) for p in points], dtype=bool)
165
+ np.testing.assert_array_equal(result, expected)
166
+
167
+ # check scalar
168
+ result = getattr(polygon, op)(points[0])
169
+ assert type(result) is bool
170
+
171
+
172
+ @pytest.mark.parametrize(
173
+ "op, kwargs",
174
+ [
175
+ pytest.param(
176
+ "dwithin",
177
+ dict(distance=0.5),
178
+ marks=pytest.mark.skipif(
179
+ shapely.geos_version < (3, 10, 0), reason="GEOS < 3.10"
180
+ ),
181
+ ),
182
+ ("equals_exact", dict(tolerance=0.01)),
183
+ ("relate_pattern", dict(pattern="T*F**F***")),
184
+ ],
185
+ )
186
+ def test_array_argument_binary_predicates2(op, kwargs):
187
+ polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
188
+ points = shapely.points([(0, 0), (0.5, 0.5), (1, 1)])
189
+
190
+ result = getattr(polygon, op)(points, **kwargs)
191
+ assert isinstance(result, np.ndarray)
192
+ expected = np.array([getattr(polygon, op)(p, **kwargs) for p in points], dtype=bool)
193
+ np.testing.assert_array_equal(result, expected)
194
+
195
+ # check scalar
196
+ result = getattr(polygon, op)(points[0], **kwargs)
197
+ assert type(result) is bool
198
+
199
+
200
+ @pytest.mark.parametrize(
201
+ "op",
202
+ [
203
+ "difference",
204
+ "intersection",
205
+ "symmetric_difference",
206
+ "union",
207
+ ],
208
+ )
209
+ def test_array_argument_binary_geo(op):
210
+ box = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
211
+ polygons = shapely.buffer(shapely.points([(0, 0), (0.5, 0.5), (1, 1)]), 0.5)
212
+
213
+ result = getattr(box, op)(polygons)
214
+ assert isinstance(result, np.ndarray)
215
+ expected = np.array([getattr(box, op)(g) for g in polygons], dtype=object)
216
+ assert_geometries_equal(result, expected)
217
+
218
+ # check scalar
219
+ result = getattr(box, op)(polygons[0])
220
+ assert isinstance(result, (Polygon, MultiPolygon))
221
+
222
+
223
+ @pytest.mark.parametrize("op", ["distance", "hausdorff_distance"])
224
+ def test_array_argument_float(op):
225
+ polygon = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
226
+ points = shapely.points([(0, 0), (0.5, 0.5), (1, 1)])
227
+
228
+ result = getattr(polygon, op)(points)
229
+ assert isinstance(result, np.ndarray)
230
+ expected = np.array([getattr(polygon, op)(p) for p in points], dtype="float64")
231
+ np.testing.assert_array_equal(result, expected)
232
+
233
+ # check scalar
234
+ result = getattr(polygon, op)(points[0])
235
+ assert type(result) is float
236
+
237
+
238
+ @pytest.mark.parametrize("op", ["line_interpolate_point", "interpolate"])
239
+ def test_array_argument_linear_point(op):
240
+ line = LineString([(0, 0), (0, 1), (1, 1)])
241
+ distances = np.array([0, 0.5, 1])
242
+
243
+ result = getattr(line, op)(distances)
244
+ assert isinstance(result, np.ndarray)
245
+ expected = np.array(
246
+ [line.line_interpolate_point(d) for d in distances], dtype=object
247
+ )
248
+ assert_geometries_equal(result, expected)
249
+
250
+ # check scalar
251
+ result = getattr(line, op)(distances[0])
252
+ assert isinstance(result, Point)
253
+
254
+
255
+ @pytest.mark.parametrize("op", ["line_locate_point", "project"])
256
+ def test_array_argument_linear_float(op):
257
+ line = LineString([(0, 0), (0, 1), (1, 1)])
258
+ points = shapely.points([(0, 0), (0.5, 0.5), (1, 1)])
259
+
260
+ result = getattr(line, op)(points)
261
+ assert isinstance(result, np.ndarray)
262
+ expected = np.array([line.line_locate_point(p) for p in points], dtype="float64")
263
+ np.testing.assert_array_equal(result, expected)
264
+
265
+ # check scalar
266
+ result = getattr(line, op)(points[0])
267
+ assert type(result) is float
268
+
269
+
270
+ def test_array_argument_buffer():
271
+ point = Point(1, 1)
272
+ distances = np.array([0, 0.5, 1])
273
+
274
+ result = point.buffer(distances)
275
+ assert isinstance(result, np.ndarray)
276
+ expected = np.array([point.buffer(d) for d in distances], dtype=object)
277
+ assert_geometries_equal(result, expected)
278
+
279
+ # check scalar
280
+ result = point.buffer(distances[0])
281
+ assert isinstance(result, Polygon)