ZTWHHH commited on
Commit
7004bef
·
verified ·
1 Parent(s): 074eb95

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. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/__init__.cpython-310.pyc +0 -0
  3. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack2.cpython-310.pyc +0 -0
  4. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack_impl.cpython-310.pyc +0 -0
  5. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack_py.cpython-310.pyc +0 -0
  6. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_interpolate.cpython-310.pyc +0 -0
  7. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_ndbspline.cpython-310.pyc +0 -0
  8. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_ndgriddata.cpython-310.pyc +0 -0
  9. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_pade.cpython-310.pyc +0 -0
  10. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_polyint.cpython-310.pyc +0 -0
  11. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_rbf.cpython-310.pyc +0 -0
  12. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_rbfinterp.cpython-310.pyc +0 -0
  13. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/fitpack.cpython-310.pyc +0 -0
  14. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/fitpack2.cpython-310.pyc +0 -0
  15. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/interpolate.cpython-310.pyc +0 -0
  16. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/ndgriddata.cpython-310.pyc +0 -0
  17. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/polyint.cpython-310.pyc +0 -0
  18. parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/rbf.cpython-310.pyc +0 -0
  19. parrot/lib/python3.10/site-packages/scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +3 -0
  20. parrot/lib/python3.10/site-packages/scipy/spatial/_geometric_slerp.py +240 -0
  21. parrot/lib/python3.10/site-packages/scipy/spatial/_kdtree.py +920 -0
  22. parrot/lib/python3.10/site-packages/scipy/spatial/_procrustes.py +132 -0
  23. parrot/lib/python3.10/site-packages/scipy/spatial/distance.pyi +211 -0
  24. parrot/lib/python3.10/site-packages/scipy/spatial/kdtree.py +25 -0
  25. parrot/lib/python3.10/site-packages/scipy/spatial/qhull.py +25 -0
  26. parrot/lib/python3.10/site-packages/scipy/spatial/tests/__init__.py +0 -0
  27. parrot/lib/python3.10/site-packages/scipy/spatial/tests/test__plotutils.py +91 -0
  28. parrot/lib/python3.10/site-packages/scipy/spatial/tests/test__procrustes.py +116 -0
  29. parrot/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc +3 -0
  30. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/INSTALLER +1 -0
  31. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/METADATA +151 -0
  32. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/RECORD +27 -0
  33. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/WHEEL +4 -0
  34. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/entry_points.txt +2 -0
  35. vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/licenses/LICENSE.txt +13 -0
  36. vllm/lib/python3.10/site-packages/markdown_it/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  37. vllm/lib/python3.10/site-packages/markdown_it/helpers/parse_link_title.py +60 -0
  38. vllm/lib/python3.10/site-packages/multipart/__init__.py +24 -0
  39. vllm/lib/python3.10/site-packages/multipart/__pycache__/decoders.cpython-310.pyc +0 -0
  40. vllm/lib/python3.10/site-packages/multipart/__pycache__/exceptions.cpython-310.pyc +0 -0
  41. vllm/lib/python3.10/site-packages/multipart/decoders.py +1 -0
  42. vllm/lib/python3.10/site-packages/multipart/exceptions.py +1 -0
  43. vllm/lib/python3.10/site-packages/multipart/multipart.py +1 -0
  44. vllm/lib/python3.10/site-packages/rsa/__pycache__/__init__.cpython-310.pyc +0 -0
  45. vllm/lib/python3.10/site-packages/rsa/__pycache__/asn1.cpython-310.pyc +0 -0
  46. vllm/lib/python3.10/site-packages/rsa/__pycache__/cli.cpython-310.pyc +0 -0
  47. vllm/lib/python3.10/site-packages/rsa/__pycache__/common.cpython-310.pyc +0 -0
  48. vllm/lib/python3.10/site-packages/rsa/__pycache__/core.cpython-310.pyc +0 -0
  49. vllm/lib/python3.10/site-packages/rsa/__pycache__/key.cpython-310.pyc +0 -0
  50. vllm/lib/python3.10/site-packages/rsa/__pycache__/parallel.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -1484,3 +1484,4 @@ parrot/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_distribut
1484
  parrot/lib/python3.10/site-packages/scipy/constants/__pycache__/_codata.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
1485
  vllm/lib/python3.10/site-packages/ray/_private/__pycache__/worker.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
1486
  parrot/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_morestats.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
 
 
1484
  parrot/lib/python3.10/site-packages/scipy/constants/__pycache__/_codata.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
1485
  vllm/lib/python3.10/site-packages/ray/_private/__pycache__/worker.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
1486
  parrot/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_morestats.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
1487
+ parrot/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (3.74 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack2.cpython-310.pyc ADDED
Binary file (82.6 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack_impl.cpython-310.pyc ADDED
Binary file (22.6 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_fitpack_py.cpython-310.pyc ADDED
Binary file (30.5 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_interpolate.cpython-310.pyc ADDED
Binary file (63.4 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_ndbspline.cpython-310.pyc ADDED
Binary file (11.2 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_ndgriddata.cpython-310.pyc ADDED
Binary file (9.66 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_pade.cpython-310.pyc ADDED
Binary file (2.07 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_polyint.cpython-310.pyc ADDED
Binary file (32.1 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_rbf.cpython-310.pyc ADDED
Binary file (11.1 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/_rbfinterp.cpython-310.pyc ADDED
Binary file (14.6 kB). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/fitpack.cpython-310.pyc ADDED
Binary file (696 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/fitpack2.cpython-310.pyc ADDED
Binary file (824 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/interpolate.cpython-310.pyc ADDED
Binary file (745 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/ndgriddata.cpython-310.pyc ADDED
Binary file (681 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/polyint.cpython-310.pyc ADDED
Binary file (708 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/interpolate/__pycache__/rbf.cpython-310.pyc ADDED
Binary file (578 Bytes). View file
 
parrot/lib/python3.10/site-packages/scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccc9e1bd9beb3f893239629529f6c19decafd37c6fce0a976211cdc6c0310c9e
3
+ size 13
parrot/lib/python3.10/site-packages/scipy/spatial/_geometric_slerp.py ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ __all__ = ['geometric_slerp']
4
+
5
+ import warnings
6
+ from typing import TYPE_CHECKING
7
+
8
+ import numpy as np
9
+ from scipy.spatial.distance import euclidean
10
+
11
+ if TYPE_CHECKING:
12
+ import numpy.typing as npt
13
+
14
+
15
+ def _geometric_slerp(start, end, t):
16
+ # create an orthogonal basis using QR decomposition
17
+ basis = np.vstack([start, end])
18
+ Q, R = np.linalg.qr(basis.T)
19
+ signs = 2 * (np.diag(R) >= 0) - 1
20
+ Q = Q.T * signs.T[:, np.newaxis]
21
+ R = R.T * signs.T[:, np.newaxis]
22
+
23
+ # calculate the angle between `start` and `end`
24
+ c = np.dot(start, end)
25
+ s = np.linalg.det(R)
26
+ omega = np.arctan2(s, c)
27
+
28
+ # interpolate
29
+ start, end = Q
30
+ s = np.sin(t * omega)
31
+ c = np.cos(t * omega)
32
+ return start * c[:, np.newaxis] + end * s[:, np.newaxis]
33
+
34
+
35
+ def geometric_slerp(
36
+ start: npt.ArrayLike,
37
+ end: npt.ArrayLike,
38
+ t: npt.ArrayLike,
39
+ tol: float = 1e-7,
40
+ ) -> np.ndarray:
41
+ """
42
+ Geometric spherical linear interpolation.
43
+
44
+ The interpolation occurs along a unit-radius
45
+ great circle arc in arbitrary dimensional space.
46
+
47
+ Parameters
48
+ ----------
49
+ start : (n_dimensions, ) array-like
50
+ Single n-dimensional input coordinate in a 1-D array-like
51
+ object. `n` must be greater than 1.
52
+ end : (n_dimensions, ) array-like
53
+ Single n-dimensional input coordinate in a 1-D array-like
54
+ object. `n` must be greater than 1.
55
+ t : float or (n_points,) 1D array-like
56
+ A float or 1D array-like of doubles representing interpolation
57
+ parameters, with values required in the inclusive interval
58
+ between 0 and 1. A common approach is to generate the array
59
+ with ``np.linspace(0, 1, n_pts)`` for linearly spaced points.
60
+ Ascending, descending, and scrambled orders are permitted.
61
+ tol : float
62
+ The absolute tolerance for determining if the start and end
63
+ coordinates are antipodes.
64
+
65
+ Returns
66
+ -------
67
+ result : (t.size, D)
68
+ An array of doubles containing the interpolated
69
+ spherical path and including start and
70
+ end when 0 and 1 t are used. The
71
+ interpolated values should correspond to the
72
+ same sort order provided in the t array. The result
73
+ may be 1-dimensional if ``t`` is a float.
74
+
75
+ Raises
76
+ ------
77
+ ValueError
78
+ If ``start`` and ``end`` are antipodes, not on the
79
+ unit n-sphere, or for a variety of degenerate conditions.
80
+
81
+ See Also
82
+ --------
83
+ scipy.spatial.transform.Slerp : 3-D Slerp that works with quaternions
84
+
85
+ Notes
86
+ -----
87
+ The implementation is based on the mathematical formula provided in [1]_,
88
+ and the first known presentation of this algorithm, derived from study of
89
+ 4-D geometry, is credited to Glenn Davis in a footnote of the original
90
+ quaternion Slerp publication by Ken Shoemake [2]_.
91
+
92
+ .. versionadded:: 1.5.0
93
+
94
+ References
95
+ ----------
96
+ .. [1] https://en.wikipedia.org/wiki/Slerp#Geometric_Slerp
97
+ .. [2] Ken Shoemake (1985) Animating rotation with quaternion curves.
98
+ ACM SIGGRAPH Computer Graphics, 19(3): 245-254.
99
+
100
+ Examples
101
+ --------
102
+ Interpolate four linearly-spaced values on the circumference of
103
+ a circle spanning 90 degrees:
104
+
105
+ >>> import numpy as np
106
+ >>> from scipy.spatial import geometric_slerp
107
+ >>> import matplotlib.pyplot as plt
108
+ >>> fig = plt.figure()
109
+ >>> ax = fig.add_subplot(111)
110
+ >>> start = np.array([1, 0])
111
+ >>> end = np.array([0, 1])
112
+ >>> t_vals = np.linspace(0, 1, 4)
113
+ >>> result = geometric_slerp(start,
114
+ ... end,
115
+ ... t_vals)
116
+
117
+ The interpolated results should be at 30 degree intervals
118
+ recognizable on the unit circle:
119
+
120
+ >>> ax.scatter(result[...,0], result[...,1], c='k')
121
+ >>> circle = plt.Circle((0, 0), 1, color='grey')
122
+ >>> ax.add_artist(circle)
123
+ >>> ax.set_aspect('equal')
124
+ >>> plt.show()
125
+
126
+ Attempting to interpolate between antipodes on a circle is
127
+ ambiguous because there are two possible paths, and on a
128
+ sphere there are infinite possible paths on the geodesic surface.
129
+ Nonetheless, one of the ambiguous paths is returned along
130
+ with a warning:
131
+
132
+ >>> opposite_pole = np.array([-1, 0])
133
+ >>> with np.testing.suppress_warnings() as sup:
134
+ ... sup.filter(UserWarning)
135
+ ... geometric_slerp(start,
136
+ ... opposite_pole,
137
+ ... t_vals)
138
+ array([[ 1.00000000e+00, 0.00000000e+00],
139
+ [ 5.00000000e-01, 8.66025404e-01],
140
+ [-5.00000000e-01, 8.66025404e-01],
141
+ [-1.00000000e+00, 1.22464680e-16]])
142
+
143
+ Extend the original example to a sphere and plot interpolation
144
+ points in 3D:
145
+
146
+ >>> from mpl_toolkits.mplot3d import proj3d
147
+ >>> fig = plt.figure()
148
+ >>> ax = fig.add_subplot(111, projection='3d')
149
+
150
+ Plot the unit sphere for reference (optional):
151
+
152
+ >>> u = np.linspace(0, 2 * np.pi, 100)
153
+ >>> v = np.linspace(0, np.pi, 100)
154
+ >>> x = np.outer(np.cos(u), np.sin(v))
155
+ >>> y = np.outer(np.sin(u), np.sin(v))
156
+ >>> z = np.outer(np.ones(np.size(u)), np.cos(v))
157
+ >>> ax.plot_surface(x, y, z, color='y', alpha=0.1)
158
+
159
+ Interpolating over a larger number of points
160
+ may provide the appearance of a smooth curve on
161
+ the surface of the sphere, which is also useful
162
+ for discretized integration calculations on a
163
+ sphere surface:
164
+
165
+ >>> start = np.array([1, 0, 0])
166
+ >>> end = np.array([0, 0, 1])
167
+ >>> t_vals = np.linspace(0, 1, 200)
168
+ >>> result = geometric_slerp(start,
169
+ ... end,
170
+ ... t_vals)
171
+ >>> ax.plot(result[...,0],
172
+ ... result[...,1],
173
+ ... result[...,2],
174
+ ... c='k')
175
+ >>> plt.show()
176
+ """
177
+
178
+ start = np.asarray(start, dtype=np.float64)
179
+ end = np.asarray(end, dtype=np.float64)
180
+ t = np.asarray(t)
181
+
182
+ if t.ndim > 1:
183
+ raise ValueError("The interpolation parameter "
184
+ "value must be one dimensional.")
185
+
186
+ if start.ndim != 1 or end.ndim != 1:
187
+ raise ValueError("Start and end coordinates "
188
+ "must be one-dimensional")
189
+
190
+ if start.size != end.size:
191
+ raise ValueError("The dimensions of start and "
192
+ "end must match (have same size)")
193
+
194
+ if start.size < 2 or end.size < 2:
195
+ raise ValueError("The start and end coordinates must "
196
+ "both be in at least two-dimensional "
197
+ "space")
198
+
199
+ if np.array_equal(start, end):
200
+ return np.linspace(start, start, t.size)
201
+
202
+ # for points that violate equation for n-sphere
203
+ for coord in [start, end]:
204
+ if not np.allclose(np.linalg.norm(coord), 1.0,
205
+ rtol=1e-9,
206
+ atol=0):
207
+ raise ValueError("start and end are not"
208
+ " on a unit n-sphere")
209
+
210
+ if not isinstance(tol, float):
211
+ raise ValueError("tol must be a float")
212
+ else:
213
+ tol = np.fabs(tol)
214
+
215
+ coord_dist = euclidean(start, end)
216
+
217
+ # diameter of 2 within tolerance means antipodes, which is a problem
218
+ # for all unit n-spheres (even the 0-sphere would have an ambiguous path)
219
+ if np.allclose(coord_dist, 2.0, rtol=0, atol=tol):
220
+ warnings.warn("start and end are antipodes "
221
+ "using the specified tolerance; "
222
+ "this may cause ambiguous slerp paths",
223
+ stacklevel=2)
224
+
225
+ t = np.asarray(t, dtype=np.float64)
226
+
227
+ if t.size == 0:
228
+ return np.empty((0, start.size))
229
+
230
+ if t.min() < 0 or t.max() > 1:
231
+ raise ValueError("interpolation parameter must be in [0, 1]")
232
+
233
+ if t.ndim == 0:
234
+ return _geometric_slerp(start,
235
+ end,
236
+ np.atleast_1d(t)).ravel()
237
+ else:
238
+ return _geometric_slerp(start,
239
+ end,
240
+ t)
parrot/lib/python3.10/site-packages/scipy/spatial/_kdtree.py ADDED
@@ -0,0 +1,920 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Anne M. Archibald 2008
2
+ # Released under the scipy license
3
+ import numpy as np
4
+ from ._ckdtree import cKDTree, cKDTreeNode
5
+
6
+ __all__ = ['minkowski_distance_p', 'minkowski_distance',
7
+ 'distance_matrix',
8
+ 'Rectangle', 'KDTree']
9
+
10
+
11
+ def minkowski_distance_p(x, y, p=2):
12
+ """Compute the pth power of the L**p distance between two arrays.
13
+
14
+ For efficiency, this function computes the L**p distance but does
15
+ not extract the pth root. If `p` is 1 or infinity, this is equal to
16
+ the actual L**p distance.
17
+
18
+ The last dimensions of `x` and `y` must be the same length. Any
19
+ other dimensions must be compatible for broadcasting.
20
+
21
+ Parameters
22
+ ----------
23
+ x : (..., K) array_like
24
+ Input array.
25
+ y : (..., K) array_like
26
+ Input array.
27
+ p : float, 1 <= p <= infinity
28
+ Which Minkowski p-norm to use.
29
+
30
+ Returns
31
+ -------
32
+ dist : ndarray
33
+ pth power of the distance between the input arrays.
34
+
35
+ Examples
36
+ --------
37
+ >>> from scipy.spatial import minkowski_distance_p
38
+ >>> minkowski_distance_p([[0, 0], [0, 0]], [[1, 1], [0, 1]])
39
+ array([2, 1])
40
+
41
+ """
42
+ x = np.asarray(x)
43
+ y = np.asarray(y)
44
+
45
+ # Find smallest common datatype with float64 (return type of this
46
+ # function) - addresses #10262.
47
+ # Don't just cast to float64 for complex input case.
48
+ common_datatype = np.promote_types(np.promote_types(x.dtype, y.dtype),
49
+ 'float64')
50
+
51
+ # Make sure x and y are NumPy arrays of correct datatype.
52
+ x = x.astype(common_datatype)
53
+ y = y.astype(common_datatype)
54
+
55
+ if p == np.inf:
56
+ return np.amax(np.abs(y-x), axis=-1)
57
+ elif p == 1:
58
+ return np.sum(np.abs(y-x), axis=-1)
59
+ else:
60
+ return np.sum(np.abs(y-x)**p, axis=-1)
61
+
62
+
63
+ def minkowski_distance(x, y, p=2):
64
+ """Compute the L**p distance between two arrays.
65
+
66
+ The last dimensions of `x` and `y` must be the same length. Any
67
+ other dimensions must be compatible for broadcasting.
68
+
69
+ Parameters
70
+ ----------
71
+ x : (..., K) array_like
72
+ Input array.
73
+ y : (..., K) array_like
74
+ Input array.
75
+ p : float, 1 <= p <= infinity
76
+ Which Minkowski p-norm to use.
77
+
78
+ Returns
79
+ -------
80
+ dist : ndarray
81
+ Distance between the input arrays.
82
+
83
+ Examples
84
+ --------
85
+ >>> from scipy.spatial import minkowski_distance
86
+ >>> minkowski_distance([[0, 0], [0, 0]], [[1, 1], [0, 1]])
87
+ array([ 1.41421356, 1. ])
88
+
89
+ """
90
+ x = np.asarray(x)
91
+ y = np.asarray(y)
92
+ if p == np.inf or p == 1:
93
+ return minkowski_distance_p(x, y, p)
94
+ else:
95
+ return minkowski_distance_p(x, y, p)**(1./p)
96
+
97
+
98
+ class Rectangle:
99
+ """Hyperrectangle class.
100
+
101
+ Represents a Cartesian product of intervals.
102
+ """
103
+ def __init__(self, maxes, mins):
104
+ """Construct a hyperrectangle."""
105
+ self.maxes = np.maximum(maxes,mins).astype(float)
106
+ self.mins = np.minimum(maxes,mins).astype(float)
107
+ self.m, = self.maxes.shape
108
+
109
+ def __repr__(self):
110
+ return "<Rectangle %s>" % list(zip(self.mins, self.maxes))
111
+
112
+ def volume(self):
113
+ """Total volume."""
114
+ return np.prod(self.maxes-self.mins)
115
+
116
+ def split(self, d, split):
117
+ """Produce two hyperrectangles by splitting.
118
+
119
+ In general, if you need to compute maximum and minimum
120
+ distances to the children, it can be done more efficiently
121
+ by updating the maximum and minimum distances to the parent.
122
+
123
+ Parameters
124
+ ----------
125
+ d : int
126
+ Axis to split hyperrectangle along.
127
+ split : float
128
+ Position along axis `d` to split at.
129
+
130
+ """
131
+ mid = np.copy(self.maxes)
132
+ mid[d] = split
133
+ less = Rectangle(self.mins, mid)
134
+ mid = np.copy(self.mins)
135
+ mid[d] = split
136
+ greater = Rectangle(mid, self.maxes)
137
+ return less, greater
138
+
139
+ def min_distance_point(self, x, p=2.):
140
+ """
141
+ Return the minimum distance between input and points in the
142
+ hyperrectangle.
143
+
144
+ Parameters
145
+ ----------
146
+ x : array_like
147
+ Input.
148
+ p : float, optional
149
+ Input.
150
+
151
+ """
152
+ return minkowski_distance(
153
+ 0, np.maximum(0, np.maximum(self.mins-x, x-self.maxes)),
154
+ p
155
+ )
156
+
157
+ def max_distance_point(self, x, p=2.):
158
+ """
159
+ Return the maximum distance between input and points in the hyperrectangle.
160
+
161
+ Parameters
162
+ ----------
163
+ x : array_like
164
+ Input array.
165
+ p : float, optional
166
+ Input.
167
+
168
+ """
169
+ return minkowski_distance(0, np.maximum(self.maxes-x, x-self.mins), p)
170
+
171
+ def min_distance_rectangle(self, other, p=2.):
172
+ """
173
+ Compute the minimum distance between points in the two hyperrectangles.
174
+
175
+ Parameters
176
+ ----------
177
+ other : hyperrectangle
178
+ Input.
179
+ p : float
180
+ Input.
181
+
182
+ """
183
+ return minkowski_distance(
184
+ 0,
185
+ np.maximum(0, np.maximum(self.mins-other.maxes,
186
+ other.mins-self.maxes)),
187
+ p
188
+ )
189
+
190
+ def max_distance_rectangle(self, other, p=2.):
191
+ """
192
+ Compute the maximum distance between points in the two hyperrectangles.
193
+
194
+ Parameters
195
+ ----------
196
+ other : hyperrectangle
197
+ Input.
198
+ p : float, optional
199
+ Input.
200
+
201
+ """
202
+ return minkowski_distance(
203
+ 0, np.maximum(self.maxes-other.mins, other.maxes-self.mins), p)
204
+
205
+
206
+ class KDTree(cKDTree):
207
+ """kd-tree for quick nearest-neighbor lookup.
208
+
209
+ This class provides an index into a set of k-dimensional points
210
+ which can be used to rapidly look up the nearest neighbors of any
211
+ point.
212
+
213
+ Parameters
214
+ ----------
215
+ data : array_like, shape (n,m)
216
+ The n data points of dimension m to be indexed. This array is
217
+ not copied unless this is necessary to produce a contiguous
218
+ array of doubles, and so modifying this data will result in
219
+ bogus results. The data are also copied if the kd-tree is built
220
+ with copy_data=True.
221
+ leafsize : positive int, optional
222
+ The number of points at which the algorithm switches over to
223
+ brute-force. Default: 10.
224
+ compact_nodes : bool, optional
225
+ If True, the kd-tree is built to shrink the hyperrectangles to
226
+ the actual data range. This usually gives a more compact tree that
227
+ is robust against degenerated input data and gives faster queries
228
+ at the expense of longer build time. Default: True.
229
+ copy_data : bool, optional
230
+ If True the data is always copied to protect the kd-tree against
231
+ data corruption. Default: False.
232
+ balanced_tree : bool, optional
233
+ If True, the median is used to split the hyperrectangles instead of
234
+ the midpoint. This usually gives a more compact tree and
235
+ faster queries at the expense of longer build time. Default: True.
236
+ boxsize : array_like or scalar, optional
237
+ Apply a m-d toroidal topology to the KDTree.. The topology is generated
238
+ by :math:`x_i + n_i L_i` where :math:`n_i` are integers and :math:`L_i`
239
+ is the boxsize along i-th dimension. The input data shall be wrapped
240
+ into :math:`[0, L_i)`. A ValueError is raised if any of the data is
241
+ outside of this bound.
242
+
243
+ Notes
244
+ -----
245
+ The algorithm used is described in Maneewongvatana and Mount 1999.
246
+ The general idea is that the kd-tree is a binary tree, each of whose
247
+ nodes represents an axis-aligned hyperrectangle. Each node specifies
248
+ an axis and splits the set of points based on whether their coordinate
249
+ along that axis is greater than or less than a particular value.
250
+
251
+ During construction, the axis and splitting point are chosen by the
252
+ "sliding midpoint" rule, which ensures that the cells do not all
253
+ become long and thin.
254
+
255
+ The tree can be queried for the r closest neighbors of any given point
256
+ (optionally returning only those within some maximum distance of the
257
+ point). It can also be queried, with a substantial gain in efficiency,
258
+ for the r approximate closest neighbors.
259
+
260
+ For large dimensions (20 is already large) do not expect this to run
261
+ significantly faster than brute force. High-dimensional nearest-neighbor
262
+ queries are a substantial open problem in computer science.
263
+
264
+ Attributes
265
+ ----------
266
+ data : ndarray, shape (n,m)
267
+ The n data points of dimension m to be indexed. This array is
268
+ not copied unless this is necessary to produce a contiguous
269
+ array of doubles. The data are also copied if the kd-tree is built
270
+ with `copy_data=True`.
271
+ leafsize : positive int
272
+ The number of points at which the algorithm switches over to
273
+ brute-force.
274
+ m : int
275
+ The dimension of a single data-point.
276
+ n : int
277
+ The number of data points.
278
+ maxes : ndarray, shape (m,)
279
+ The maximum value in each dimension of the n data points.
280
+ mins : ndarray, shape (m,)
281
+ The minimum value in each dimension of the n data points.
282
+ size : int
283
+ The number of nodes in the tree.
284
+
285
+ """
286
+
287
+ class node:
288
+ @staticmethod
289
+ def _create(ckdtree_node=None):
290
+ """Create either an inner or leaf node, wrapping a cKDTreeNode instance"""
291
+ if ckdtree_node is None:
292
+ return KDTree.node(ckdtree_node)
293
+ elif ckdtree_node.split_dim == -1:
294
+ return KDTree.leafnode(ckdtree_node)
295
+ else:
296
+ return KDTree.innernode(ckdtree_node)
297
+
298
+ def __init__(self, ckdtree_node=None):
299
+ if ckdtree_node is None:
300
+ ckdtree_node = cKDTreeNode()
301
+ self._node = ckdtree_node
302
+
303
+ def __lt__(self, other):
304
+ return id(self) < id(other)
305
+
306
+ def __gt__(self, other):
307
+ return id(self) > id(other)
308
+
309
+ def __le__(self, other):
310
+ return id(self) <= id(other)
311
+
312
+ def __ge__(self, other):
313
+ return id(self) >= id(other)
314
+
315
+ def __eq__(self, other):
316
+ return id(self) == id(other)
317
+
318
+ class leafnode(node):
319
+ @property
320
+ def idx(self):
321
+ return self._node.indices
322
+
323
+ @property
324
+ def children(self):
325
+ return self._node.children
326
+
327
+ class innernode(node):
328
+ def __init__(self, ckdtreenode):
329
+ assert isinstance(ckdtreenode, cKDTreeNode)
330
+ super().__init__(ckdtreenode)
331
+ self.less = KDTree.node._create(ckdtreenode.lesser)
332
+ self.greater = KDTree.node._create(ckdtreenode.greater)
333
+
334
+ @property
335
+ def split_dim(self):
336
+ return self._node.split_dim
337
+
338
+ @property
339
+ def split(self):
340
+ return self._node.split
341
+
342
+ @property
343
+ def children(self):
344
+ return self._node.children
345
+
346
+ @property
347
+ def tree(self):
348
+ if not hasattr(self, "_tree"):
349
+ self._tree = KDTree.node._create(super().tree)
350
+
351
+ return self._tree
352
+
353
+ def __init__(self, data, leafsize=10, compact_nodes=True, copy_data=False,
354
+ balanced_tree=True, boxsize=None):
355
+ data = np.asarray(data)
356
+ if data.dtype.kind == 'c':
357
+ raise TypeError("KDTree does not work with complex data")
358
+
359
+ # Note KDTree has different default leafsize from cKDTree
360
+ super().__init__(data, leafsize, compact_nodes, copy_data,
361
+ balanced_tree, boxsize)
362
+
363
+ def query(
364
+ self, x, k=1, eps=0, p=2, distance_upper_bound=np.inf, workers=1):
365
+ r"""Query the kd-tree for nearest neighbors.
366
+
367
+ Parameters
368
+ ----------
369
+ x : array_like, last dimension self.m
370
+ An array of points to query.
371
+ k : int or Sequence[int], optional
372
+ Either the number of nearest neighbors to return, or a list of the
373
+ k-th nearest neighbors to return, starting from 1.
374
+ eps : nonnegative float, optional
375
+ Return approximate nearest neighbors; the kth returned value
376
+ is guaranteed to be no further than (1+eps) times the
377
+ distance to the real kth nearest neighbor.
378
+ p : float, 1<=p<=infinity, optional
379
+ Which Minkowski p-norm to use.
380
+ 1 is the sum-of-absolute-values distance ("Manhattan" distance).
381
+ 2 is the usual Euclidean distance.
382
+ infinity is the maximum-coordinate-difference distance.
383
+ A large, finite p may cause a ValueError if overflow can occur.
384
+ distance_upper_bound : nonnegative float, optional
385
+ Return only neighbors within this distance. This is used to prune
386
+ tree searches, so if you are doing a series of nearest-neighbor
387
+ queries, it may help to supply the distance to the nearest neighbor
388
+ of the most recent point.
389
+ workers : int, optional
390
+ Number of workers to use for parallel processing. If -1 is given
391
+ all CPU threads are used. Default: 1.
392
+
393
+ .. versionadded:: 1.6.0
394
+
395
+ Returns
396
+ -------
397
+ d : float or array of floats
398
+ The distances to the nearest neighbors.
399
+ If ``x`` has shape ``tuple+(self.m,)``, then ``d`` has shape
400
+ ``tuple+(k,)``.
401
+ When k == 1, the last dimension of the output is squeezed.
402
+ Missing neighbors are indicated with infinite distances.
403
+ Hits are sorted by distance (nearest first).
404
+
405
+ .. versionchanged:: 1.9.0
406
+ Previously if ``k=None``, then `d` was an object array of
407
+ shape ``tuple``, containing lists of distances. This behavior
408
+ has been removed, use `query_ball_point` instead.
409
+
410
+ i : integer or array of integers
411
+ The index of each neighbor in ``self.data``.
412
+ ``i`` is the same shape as d.
413
+ Missing neighbors are indicated with ``self.n``.
414
+
415
+ Examples
416
+ --------
417
+
418
+ >>> import numpy as np
419
+ >>> from scipy.spatial import KDTree
420
+ >>> x, y = np.mgrid[0:5, 2:8]
421
+ >>> tree = KDTree(np.c_[x.ravel(), y.ravel()])
422
+
423
+ To query the nearest neighbours and return squeezed result, use
424
+
425
+ >>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=1)
426
+ >>> print(dd, ii, sep='\n')
427
+ [2. 0.2236068]
428
+ [ 0 13]
429
+
430
+ To query the nearest neighbours and return unsqueezed result, use
431
+
432
+ >>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[1])
433
+ >>> print(dd, ii, sep='\n')
434
+ [[2. ]
435
+ [0.2236068]]
436
+ [[ 0]
437
+ [13]]
438
+
439
+ To query the second nearest neighbours and return unsqueezed result,
440
+ use
441
+
442
+ >>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[2])
443
+ >>> print(dd, ii, sep='\n')
444
+ [[2.23606798]
445
+ [0.80622577]]
446
+ [[ 6]
447
+ [19]]
448
+
449
+ To query the first and second nearest neighbours, use
450
+
451
+ >>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=2)
452
+ >>> print(dd, ii, sep='\n')
453
+ [[2. 2.23606798]
454
+ [0.2236068 0.80622577]]
455
+ [[ 0 6]
456
+ [13 19]]
457
+
458
+ or, be more specific
459
+
460
+ >>> dd, ii = tree.query([[0, 0], [2.2, 2.9]], k=[1, 2])
461
+ >>> print(dd, ii, sep='\n')
462
+ [[2. 2.23606798]
463
+ [0.2236068 0.80622577]]
464
+ [[ 0 6]
465
+ [13 19]]
466
+
467
+ """
468
+ x = np.asarray(x)
469
+ if x.dtype.kind == 'c':
470
+ raise TypeError("KDTree does not work with complex data")
471
+
472
+ if k is None:
473
+ raise ValueError("k must be an integer or a sequence of integers")
474
+
475
+ d, i = super().query(x, k, eps, p, distance_upper_bound, workers)
476
+ if isinstance(i, int):
477
+ i = np.intp(i)
478
+ return d, i
479
+
480
+ def query_ball_point(self, x, r, p=2., eps=0, workers=1,
481
+ return_sorted=None, return_length=False):
482
+ """Find all points within distance r of point(s) x.
483
+
484
+ Parameters
485
+ ----------
486
+ x : array_like, shape tuple + (self.m,)
487
+ The point or points to search for neighbors of.
488
+ r : array_like, float
489
+ The radius of points to return, must broadcast to the length of x.
490
+ p : float, optional
491
+ Which Minkowski p-norm to use. Should be in the range [1, inf].
492
+ A finite large p may cause a ValueError if overflow can occur.
493
+ eps : nonnegative float, optional
494
+ Approximate search. Branches of the tree are not explored if their
495
+ nearest points are further than ``r / (1 + eps)``, and branches are
496
+ added in bulk if their furthest points are nearer than
497
+ ``r * (1 + eps)``.
498
+ workers : int, optional
499
+ Number of jobs to schedule for parallel processing. If -1 is given
500
+ all processors are used. Default: 1.
501
+
502
+ .. versionadded:: 1.6.0
503
+ return_sorted : bool, optional
504
+ Sorts returned indices if True and does not sort them if False. If
505
+ None, does not sort single point queries, but does sort
506
+ multi-point queries which was the behavior before this option
507
+ was added.
508
+
509
+ .. versionadded:: 1.6.0
510
+ return_length : bool, optional
511
+ Return the number of points inside the radius instead of a list
512
+ of the indices.
513
+
514
+ .. versionadded:: 1.6.0
515
+
516
+ Returns
517
+ -------
518
+ results : list or array of lists
519
+ If `x` is a single point, returns a list of the indices of the
520
+ neighbors of `x`. If `x` is an array of points, returns an object
521
+ array of shape tuple containing lists of neighbors.
522
+
523
+ Notes
524
+ -----
525
+ If you have many points whose neighbors you want to find, you may save
526
+ substantial amounts of time by putting them in a KDTree and using
527
+ query_ball_tree.
528
+
529
+ Examples
530
+ --------
531
+ >>> import numpy as np
532
+ >>> from scipy import spatial
533
+ >>> x, y = np.mgrid[0:5, 0:5]
534
+ >>> points = np.c_[x.ravel(), y.ravel()]
535
+ >>> tree = spatial.KDTree(points)
536
+ >>> sorted(tree.query_ball_point([2, 0], 1))
537
+ [5, 10, 11, 15]
538
+
539
+ Query multiple points and plot the results:
540
+
541
+ >>> import matplotlib.pyplot as plt
542
+ >>> points = np.asarray(points)
543
+ >>> plt.plot(points[:,0], points[:,1], '.')
544
+ >>> for results in tree.query_ball_point(([2, 0], [3, 3]), 1):
545
+ ... nearby_points = points[results]
546
+ ... plt.plot(nearby_points[:,0], nearby_points[:,1], 'o')
547
+ >>> plt.margins(0.1, 0.1)
548
+ >>> plt.show()
549
+
550
+ """
551
+ x = np.asarray(x)
552
+ if x.dtype.kind == 'c':
553
+ raise TypeError("KDTree does not work with complex data")
554
+ return super().query_ball_point(
555
+ x, r, p, eps, workers, return_sorted, return_length)
556
+
557
+ def query_ball_tree(self, other, r, p=2., eps=0):
558
+ """
559
+ Find all pairs of points between `self` and `other` whose distance is
560
+ at most r.
561
+
562
+ Parameters
563
+ ----------
564
+ other : KDTree instance
565
+ The tree containing points to search against.
566
+ r : float
567
+ The maximum distance, has to be positive.
568
+ p : float, optional
569
+ Which Minkowski norm to use. `p` has to meet the condition
570
+ ``1 <= p <= infinity``.
571
+ eps : float, optional
572
+ Approximate search. Branches of the tree are not explored
573
+ if their nearest points are further than ``r/(1+eps)``, and
574
+ branches are added in bulk if their furthest points are nearer
575
+ than ``r * (1+eps)``. `eps` has to be non-negative.
576
+
577
+ Returns
578
+ -------
579
+ results : list of lists
580
+ For each element ``self.data[i]`` of this tree, ``results[i]`` is a
581
+ list of the indices of its neighbors in ``other.data``.
582
+
583
+ Examples
584
+ --------
585
+ You can search all pairs of points between two kd-trees within a distance:
586
+
587
+ >>> import matplotlib.pyplot as plt
588
+ >>> import numpy as np
589
+ >>> from scipy.spatial import KDTree
590
+ >>> rng = np.random.default_rng()
591
+ >>> points1 = rng.random((15, 2))
592
+ >>> points2 = rng.random((15, 2))
593
+ >>> plt.figure(figsize=(6, 6))
594
+ >>> plt.plot(points1[:, 0], points1[:, 1], "xk", markersize=14)
595
+ >>> plt.plot(points2[:, 0], points2[:, 1], "og", markersize=14)
596
+ >>> kd_tree1 = KDTree(points1)
597
+ >>> kd_tree2 = KDTree(points2)
598
+ >>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
599
+ >>> for i in range(len(indexes)):
600
+ ... for j in indexes[i]:
601
+ ... plt.plot([points1[i, 0], points2[j, 0]],
602
+ ... [points1[i, 1], points2[j, 1]], "-r")
603
+ >>> plt.show()
604
+
605
+ """
606
+ return super().query_ball_tree(other, r, p, eps)
607
+
608
+ def query_pairs(self, r, p=2., eps=0, output_type='set'):
609
+ """Find all pairs of points in `self` whose distance is at most r.
610
+
611
+ Parameters
612
+ ----------
613
+ r : positive float
614
+ The maximum distance.
615
+ p : float, optional
616
+ Which Minkowski norm to use. `p` has to meet the condition
617
+ ``1 <= p <= infinity``.
618
+ eps : float, optional
619
+ Approximate search. Branches of the tree are not explored
620
+ if their nearest points are further than ``r/(1+eps)``, and
621
+ branches are added in bulk if their furthest points are nearer
622
+ than ``r * (1+eps)``. `eps` has to be non-negative.
623
+ output_type : string, optional
624
+ Choose the output container, 'set' or 'ndarray'. Default: 'set'
625
+
626
+ .. versionadded:: 1.6.0
627
+
628
+ Returns
629
+ -------
630
+ results : set or ndarray
631
+ Set of pairs ``(i,j)``, with ``i < j``, for which the corresponding
632
+ positions are close. If output_type is 'ndarray', an ndarry is
633
+ returned instead of a set.
634
+
635
+ Examples
636
+ --------
637
+ You can search all pairs of points in a kd-tree within a distance:
638
+
639
+ >>> import matplotlib.pyplot as plt
640
+ >>> import numpy as np
641
+ >>> from scipy.spatial import KDTree
642
+ >>> rng = np.random.default_rng()
643
+ >>> points = rng.random((20, 2))
644
+ >>> plt.figure(figsize=(6, 6))
645
+ >>> plt.plot(points[:, 0], points[:, 1], "xk", markersize=14)
646
+ >>> kd_tree = KDTree(points)
647
+ >>> pairs = kd_tree.query_pairs(r=0.2)
648
+ >>> for (i, j) in pairs:
649
+ ... plt.plot([points[i, 0], points[j, 0]],
650
+ ... [points[i, 1], points[j, 1]], "-r")
651
+ >>> plt.show()
652
+
653
+ """
654
+ return super().query_pairs(r, p, eps, output_type)
655
+
656
+ def count_neighbors(self, other, r, p=2., weights=None, cumulative=True):
657
+ """Count how many nearby pairs can be formed.
658
+
659
+ Count the number of pairs ``(x1,x2)`` can be formed, with ``x1`` drawn
660
+ from ``self`` and ``x2`` drawn from ``other``, and where
661
+ ``distance(x1, x2, p) <= r``.
662
+
663
+ Data points on ``self`` and ``other`` are optionally weighted by the
664
+ ``weights`` argument. (See below)
665
+
666
+ This is adapted from the "two-point correlation" algorithm described by
667
+ Gray and Moore [1]_. See notes for further discussion.
668
+
669
+ Parameters
670
+ ----------
671
+ other : KDTree
672
+ The other tree to draw points from, can be the same tree as self.
673
+ r : float or one-dimensional array of floats
674
+ The radius to produce a count for. Multiple radii are searched with
675
+ a single tree traversal.
676
+ If the count is non-cumulative(``cumulative=False``), ``r`` defines
677
+ the edges of the bins, and must be non-decreasing.
678
+ p : float, optional
679
+ 1<=p<=infinity.
680
+ Which Minkowski p-norm to use.
681
+ Default 2.0.
682
+ A finite large p may cause a ValueError if overflow can occur.
683
+ weights : tuple, array_like, or None, optional
684
+ If None, the pair-counting is unweighted.
685
+ If given as a tuple, weights[0] is the weights of points in
686
+ ``self``, and weights[1] is the weights of points in ``other``;
687
+ either can be None to indicate the points are unweighted.
688
+ If given as an array_like, weights is the weights of points in
689
+ ``self`` and ``other``. For this to make sense, ``self`` and
690
+ ``other`` must be the same tree. If ``self`` and ``other`` are two
691
+ different trees, a ``ValueError`` is raised.
692
+ Default: None
693
+
694
+ .. versionadded:: 1.6.0
695
+ cumulative : bool, optional
696
+ Whether the returned counts are cumulative. When cumulative is set
697
+ to ``False`` the algorithm is optimized to work with a large number
698
+ of bins (>10) specified by ``r``. When ``cumulative`` is set to
699
+ True, the algorithm is optimized to work with a small number of
700
+ ``r``. Default: True
701
+
702
+ .. versionadded:: 1.6.0
703
+
704
+ Returns
705
+ -------
706
+ result : scalar or 1-D array
707
+ The number of pairs. For unweighted counts, the result is integer.
708
+ For weighted counts, the result is float.
709
+ If cumulative is False, ``result[i]`` contains the counts with
710
+ ``(-inf if i == 0 else r[i-1]) < R <= r[i]``
711
+
712
+ Notes
713
+ -----
714
+ Pair-counting is the basic operation used to calculate the two point
715
+ correlation functions from a data set composed of position of objects.
716
+
717
+ Two point correlation function measures the clustering of objects and
718
+ is widely used in cosmology to quantify the large scale structure
719
+ in our Universe, but it may be useful for data analysis in other fields
720
+ where self-similar assembly of objects also occur.
721
+
722
+ The Landy-Szalay estimator for the two point correlation function of
723
+ ``D`` measures the clustering signal in ``D``. [2]_
724
+
725
+ For example, given the position of two sets of objects,
726
+
727
+ - objects ``D`` (data) contains the clustering signal, and
728
+
729
+ - objects ``R`` (random) that contains no signal,
730
+
731
+ .. math::
732
+
733
+ \\xi(r) = \\frac{<D, D> - 2 f <D, R> + f^2<R, R>}{f^2<R, R>},
734
+
735
+ where the brackets represents counting pairs between two data sets
736
+ in a finite bin around ``r`` (distance), corresponding to setting
737
+ `cumulative=False`, and ``f = float(len(D)) / float(len(R))`` is the
738
+ ratio between number of objects from data and random.
739
+
740
+ The algorithm implemented here is loosely based on the dual-tree
741
+ algorithm described in [1]_. We switch between two different
742
+ pair-cumulation scheme depending on the setting of ``cumulative``.
743
+ The computing time of the method we use when for
744
+ ``cumulative == False`` does not scale with the total number of bins.
745
+ The algorithm for ``cumulative == True`` scales linearly with the
746
+ number of bins, though it is slightly faster when only
747
+ 1 or 2 bins are used. [5]_.
748
+
749
+ As an extension to the naive pair-counting,
750
+ weighted pair-counting counts the product of weights instead
751
+ of number of pairs.
752
+ Weighted pair-counting is used to estimate marked correlation functions
753
+ ([3]_, section 2.2),
754
+ or to properly calculate the average of data per distance bin
755
+ (e.g. [4]_, section 2.1 on redshift).
756
+
757
+ .. [1] Gray and Moore,
758
+ "N-body problems in statistical learning",
759
+ Mining the sky, 2000,
760
+ https://arxiv.org/abs/astro-ph/0012333
761
+
762
+ .. [2] Landy and Szalay,
763
+ "Bias and variance of angular correlation functions",
764
+ The Astrophysical Journal, 1993,
765
+ http://adsabs.harvard.edu/abs/1993ApJ...412...64L
766
+
767
+ .. [3] Sheth, Connolly and Skibba,
768
+ "Marked correlations in galaxy formation models",
769
+ Arxiv e-print, 2005,
770
+ https://arxiv.org/abs/astro-ph/0511773
771
+
772
+ .. [4] Hawkins, et al.,
773
+ "The 2dF Galaxy Redshift Survey: correlation functions,
774
+ peculiar velocities and the matter density of the Universe",
775
+ Monthly Notices of the Royal Astronomical Society, 2002,
776
+ http://adsabs.harvard.edu/abs/2003MNRAS.346...78H
777
+
778
+ .. [5] https://github.com/scipy/scipy/pull/5647#issuecomment-168474926
779
+
780
+ Examples
781
+ --------
782
+ You can count neighbors number between two kd-trees within a distance:
783
+
784
+ >>> import numpy as np
785
+ >>> from scipy.spatial import KDTree
786
+ >>> rng = np.random.default_rng()
787
+ >>> points1 = rng.random((5, 2))
788
+ >>> points2 = rng.random((5, 2))
789
+ >>> kd_tree1 = KDTree(points1)
790
+ >>> kd_tree2 = KDTree(points2)
791
+ >>> kd_tree1.count_neighbors(kd_tree2, 0.2)
792
+ 1
793
+
794
+ This number is same as the total pair number calculated by
795
+ `query_ball_tree`:
796
+
797
+ >>> indexes = kd_tree1.query_ball_tree(kd_tree2, r=0.2)
798
+ >>> sum([len(i) for i in indexes])
799
+ 1
800
+
801
+ """
802
+ return super().count_neighbors(other, r, p, weights, cumulative)
803
+
804
+ def sparse_distance_matrix(
805
+ self, other, max_distance, p=2., output_type='dok_matrix'):
806
+ """Compute a sparse distance matrix.
807
+
808
+ Computes a distance matrix between two KDTrees, leaving as zero
809
+ any distance greater than max_distance.
810
+
811
+ Parameters
812
+ ----------
813
+ other : KDTree
814
+
815
+ max_distance : positive float
816
+
817
+ p : float, 1<=p<=infinity
818
+ Which Minkowski p-norm to use.
819
+ A finite large p may cause a ValueError if overflow can occur.
820
+
821
+ output_type : string, optional
822
+ Which container to use for output data. Options: 'dok_matrix',
823
+ 'coo_matrix', 'dict', or 'ndarray'. Default: 'dok_matrix'.
824
+
825
+ .. versionadded:: 1.6.0
826
+
827
+ Returns
828
+ -------
829
+ result : dok_matrix, coo_matrix, dict or ndarray
830
+ Sparse matrix representing the results in "dictionary of keys"
831
+ format. If a dict is returned the keys are (i,j) tuples of indices.
832
+ If output_type is 'ndarray' a record array with fields 'i', 'j',
833
+ and 'v' is returned,
834
+
835
+ Examples
836
+ --------
837
+ You can compute a sparse distance matrix between two kd-trees:
838
+
839
+ >>> import numpy as np
840
+ >>> from scipy.spatial import KDTree
841
+ >>> rng = np.random.default_rng()
842
+ >>> points1 = rng.random((5, 2))
843
+ >>> points2 = rng.random((5, 2))
844
+ >>> kd_tree1 = KDTree(points1)
845
+ >>> kd_tree2 = KDTree(points2)
846
+ >>> sdm = kd_tree1.sparse_distance_matrix(kd_tree2, 0.3)
847
+ >>> sdm.toarray()
848
+ array([[0. , 0. , 0.12295571, 0. , 0. ],
849
+ [0. , 0. , 0. , 0. , 0. ],
850
+ [0.28942611, 0. , 0. , 0.2333084 , 0. ],
851
+ [0. , 0. , 0. , 0. , 0. ],
852
+ [0.24617575, 0.29571802, 0.26836782, 0. , 0. ]])
853
+
854
+ You can check distances above the `max_distance` are zeros:
855
+
856
+ >>> from scipy.spatial import distance_matrix
857
+ >>> distance_matrix(points1, points2)
858
+ array([[0.56906522, 0.39923701, 0.12295571, 0.8658745 , 0.79428925],
859
+ [0.37327919, 0.7225693 , 0.87665969, 0.32580855, 0.75679479],
860
+ [0.28942611, 0.30088013, 0.6395831 , 0.2333084 , 0.33630734],
861
+ [0.31994999, 0.72658602, 0.71124834, 0.55396483, 0.90785663],
862
+ [0.24617575, 0.29571802, 0.26836782, 0.57714465, 0.6473269 ]])
863
+
864
+ """
865
+ return super().sparse_distance_matrix(
866
+ other, max_distance, p, output_type)
867
+
868
+
869
+ def distance_matrix(x, y, p=2, threshold=1000000):
870
+ """Compute the distance matrix.
871
+
872
+ Returns the matrix of all pair-wise distances.
873
+
874
+ Parameters
875
+ ----------
876
+ x : (M, K) array_like
877
+ Matrix of M vectors in K dimensions.
878
+ y : (N, K) array_like
879
+ Matrix of N vectors in K dimensions.
880
+ p : float, 1 <= p <= infinity
881
+ Which Minkowski p-norm to use.
882
+ threshold : positive int
883
+ If ``M * N * K`` > `threshold`, algorithm uses a Python loop instead
884
+ of large temporary arrays.
885
+
886
+ Returns
887
+ -------
888
+ result : (M, N) ndarray
889
+ Matrix containing the distance from every vector in `x` to every vector
890
+ in `y`.
891
+
892
+ Examples
893
+ --------
894
+ >>> from scipy.spatial import distance_matrix
895
+ >>> distance_matrix([[0,0],[0,1]], [[1,0],[1,1]])
896
+ array([[ 1. , 1.41421356],
897
+ [ 1.41421356, 1. ]])
898
+
899
+ """
900
+
901
+ x = np.asarray(x)
902
+ m, k = x.shape
903
+ y = np.asarray(y)
904
+ n, kk = y.shape
905
+
906
+ if k != kk:
907
+ raise ValueError(f"x contains {k}-dimensional vectors but y contains "
908
+ f"{kk}-dimensional vectors")
909
+
910
+ if m*n*k <= threshold:
911
+ return minkowski_distance(x[:,np.newaxis,:],y[np.newaxis,:,:],p)
912
+ else:
913
+ result = np.empty((m,n),dtype=float) # FIXME: figure out the best dtype
914
+ if m < n:
915
+ for i in range(m):
916
+ result[i,:] = minkowski_distance(x[i],y,p)
917
+ else:
918
+ for j in range(n):
919
+ result[:,j] = minkowski_distance(x,y[j],p)
920
+ return result
parrot/lib/python3.10/site-packages/scipy/spatial/_procrustes.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This module provides functions to perform full Procrustes analysis.
3
+
4
+ This code was originally written by Justin Kucynski and ported over from
5
+ scikit-bio by Yoshiki Vazquez-Baeza.
6
+ """
7
+
8
+ import numpy as np
9
+ from scipy.linalg import orthogonal_procrustes
10
+
11
+
12
+ __all__ = ['procrustes']
13
+
14
+
15
+ def procrustes(data1, data2):
16
+ r"""Procrustes analysis, a similarity test for two data sets.
17
+
18
+ Each input matrix is a set of points or vectors (the rows of the matrix).
19
+ The dimension of the space is the number of columns of each matrix. Given
20
+ two identically sized matrices, procrustes standardizes both such that:
21
+
22
+ - :math:`tr(AA^{T}) = 1`.
23
+
24
+ - Both sets of points are centered around the origin.
25
+
26
+ Procrustes ([1]_, [2]_) then applies the optimal transform to the second
27
+ matrix (including scaling/dilation, rotations, and reflections) to minimize
28
+ :math:`M^{2}=\sum(data1-data2)^{2}`, or the sum of the squares of the
29
+ pointwise differences between the two input datasets.
30
+
31
+ This function was not designed to handle datasets with different numbers of
32
+ datapoints (rows). If two data sets have different dimensionality
33
+ (different number of columns), simply add columns of zeros to the smaller
34
+ of the two.
35
+
36
+ Parameters
37
+ ----------
38
+ data1 : array_like
39
+ Matrix, n rows represent points in k (columns) space `data1` is the
40
+ reference data, after it is standardised, the data from `data2` will be
41
+ transformed to fit the pattern in `data1` (must have >1 unique points).
42
+ data2 : array_like
43
+ n rows of data in k space to be fit to `data1`. Must be the same
44
+ shape ``(numrows, numcols)`` as data1 (must have >1 unique points).
45
+
46
+ Returns
47
+ -------
48
+ mtx1 : array_like
49
+ A standardized version of `data1`.
50
+ mtx2 : array_like
51
+ The orientation of `data2` that best fits `data1`. Centered, but not
52
+ necessarily :math:`tr(AA^{T}) = 1`.
53
+ disparity : float
54
+ :math:`M^{2}` as defined above.
55
+
56
+ Raises
57
+ ------
58
+ ValueError
59
+ If the input arrays are not two-dimensional.
60
+ If the shape of the input arrays is different.
61
+ If the input arrays have zero columns or zero rows.
62
+
63
+ See Also
64
+ --------
65
+ scipy.linalg.orthogonal_procrustes
66
+ scipy.spatial.distance.directed_hausdorff : Another similarity test
67
+ for two data sets
68
+
69
+ Notes
70
+ -----
71
+ - The disparity should not depend on the order of the input matrices, but
72
+ the output matrices will, as only the first output matrix is guaranteed
73
+ to be scaled such that :math:`tr(AA^{T}) = 1`.
74
+
75
+ - Duplicate data points are generally ok, duplicating a data point will
76
+ increase its effect on the procrustes fit.
77
+
78
+ - The disparity scales as the number of points per input matrix.
79
+
80
+ References
81
+ ----------
82
+ .. [1] Krzanowski, W. J. (2000). "Principles of Multivariate analysis".
83
+ .. [2] Gower, J. C. (1975). "Generalized procrustes analysis".
84
+
85
+ Examples
86
+ --------
87
+ >>> import numpy as np
88
+ >>> from scipy.spatial import procrustes
89
+
90
+ The matrix ``b`` is a rotated, shifted, scaled and mirrored version of
91
+ ``a`` here:
92
+
93
+ >>> a = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd')
94
+ >>> b = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd')
95
+ >>> mtx1, mtx2, disparity = procrustes(a, b)
96
+ >>> round(disparity)
97
+ 0.0
98
+
99
+ """
100
+ mtx1 = np.array(data1, dtype=np.float64, copy=True)
101
+ mtx2 = np.array(data2, dtype=np.float64, copy=True)
102
+
103
+ if mtx1.ndim != 2 or mtx2.ndim != 2:
104
+ raise ValueError("Input matrices must be two-dimensional")
105
+ if mtx1.shape != mtx2.shape:
106
+ raise ValueError("Input matrices must be of same shape")
107
+ if mtx1.size == 0:
108
+ raise ValueError("Input matrices must be >0 rows and >0 cols")
109
+
110
+ # translate all the data to the origin
111
+ mtx1 -= np.mean(mtx1, 0)
112
+ mtx2 -= np.mean(mtx2, 0)
113
+
114
+ norm1 = np.linalg.norm(mtx1)
115
+ norm2 = np.linalg.norm(mtx2)
116
+
117
+ if norm1 == 0 or norm2 == 0:
118
+ raise ValueError("Input matrices must contain >1 unique points")
119
+
120
+ # change scaling of data (in rows) such that trace(mtx*mtx') = 1
121
+ mtx1 /= norm1
122
+ mtx2 /= norm2
123
+
124
+ # transform mtx2 to minimize disparity
125
+ R, s = orthogonal_procrustes(mtx1, mtx2)
126
+ mtx2 = np.dot(mtx2, R.T) * s
127
+
128
+ # measure the dissimilarity between the two datasets
129
+ disparity = np.sum(np.square(mtx1 - mtx2))
130
+
131
+ return mtx1, mtx2, disparity
132
+
parrot/lib/python3.10/site-packages/scipy/spatial/distance.pyi ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+ from typing import (overload, Any, SupportsFloat, Literal, Protocol, SupportsIndex)
3
+
4
+ import numpy as np
5
+ from numpy.typing import ArrayLike, NDArray
6
+
7
+ # Anything that can be parsed by `np.float64.__init__` and is thus
8
+ # compatible with `ndarray.__setitem__` (for a float64 array)
9
+ _FloatValue = None | str | bytes | SupportsFloat | SupportsIndex
10
+
11
+ class _MetricCallback1(Protocol):
12
+ def __call__(
13
+ self, __XA: NDArray[Any], __XB: NDArray[Any]
14
+ ) -> _FloatValue: ...
15
+
16
+ class _MetricCallback2(Protocol):
17
+ def __call__(
18
+ self, __XA: NDArray[Any], __XB: NDArray[Any], **kwargs: Any
19
+ ) -> _FloatValue: ...
20
+
21
+ # TODO: Use a single protocol with a parameter specification variable
22
+ # once available (PEP 612)
23
+ _MetricCallback = _MetricCallback1 | _MetricCallback2
24
+
25
+ _MetricKind = Literal[
26
+ 'braycurtis',
27
+ 'canberra',
28
+ 'chebychev', 'chebyshev', 'cheby', 'cheb', 'ch',
29
+ 'cityblock', 'cblock', 'cb', 'c',
30
+ 'correlation', 'co',
31
+ 'cosine', 'cos',
32
+ 'dice',
33
+ 'euclidean', 'euclid', 'eu', 'e',
34
+ 'hamming', 'hamm', 'ha', 'h',
35
+ 'minkowski', 'mi', 'm', 'pnorm',
36
+ 'jaccard', 'jacc', 'ja', 'j',
37
+ 'jensenshannon', 'js',
38
+ 'kulczynski1',
39
+ 'mahalanobis', 'mahal', 'mah',
40
+ 'rogerstanimoto',
41
+ 'russellrao',
42
+ 'seuclidean', 'se', 's',
43
+ 'sokalmichener',
44
+ 'sokalsneath',
45
+ 'sqeuclidean', 'sqe', 'sqeuclid',
46
+ 'yule',
47
+ ]
48
+
49
+ # Function annotations
50
+
51
+ def braycurtis(
52
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
53
+ ) -> np.float64: ...
54
+
55
+ def canberra(
56
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
57
+ ) -> np.float64: ...
58
+
59
+ # TODO: Add `metric`-specific overloads
60
+ # Returns a float64 or float128 array, depending on the input dtype
61
+ @overload
62
+ def cdist(
63
+ XA: ArrayLike,
64
+ XB: ArrayLike,
65
+ metric: _MetricKind = ...,
66
+ *,
67
+ out: None | NDArray[np.floating[Any]] = ...,
68
+ p: float = ...,
69
+ w: ArrayLike | None = ...,
70
+ V: ArrayLike | None = ...,
71
+ VI: ArrayLike | None = ...,
72
+ ) -> NDArray[np.floating[Any]]: ...
73
+ @overload
74
+ def cdist(
75
+ XA: ArrayLike,
76
+ XB: ArrayLike,
77
+ metric: _MetricCallback,
78
+ *,
79
+ out: None | NDArray[np.floating[Any]] = ...,
80
+ **kwargs: Any,
81
+ ) -> NDArray[np.floating[Any]]: ...
82
+
83
+ # TODO: Wait for dtype support; the return type is
84
+ # dependent on the input arrays dtype
85
+ def chebyshev(
86
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
87
+ ) -> Any: ...
88
+
89
+ # TODO: Wait for dtype support; the return type is
90
+ # dependent on the input arrays dtype
91
+ def cityblock(
92
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
93
+ ) -> Any: ...
94
+
95
+ def correlation(
96
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ..., centered: bool = ...
97
+ ) -> np.float64: ...
98
+
99
+ def cosine(
100
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
101
+ ) -> np.float64: ...
102
+
103
+ def dice(
104
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
105
+ ) -> float: ...
106
+
107
+ def directed_hausdorff(
108
+ u: ArrayLike, v: ArrayLike, seed: int | None = ...
109
+ ) -> tuple[float, int, int]: ...
110
+
111
+ def euclidean(
112
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
113
+ ) -> float: ...
114
+
115
+ def hamming(
116
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
117
+ ) -> np.float64: ...
118
+
119
+ def is_valid_dm(
120
+ D: ArrayLike,
121
+ tol: float = ...,
122
+ throw: bool = ...,
123
+ name: str | None = ...,
124
+ warning: bool = ...,
125
+ ) -> bool: ...
126
+
127
+ def is_valid_y(
128
+ y: ArrayLike,
129
+ warning: bool = ...,
130
+ throw: bool = ...,
131
+ name: str | None = ...,
132
+ ) -> bool: ...
133
+
134
+ def jaccard(
135
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
136
+ ) -> np.float64: ...
137
+
138
+ def jensenshannon(
139
+ p: ArrayLike, q: ArrayLike, base: float | None = ...
140
+ ) -> np.float64: ...
141
+
142
+ def kulczynski1(
143
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
144
+ ) -> np.float64: ...
145
+
146
+ def mahalanobis(
147
+ u: ArrayLike, v: ArrayLike, VI: ArrayLike
148
+ ) -> np.float64: ...
149
+
150
+ def minkowski(
151
+ u: ArrayLike, v: ArrayLike, p: float = ..., w: ArrayLike | None = ...
152
+ ) -> float: ...
153
+
154
+ def num_obs_dm(d: ArrayLike) -> int: ...
155
+
156
+ def num_obs_y(Y: ArrayLike) -> int: ...
157
+
158
+ # TODO: Add `metric`-specific overloads
159
+ @overload
160
+ def pdist(
161
+ X: ArrayLike,
162
+ metric: _MetricKind = ...,
163
+ *,
164
+ out: None | NDArray[np.floating[Any]] = ...,
165
+ p: float = ...,
166
+ w: ArrayLike | None = ...,
167
+ V: ArrayLike | None = ...,
168
+ VI: ArrayLike | None = ...,
169
+ ) -> NDArray[np.floating[Any]]: ...
170
+ @overload
171
+ def pdist(
172
+ X: ArrayLike,
173
+ metric: _MetricCallback,
174
+ *,
175
+ out: None | NDArray[np.floating[Any]] = ...,
176
+ **kwargs: Any,
177
+ ) -> NDArray[np.floating[Any]]: ...
178
+
179
+ def seuclidean(
180
+ u: ArrayLike, v: ArrayLike, V: ArrayLike
181
+ ) -> float: ...
182
+
183
+ def sokalmichener(
184
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
185
+ ) -> float: ...
186
+
187
+ def sokalsneath(
188
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
189
+ ) -> np.float64: ...
190
+
191
+ def sqeuclidean(
192
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
193
+ ) -> np.float64: ...
194
+
195
+ def squareform(
196
+ X: ArrayLike,
197
+ force: Literal["no", "tomatrix", "tovector"] = ...,
198
+ checks: bool = ...,
199
+ ) -> NDArray[Any]: ...
200
+
201
+ def rogerstanimoto(
202
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
203
+ ) -> float: ...
204
+
205
+ def russellrao(
206
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
207
+ ) -> float: ...
208
+
209
+ def yule(
210
+ u: ArrayLike, v: ArrayLike, w: ArrayLike | None = ...
211
+ ) -> float: ...
parrot/lib/python3.10/site-packages/scipy/spatial/kdtree.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is not meant for public use and will be removed in SciPy v2.0.0.
2
+ # Use the `scipy.spatial` namespace for importing the functions
3
+ # included below.
4
+
5
+ from scipy._lib.deprecation import _sub_module_deprecation
6
+
7
+
8
+ __all__ = [ # noqa: F822
9
+ 'KDTree',
10
+ 'Rectangle',
11
+ 'cKDTree',
12
+ 'distance_matrix',
13
+ 'minkowski_distance',
14
+ 'minkowski_distance_p',
15
+ ]
16
+
17
+
18
+ def __dir__():
19
+ return __all__
20
+
21
+
22
+ def __getattr__(name):
23
+ return _sub_module_deprecation(sub_package="spatial", module="kdtree",
24
+ private_modules=["_kdtree"], all=__all__,
25
+ attribute=name)
parrot/lib/python3.10/site-packages/scipy/spatial/qhull.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is not meant for public use and will be removed in SciPy v2.0.0.
2
+ # Use the `scipy.spatial` namespace for importing the functions
3
+ # included below.
4
+
5
+ from scipy._lib.deprecation import _sub_module_deprecation
6
+
7
+
8
+ __all__ = [ # noqa: F822
9
+ 'ConvexHull',
10
+ 'Delaunay',
11
+ 'HalfspaceIntersection',
12
+ 'QhullError',
13
+ 'Voronoi',
14
+ 'tsearch',
15
+ ]
16
+
17
+
18
+ def __dir__():
19
+ return __all__
20
+
21
+
22
+ def __getattr__(name):
23
+ return _sub_module_deprecation(sub_package="spatial", module="qhull",
24
+ private_modules=["_qhull"], all=__all__,
25
+ attribute=name)
parrot/lib/python3.10/site-packages/scipy/spatial/tests/__init__.py ADDED
File without changes
parrot/lib/python3.10/site-packages/scipy/spatial/tests/test__plotutils.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+ import numpy as np
3
+ from numpy.testing import assert_, assert_array_equal, assert_allclose
4
+
5
+ try:
6
+ import matplotlib
7
+ matplotlib.rcParams['backend'] = 'Agg'
8
+ import matplotlib.pyplot as plt
9
+ has_matplotlib = True
10
+ except Exception:
11
+ has_matplotlib = False
12
+
13
+ from scipy.spatial import \
14
+ delaunay_plot_2d, voronoi_plot_2d, convex_hull_plot_2d, \
15
+ Delaunay, Voronoi, ConvexHull
16
+
17
+
18
+ @pytest.mark.skipif(not has_matplotlib, reason="Matplotlib not available")
19
+ class TestPlotting:
20
+ points = [(0,0), (0,1), (1,0), (1,1)]
21
+
22
+ def test_delaunay(self):
23
+ # Smoke test
24
+ fig = plt.figure()
25
+ obj = Delaunay(self.points)
26
+ s_before = obj.simplices.copy()
27
+ r = delaunay_plot_2d(obj, ax=fig.gca())
28
+ assert_array_equal(obj.simplices, s_before) # shouldn't modify
29
+ assert_(r is fig)
30
+ delaunay_plot_2d(obj, ax=fig.gca())
31
+
32
+ def test_voronoi(self):
33
+ # Smoke test
34
+ fig = plt.figure()
35
+ obj = Voronoi(self.points)
36
+ r = voronoi_plot_2d(obj, ax=fig.gca())
37
+ assert_(r is fig)
38
+ voronoi_plot_2d(obj)
39
+ voronoi_plot_2d(obj, show_vertices=False)
40
+
41
+ def test_convex_hull(self):
42
+ # Smoke test
43
+ fig = plt.figure()
44
+ tri = ConvexHull(self.points)
45
+ r = convex_hull_plot_2d(tri, ax=fig.gca())
46
+ assert_(r is fig)
47
+ convex_hull_plot_2d(tri)
48
+
49
+ def test_gh_19653(self):
50
+ # aspect ratio sensitivity of voronoi_plot_2d
51
+ # infinite Voronoi edges
52
+ points = np.array([[245.059986986012, 10.971011721360075],
53
+ [320.49044143557785, 10.970258360366753],
54
+ [239.79023081978914, 13.108487516946218],
55
+ [263.38325791238833, 12.93241352743668],
56
+ [219.53334398353175, 13.346107628161008]])
57
+ vor = Voronoi(points)
58
+ fig = voronoi_plot_2d(vor)
59
+ ax = fig.gca()
60
+ infinite_segments = ax.collections[1].get_segments()
61
+ expected_segments = np.array([[[282.77256, -254.76904],
62
+ [282.729714, -4544.744698]],
63
+ [[282.77256014, -254.76904029],
64
+ [430.08561382, 4032.67658742]],
65
+ [[229.26733285, -20.39957514],
66
+ [-168.17167404, -4291.92545966]],
67
+ [[289.93433364, 5151.40412217],
68
+ [330.40553385, 9441.18887532]]])
69
+ assert_allclose(infinite_segments, expected_segments)
70
+
71
+ def test_gh_19653_smaller_aspect(self):
72
+ # reasonable behavior for less extreme aspect
73
+ # ratio
74
+ points = np.array([[24.059986986012, 10.971011721360075],
75
+ [32.49044143557785, 10.970258360366753],
76
+ [23.79023081978914, 13.108487516946218],
77
+ [26.38325791238833, 12.93241352743668],
78
+ [21.53334398353175, 13.346107628161008]])
79
+ vor = Voronoi(points)
80
+ fig = voronoi_plot_2d(vor)
81
+ ax = fig.gca()
82
+ infinite_segments = ax.collections[1].get_segments()
83
+ expected_segments = np.array([[[28.274979, 8.335027],
84
+ [28.270463, -42.19763338]],
85
+ [[28.27497869, 8.33502697],
86
+ [43.73223829, 56.44555501]],
87
+ [[22.51805823, 11.8621754],
88
+ [-12.09266506, -24.95694485]],
89
+ [[29.53092448, 78.46952378],
90
+ [33.82572726, 128.81934455]]])
91
+ assert_allclose(infinite_segments, expected_segments)
parrot/lib/python3.10/site-packages/scipy/spatial/tests/test__procrustes.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from numpy.testing import assert_allclose, assert_equal, assert_almost_equal
3
+ from pytest import raises as assert_raises
4
+
5
+ from scipy.spatial import procrustes
6
+
7
+
8
+ class TestProcrustes:
9
+ def setup_method(self):
10
+ """creates inputs"""
11
+ # an L
12
+ self.data1 = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd')
13
+
14
+ # a larger, shifted, mirrored L
15
+ self.data2 = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd')
16
+
17
+ # an L shifted up 1, right 1, and with point 4 shifted an extra .5
18
+ # to the right
19
+ # pointwise distance disparity with data1: 3*(2) + (1 + 1.5^2)
20
+ self.data3 = np.array([[2, 4], [2, 3], [2, 2], [3, 2.5]], 'd')
21
+
22
+ # data4, data5 are standardized (trace(A*A') = 1).
23
+ # procrustes should return an identical copy if they are used
24
+ # as the first matrix argument.
25
+ shiftangle = np.pi / 8
26
+ self.data4 = np.array([[1, 0], [0, 1], [-1, 0],
27
+ [0, -1]], 'd') / np.sqrt(4)
28
+ self.data5 = np.array([[np.cos(shiftangle), np.sin(shiftangle)],
29
+ [np.cos(np.pi / 2 - shiftangle),
30
+ np.sin(np.pi / 2 - shiftangle)],
31
+ [-np.cos(shiftangle),
32
+ -np.sin(shiftangle)],
33
+ [-np.cos(np.pi / 2 - shiftangle),
34
+ -np.sin(np.pi / 2 - shiftangle)]],
35
+ 'd') / np.sqrt(4)
36
+
37
+ def test_procrustes(self):
38
+ # tests procrustes' ability to match two matrices.
39
+ #
40
+ # the second matrix is a rotated, shifted, scaled, and mirrored version
41
+ # of the first, in two dimensions only
42
+ #
43
+ # can shift, mirror, and scale an 'L'?
44
+ a, b, disparity = procrustes(self.data1, self.data2)
45
+ assert_allclose(b, a)
46
+ assert_almost_equal(disparity, 0.)
47
+
48
+ # if first mtx is standardized, leaves first mtx unchanged?
49
+ m4, m5, disp45 = procrustes(self.data4, self.data5)
50
+ assert_equal(m4, self.data4)
51
+
52
+ # at worst, data3 is an 'L' with one point off by .5
53
+ m1, m3, disp13 = procrustes(self.data1, self.data3)
54
+ #assert_(disp13 < 0.5 ** 2)
55
+
56
+ def test_procrustes2(self):
57
+ # procrustes disparity should not depend on order of matrices
58
+ m1, m3, disp13 = procrustes(self.data1, self.data3)
59
+ m3_2, m1_2, disp31 = procrustes(self.data3, self.data1)
60
+ assert_almost_equal(disp13, disp31)
61
+
62
+ # try with 3d, 8 pts per
63
+ rand1 = np.array([[2.61955202, 0.30522265, 0.55515826],
64
+ [0.41124708, -0.03966978, -0.31854548],
65
+ [0.91910318, 1.39451809, -0.15295084],
66
+ [2.00452023, 0.50150048, 0.29485268],
67
+ [0.09453595, 0.67528885, 0.03283872],
68
+ [0.07015232, 2.18892599, -1.67266852],
69
+ [0.65029688, 1.60551637, 0.80013549],
70
+ [-0.6607528, 0.53644208, 0.17033891]])
71
+
72
+ rand3 = np.array([[0.0809969, 0.09731461, -0.173442],
73
+ [-1.84888465, -0.92589646, -1.29335743],
74
+ [0.67031855, -1.35957463, 0.41938621],
75
+ [0.73967209, -0.20230757, 0.52418027],
76
+ [0.17752796, 0.09065607, 0.29827466],
77
+ [0.47999368, -0.88455717, -0.57547934],
78
+ [-0.11486344, -0.12608506, -0.3395779],
79
+ [-0.86106154, -0.28687488, 0.9644429]])
80
+ res1, res3, disp13 = procrustes(rand1, rand3)
81
+ res3_2, res1_2, disp31 = procrustes(rand3, rand1)
82
+ assert_almost_equal(disp13, disp31)
83
+
84
+ def test_procrustes_shape_mismatch(self):
85
+ assert_raises(ValueError, procrustes,
86
+ np.array([[1, 2], [3, 4]]),
87
+ np.array([[5, 6, 7], [8, 9, 10]]))
88
+
89
+ def test_procrustes_empty_rows_or_cols(self):
90
+ empty = np.array([[]])
91
+ assert_raises(ValueError, procrustes, empty, empty)
92
+
93
+ def test_procrustes_no_variation(self):
94
+ assert_raises(ValueError, procrustes,
95
+ np.array([[42, 42], [42, 42]]),
96
+ np.array([[45, 45], [45, 45]]))
97
+
98
+ def test_procrustes_bad_number_of_dimensions(self):
99
+ # fewer dimensions in one dataset
100
+ assert_raises(ValueError, procrustes,
101
+ np.array([1, 1, 2, 3, 5, 8]),
102
+ np.array([[1, 2], [3, 4]]))
103
+
104
+ # fewer dimensions in both datasets
105
+ assert_raises(ValueError, procrustes,
106
+ np.array([1, 1, 2, 3, 5, 8]),
107
+ np.array([1, 1, 2, 3, 5, 8]))
108
+
109
+ # zero dimensions
110
+ assert_raises(ValueError, procrustes, np.array(7), np.array(11))
111
+
112
+ # extra dimensions
113
+ assert_raises(ValueError, procrustes,
114
+ np.array([[[11], [7]]]),
115
+ np.array([[[5, 13]]]))
116
+
parrot/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08c903c75c989b012035d1ab96baf8c0560bc1b7731728a292e2f061a8d1abb0
3
+ size 212286
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/METADATA ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.3
2
+ Name: ftfy
3
+ Version: 6.3.1
4
+ Summary: Fixes mojibake and other problems with Unicode, after the fact
5
+ Project-URL: Homepage, https://ftfy.readthedocs.io/en/latest/
6
+ Project-URL: Documentation, https://ftfy.readthedocs.io/en/latest/
7
+ Project-URL: Repository, https://github.com/rspeer/python-ftfy
8
+ Project-URL: Issues, https://github.com/rspeer/python-ftfy/issues/
9
+ Project-URL: Changelog, https://github.com/rspeer/python-ftfy/blob/main/CHANGELOG.md
10
+ Project-URL: Blog, https://posts.arborelia.net
11
+ Author-email: Robyn Speer <rspeer@arborelia.net>
12
+ License: Apache-2.0
13
+ License-File: LICENSE.txt
14
+ Requires-Python: >=3.9
15
+ Requires-Dist: wcwidth
16
+ Description-Content-Type: text/markdown
17
+
18
+ # ftfy: fixes text for you
19
+
20
+ [![PyPI package](https://badge.fury.io/py/ftfy.svg)](https://badge.fury.io/py/ftfy)
21
+ [![Docs](https://readthedocs.org/projects/ftfy/badge/?version=latest)](https://ftfy.readthedocs.org/en/latest/)
22
+
23
+ ```python
24
+
25
+ >>> from ftfy import fix_encoding
26
+ >>> print(fix_encoding("(ง'⌣')ง"))
27
+ (ง'⌣')ง
28
+
29
+ ```
30
+
31
+ The full documentation of ftfy is available at [ftfy.readthedocs.org](https://ftfy.readthedocs.org). The documentation covers a lot more than this README, so here are some links into it:
32
+
33
+ - [Fixing problems and getting explanations](https://ftfy.readthedocs.io/en/latest/explain.html)
34
+ - [Configuring ftfy](https://ftfy.readthedocs.io/en/latest/config.html)
35
+ - [Encodings ftfy can handle](https://ftfy.readthedocs.io/en/latest/encodings.html)
36
+ - [“Fixer” functions](https://ftfy.readthedocs.io/en/latest/fixes.html)
37
+ - [Is ftfy an encoding detector?](https://ftfy.readthedocs.io/en/latest/detect.html)
38
+ - [Heuristics for detecting mojibake](https://ftfy.readthedocs.io/en/latest/heuristic.html)
39
+ - [Support for “bad” encodings](https://ftfy.readthedocs.io/en/latest/bad_encodings.html)
40
+ - [Command-line usage](https://ftfy.readthedocs.io/en/latest/cli.html)
41
+ - [Citing ftfy](https://ftfy.readthedocs.io/en/latest/cite.html)
42
+
43
+ ## Testimonials
44
+
45
+ - “My life is livable again!”
46
+ — [@planarrowspace](https://twitter.com/planarrowspace)
47
+ - “A handy piece of magic”
48
+ — [@simonw](https://twitter.com/simonw)
49
+ - “Saved me a large amount of frustrating dev work”
50
+ — [@iancal](https://twitter.com/iancal)
51
+ - “ftfy did the right thing right away, with no faffing about. Excellent work, solving a very tricky real-world (whole-world!) problem.”
52
+ — Brennan Young
53
+ - “I have no idea when I’m gonna need this, but I’m definitely bookmarking it.”
54
+ — [/u/ocrow](https://reddit.com/u/ocrow)
55
+
56
+ ## What it does
57
+
58
+ Here are some examples (found in the real world) of what ftfy can do:
59
+
60
+ ftfy can fix mojibake (encoding mix-ups), by detecting patterns of characters that were clearly meant to be UTF-8 but were decoded as something else:
61
+
62
+ >>> import ftfy
63
+ >>> ftfy.fix_text('✔ No problems')
64
+ '✔ No problems'
65
+
66
+ Does this sound impossible? It's really not. UTF-8 is a well-designed encoding that makes it obvious when it's being misused, and a string of mojibake usually contains all the information we need to recover the original string.
67
+
68
+ ftfy can fix multiple layers of mojibake simultaneously:
69
+
70
+ >>> ftfy.fix_text('The Mona Lisa doesn’t have eyebrows.')
71
+ "The Mona Lisa doesn't have eyebrows."
72
+
73
+ It can fix mojibake that has had "curly quotes" applied on top of it, which cannot be consistently decoded until the quotes are uncurled:
74
+
75
+ >>> ftfy.fix_text("l’humanité")
76
+ "l'humanité"
77
+
78
+ ftfy can fix mojibake that would have included the character U+A0 (non-breaking space), but the U+A0 was turned into an ASCII space and then combined with another following space:
79
+
80
+ >>> ftfy.fix_text('Ã\xa0 perturber la réflexion')
81
+ 'à perturber la réflexion'
82
+ >>> ftfy.fix_text('à perturber la réflexion')
83
+ 'à perturber la réflexion'
84
+
85
+ ftfy can also decode HTML entities that appear outside of HTML, even in cases where the entity has been incorrectly capitalized:
86
+
87
+ >>> # by the HTML 5 standard, only 'P&Eacute;REZ' is acceptable
88
+ >>> ftfy.fix_text('P&EACUTE;REZ')
89
+ 'PÉREZ'
90
+
91
+ These fixes are not applied in all cases, because ftfy has a strongly-held goal of avoiding false positives -- it should never change correctly-decoded text to something else.
92
+
93
+ The following text could be encoded in Windows-1252 and decoded in UTF-8, and it would decode as 'MARQUɅ'. However, the original text is already sensible, so it is unchanged.
94
+
95
+ >>> ftfy.fix_text('IL Y MARQUÉ…')
96
+ 'IL Y MARQUÉ…'
97
+
98
+ ## Installing
99
+
100
+ ftfy is a Python 3 package that can be installed using `pip` or `uv pip`:
101
+
102
+ pip install ftfy
103
+
104
+ (Or use `pip3 install ftfy` on systems where Python 2 and 3 are both globally installed and `pip` refers to Python 2.)
105
+
106
+ If you use `poetry`, you can use ftfy as a dependency in the usual way (such as `poetry add ftfy`).
107
+
108
+ ### Local development
109
+
110
+ ftfy is developed using [uv](https://github.com/astral-sh/uv). You can build a virtual environment with its local dependencies by running `uv venv`, and test it with `uv run pytest`.
111
+
112
+ ## Who maintains ftfy?
113
+
114
+ I'm Robyn Speer, also known as Elia Robyn Lake. You can find my projects
115
+ [on GitHub](https://github.com/rspeer) and my posts on [my own blog](https://posts.arborelia.net).
116
+
117
+ ## Citing ftfy
118
+
119
+ ftfy has been used as a crucial data processing step in major NLP research.
120
+
121
+ It's important to give credit appropriately to everyone whose work you build on in research. This includes software, not just high-status contributions such as mathematical models. All I ask when you use ftfy for research is that you cite it.
122
+
123
+ ftfy has a citable record [on Zenodo](https://zenodo.org/record/2591652). A citation of ftfy may look like this:
124
+
125
+ Robyn Speer. (2019). ftfy (Version 5.5). Zenodo.
126
+ http://doi.org/10.5281/zenodo.2591652
127
+
128
+ In BibTeX format, the citation is::
129
+
130
+ @misc{speer-2019-ftfy,
131
+ author = {Robyn Speer},
132
+ title = {ftfy},
133
+ note = {Version 5.5},
134
+ year = 2019,
135
+ howpublished = {Zenodo},
136
+ doi = {10.5281/zenodo.2591652},
137
+ url = {https://doi.org/10.5281/zenodo.2591652}
138
+ }
139
+
140
+ ## Important license clarifications
141
+
142
+ If you do not follow ftfy's license, you do not have a license to ftfy.
143
+
144
+ This sounds obvious and tautological, but there are people who think open source licenses mean that they can just do what they want, especially in the field of generative AI. It's a permissive license but you still have to follow it. The [Apache license](https://www.apache.org/licenses/LICENSE-2.0) is the only thing that gives you permission to use and copy ftfy; otherwise, all rights are reserved.
145
+
146
+ If you use or distribute ftfy, you must follow the terms of the [Apache license](https://www.apache.org/licenses/LICENSE-2.0), including that you must attribute the author of ftfy (Robyn Speer) correctly.
147
+
148
+ You _may not_ make a derived work of ftfy that obscures its authorship, such as by putting its code in an AI training dataset, including the code in AI training at runtime, or using a generative AI that copies code from such a dataset.
149
+
150
+ At my discretion, I may notify you of a license violation, and give you a chance to either remedy it or delete all copies of ftfy in your possession.
151
+
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/RECORD ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/ftfy,sha256=fsTFYlFg_hHOGgoB6KG_JEyQpmLe6ytRIO1iDxH9dZM,217
2
+ ftfy-6.3.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
3
+ ftfy-6.3.1.dist-info/METADATA,sha256=g_Z8YoA3djfFYLXogCoAum7lErCh6h2uXf8edFsZ0d8,7257
4
+ ftfy-6.3.1.dist-info/RECORD,,
5
+ ftfy-6.3.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ ftfy-6.3.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
7
+ ftfy-6.3.1.dist-info/entry_points.txt,sha256=sy4Ei29IqZhQRgYFC17GVrT1JkE6l1-ooJheKulSqO8,39
8
+ ftfy-6.3.1.dist-info/licenses/LICENSE.txt,sha256=oL_FAgvC4eggVRoGJccMlfqomMFec3EA_0iAqhAZeFc,552
9
+ ftfy/__init__.py,sha256=ekX6ZbJnR3UxmgWwpM2_0Eoizn82ukCYQRv57Bsiyzw,29593
10
+ ftfy/__pycache__/__init__.cpython-310.pyc,,
11
+ ftfy/__pycache__/badness.cpython-310.pyc,,
12
+ ftfy/__pycache__/chardata.cpython-310.pyc,,
13
+ ftfy/__pycache__/cli.cpython-310.pyc,,
14
+ ftfy/__pycache__/fixes.cpython-310.pyc,,
15
+ ftfy/__pycache__/formatting.cpython-310.pyc,,
16
+ ftfy/bad_codecs/__init__.py,sha256=sPKWae974vjc3JeOsGhZ8ZFNUoPTISx988zBbxJ7SIQ,3282
17
+ ftfy/bad_codecs/__pycache__/__init__.cpython-310.pyc,,
18
+ ftfy/bad_codecs/__pycache__/sloppy.cpython-310.pyc,,
19
+ ftfy/bad_codecs/__pycache__/utf8_variants.cpython-310.pyc,,
20
+ ftfy/bad_codecs/sloppy.py,sha256=bzgoZAQIrzRUxb-qJmDVX6_Eh2l143IqstdFFFayTII,6814
21
+ ftfy/bad_codecs/utf8_variants.py,sha256=WlyMbOtUFftePEj_SpxDTXirPAj8HcuxVZ1aSYApVh0,9964
22
+ ftfy/badness.py,sha256=jOR-ucAfX6LTjmUP4EdHS95VN766WXG3IsprQHnfb9M,15561
23
+ ftfy/chardata.py,sha256=tAXqrX2Y3zBslAZoj6tFBy-Yn-_-UwF1uszvKN7cVck,34911
24
+ ftfy/cli.py,sha256=q9DNi4LuhKGrleoH_Z3aB6J0oST34a2WWatap7Odr7s,4137
25
+ ftfy/fixes.py,sha256=G8XQKzMlcsw4aPhRrQgcwAMcxqatf7EDmNaOrsY-C6U,18233
26
+ ftfy/formatting.py,sha256=pbmBunYydgPs3bxMhCXFtaTM0_3qT_yp6esZvjvOKZk,5882
27
+ ftfy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.25.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [console_scripts]
2
+ ftfy = ftfy.cli:main
vllm/lib/python3.10/site-packages/ftfy-6.3.1.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2023 Robyn Speer
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
vllm/lib/python3.10/site-packages/markdown_it/cli/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (165 Bytes). View file
 
vllm/lib/python3.10/site-packages/markdown_it/helpers/parse_link_title.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Parse link title
2
+ """
3
+ from ..common.utils import charCodeAt, unescapeAll
4
+
5
+
6
+ class _Result:
7
+ __slots__ = ("ok", "pos", "lines", "str")
8
+
9
+ def __init__(self) -> None:
10
+ self.ok = False
11
+ self.pos = 0
12
+ self.lines = 0
13
+ self.str = ""
14
+
15
+ def __str__(self) -> str:
16
+ return self.str
17
+
18
+
19
+ def parseLinkTitle(string: str, pos: int, maximum: int) -> _Result:
20
+ lines = 0
21
+ start = pos
22
+ result = _Result()
23
+
24
+ if pos >= maximum:
25
+ return result
26
+
27
+ marker = charCodeAt(string, pos)
28
+
29
+ # /* " */ /* ' */ /* ( */
30
+ if marker != 0x22 and marker != 0x27 and marker != 0x28:
31
+ return result
32
+
33
+ pos += 1
34
+
35
+ # if opening marker is "(", switch it to closing marker ")"
36
+ if marker == 0x28:
37
+ marker = 0x29
38
+
39
+ while pos < maximum:
40
+ code = charCodeAt(string, pos)
41
+ if code == marker:
42
+ title = string[start + 1 : pos]
43
+ title = unescapeAll(title)
44
+ result.pos = pos + 1
45
+ result.lines = lines
46
+ result.str = title
47
+ result.ok = True
48
+ return result
49
+ elif code == 0x28 and marker == 0x29: # /* ( */ /* ) */
50
+ return result
51
+ elif code == 0x0A:
52
+ lines += 1
53
+ elif code == 0x5C and pos + 1 < maximum: # /* \ */
54
+ pos += 1
55
+ if charCodeAt(string, pos) == 0x0A:
56
+ lines += 1
57
+
58
+ pos += 1
59
+
60
+ return result
vllm/lib/python3.10/site-packages/multipart/__init__.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This only works if using a file system, other loaders not implemented.
2
+
3
+ import importlib.util
4
+ import sys
5
+ import warnings
6
+ from pathlib import Path
7
+
8
+ for p in sys.path:
9
+ file_path = Path(p, "multipart.py")
10
+ try:
11
+ if file_path.is_file():
12
+ spec = importlib.util.spec_from_file_location("multipart", file_path)
13
+ assert spec is not None, f"{file_path} found but not loadable!"
14
+ module = importlib.util.module_from_spec(spec)
15
+ sys.modules["multipart"] = module
16
+ assert spec.loader is not None, f"{file_path} must be loadable!"
17
+ spec.loader.exec_module(module)
18
+ break
19
+ except PermissionError:
20
+ pass
21
+ else:
22
+ warnings.warn("Please use `import python_multipart` instead.", PendingDeprecationWarning, stacklevel=2)
23
+ from python_multipart import *
24
+ from python_multipart import __all__, __author__, __copyright__, __license__, __version__
vllm/lib/python3.10/site-packages/multipart/__pycache__/decoders.cpython-310.pyc ADDED
Binary file (201 Bytes). View file
 
vllm/lib/python3.10/site-packages/multipart/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (205 Bytes). View file
 
vllm/lib/python3.10/site-packages/multipart/decoders.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from python_multipart.decoders import *
vllm/lib/python3.10/site-packages/multipart/exceptions.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from python_multipart.exceptions import *
vllm/lib/python3.10/site-packages/multipart/multipart.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from python_multipart.multipart import *
vllm/lib/python3.10/site-packages/rsa/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.05 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/asn1.cpython-310.pyc ADDED
Binary file (1.42 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/cli.cpython-310.pyc ADDED
Binary file (9.1 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/common.cpython-310.pyc ADDED
Binary file (4.27 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/core.cpython-310.pyc ADDED
Binary file (1.29 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/key.cpython-310.pyc ADDED
Binary file (25.2 kB). View file
 
vllm/lib/python3.10/site-packages/rsa/__pycache__/parallel.cpython-310.pyc ADDED
Binary file (1.9 kB). View file