applied-ai-018 commited on
Commit
072e1ee
·
verified ·
1 Parent(s): 33a0b79

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. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_filters.cpython-310.pyc +0 -0
  2. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_fourier.cpython-310.pyc +0 -0
  3. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_interpolation.cpython-310.pyc +0 -0
  4. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/__pycache__/test_datatypes.cpython-310.pyc +0 -0
  5. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/data/label_inputs.txt +21 -0
  6. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/data/label_results.txt +294 -0
  7. llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/data/label_strels.txt +42 -0
  8. llmeval-env/lib/python3.10/site-packages/scipy/sparse/_csc.py +364 -0
  9. llmeval-env/lib/python3.10/site-packages/scipy/sparse/_data.py +506 -0
  10. llmeval-env/lib/python3.10/site-packages/scipy/sparse/_sputils.py +451 -0
  11. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aden +0 -0
  12. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Anadyr +0 -0
  13. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aqtau +0 -0
  14. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aqtobe +0 -0
  15. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Ashgabat +0 -0
  16. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Atyrau +0 -0
  17. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Bahrain +0 -0
  18. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Baku +0 -0
  19. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Bangkok +0 -0
  20. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Barnaul +0 -0
  21. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Beirut +0 -0
  22. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Brunei +0 -0
  23. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Choibalsan +0 -0
  24. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Chongqing +0 -0
  25. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Chungking +0 -0
  26. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Damascus +0 -0
  27. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dhaka +0 -0
  28. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dubai +0 -0
  29. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dushanbe +0 -0
  30. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Famagusta +0 -0
  31. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Gaza +0 -0
  32. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Hebron +0 -0
  33. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Ho_Chi_Minh +0 -0
  34. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Hong_Kong +0 -0
  35. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Irkutsk +0 -0
  36. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Istanbul +0 -0
  37. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Jakarta +0 -0
  38. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Jerusalem +0 -0
  39. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kabul +0 -0
  40. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kamchatka +0 -0
  41. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kashgar +0 -0
  42. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kathmandu +0 -0
  43. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Katmandu +0 -0
  44. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Khandyga +0 -0
  45. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kolkata +0 -0
  46. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Krasnoyarsk +0 -0
  47. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kuching +0 -0
  48. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kuwait +0 -0
  49. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Magadan +0 -0
  50. llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Muscat +0 -0
llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_filters.cpython-310.pyc ADDED
Binary file (52.3 kB). View file
 
llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_fourier.cpython-310.pyc ADDED
Binary file (8.74 kB). View file
 
llmeval-env/lib/python3.10/site-packages/scipy/ndimage/__pycache__/_interpolation.cpython-310.pyc ADDED
Binary file (28.6 kB). View file
 
llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/__pycache__/test_datatypes.cpython-310.pyc ADDED
Binary file (1.9 kB). View file
 
llmeval-env/lib/python3.10/site-packages/scipy/ndimage/tests/data/label_inputs.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1 1 1 1 1 1 1
2
+ 1 1 1 1 1 1 1
3
+ 1 1 1 1 1 1 1
4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6 0 1 0 7
111
+ 5 5 0 0 0 1 1
112
+ 5 5 5 0 1 1 1
113
+ 1 1 1 0 2 2 2
114
+ 3 3 0 0 0 4 4
115
+ 5 0 6 0 7 0 8
116
+ 0 0 0 9 0 0 0
117
+ 10 0 11 0 12 0 13
118
+ 14 14 0 0 0 15 15
119
+ 16 16 16 0 17 17 17
120
+ 1 1 1 0 2 3 3
121
+ 1 1 0 0 0 3 3
122
+ 1 0 4 0 3 0 3
123
+ 0 0 0 3 0 0 0
124
+ 3 0 3 0 5 0 6
125
+ 3 3 0 0 0 6 6
126
+ 3 3 7 0 6 6 6
127
+ 1 2 3 0 4 5 6
128
+ 7 8 0 0 0 9 10
129
+ 11 0 12 0 13 0 14
130
+ 0 0 0 15 0 0 0
131
+ 16 0 17 0 18 0 19
132
+ 20 21 0 0 0 22 23
133
+ 24 25 26 0 27 28 29
134
+ 1 1 1 0 2 2 2
135
+ 1 1 0 0 0 2 2
136
+ 1 0 3 0 2 0 2
137
+ 0 0 0 2 0 0 0
138
+ 2 0 2 0 4 0 5
139
+ 2 2 0 0 0 5 5
140
+ 2 2 2 0 5 5 5
141
+ 1 1 1 0 2 2 2
142
+ 1 1 0 0 0 2 2
143
+ 1 0 3 0 4 0 2
144
+ 0 0 0 5 0 0 0
145
+ 6 0 7 0 8 0 9
146
+ 6 6 0 0 0 9 9
147
+ 6 6 6 0 9 9 9
148
+ 1 2 3 0 4 5 6
149
+ 7 1 0 0 0 4 5
150
+ 8 0 1 0 9 0 4
151
+ 0 0 0 1 0 0 0
152
+ 10 0 11 0 1 0 12
153
+ 13 10 0 0 0 1 14
154
+ 15 13 10 0 16 17 1
155
+ 1 2 3 0 4 5 6
156
+ 1 2 0 0 0 5 6
157
+ 1 0 7 0 8 0 6
158
+ 0 0 0 9 0 0 0
159
+ 10 0 11 0 12 0 13
160
+ 10 14 0 0 0 15 13
161
+ 10 14 16 0 17 15 13
162
+ 1 1 1 0 1 1 1
163
+ 1 1 0 0 0 1 1
164
+ 1 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+ 1 1 1
42
+ 0 1 1
llmeval-env/lib/python3.10/site-packages/scipy/sparse/_csc.py ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compressed Sparse Column matrix format"""
2
+ __docformat__ = "restructuredtext en"
3
+
4
+ __all__ = ['csc_array', 'csc_matrix', 'isspmatrix_csc']
5
+
6
+
7
+ import numpy as np
8
+
9
+ from ._matrix import spmatrix
10
+ from ._base import _spbase, sparray
11
+ from ._sparsetools import csc_tocsr, expandptr
12
+ from ._sputils import upcast
13
+
14
+ from ._compressed import _cs_matrix
15
+
16
+
17
+ class _csc_base(_cs_matrix):
18
+ _format = 'csc'
19
+
20
+ def transpose(self, axes=None, copy=False):
21
+ if axes is not None and axes != (1, 0):
22
+ raise ValueError("Sparse arrays/matrices do not support "
23
+ "an 'axes' parameter because swapping "
24
+ "dimensions is the only logical permutation.")
25
+
26
+ M, N = self.shape
27
+
28
+ return self._csr_container((self.data, self.indices,
29
+ self.indptr), (N, M), copy=copy)
30
+
31
+ transpose.__doc__ = _spbase.transpose.__doc__
32
+
33
+ def __iter__(self):
34
+ yield from self.tocsr()
35
+
36
+ def tocsc(self, copy=False):
37
+ if copy:
38
+ return self.copy()
39
+ else:
40
+ return self
41
+
42
+ tocsc.__doc__ = _spbase.tocsc.__doc__
43
+
44
+ def tocsr(self, copy=False):
45
+ M,N = self.shape
46
+ idx_dtype = self._get_index_dtype((self.indptr, self.indices),
47
+ maxval=max(self.nnz, N))
48
+ indptr = np.empty(M + 1, dtype=idx_dtype)
49
+ indices = np.empty(self.nnz, dtype=idx_dtype)
50
+ data = np.empty(self.nnz, dtype=upcast(self.dtype))
51
+
52
+ csc_tocsr(M, N,
53
+ self.indptr.astype(idx_dtype),
54
+ self.indices.astype(idx_dtype),
55
+ self.data,
56
+ indptr,
57
+ indices,
58
+ data)
59
+
60
+ A = self._csr_container(
61
+ (data, indices, indptr),
62
+ shape=self.shape, copy=False
63
+ )
64
+ A.has_sorted_indices = True
65
+ return A
66
+
67
+ tocsr.__doc__ = _spbase.tocsr.__doc__
68
+
69
+ def nonzero(self):
70
+ # CSC can't use _cs_matrix's .nonzero method because it
71
+ # returns the indices sorted for self transposed.
72
+
73
+ # Get row and col indices, from _cs_matrix.tocoo
74
+ major_dim, minor_dim = self._swap(self.shape)
75
+ minor_indices = self.indices
76
+ major_indices = np.empty(len(minor_indices), dtype=self.indices.dtype)
77
+ expandptr(major_dim, self.indptr, major_indices)
78
+ row, col = self._swap((major_indices, minor_indices))
79
+
80
+ # Remove explicit zeros
81
+ nz_mask = self.data != 0
82
+ row = row[nz_mask]
83
+ col = col[nz_mask]
84
+
85
+ # Sort them to be in C-style order
86
+ ind = np.argsort(row, kind='mergesort')
87
+ row = row[ind]
88
+ col = col[ind]
89
+
90
+ return row, col
91
+
92
+ nonzero.__doc__ = _cs_matrix.nonzero.__doc__
93
+
94
+ def _getrow(self, i):
95
+ """Returns a copy of row i of the matrix, as a (1 x n)
96
+ CSR matrix (row vector).
97
+ """
98
+ M, N = self.shape
99
+ i = int(i)
100
+ if i < 0:
101
+ i += M
102
+ if i < 0 or i >= M:
103
+ raise IndexError('index (%d) out of range' % i)
104
+ return self._get_submatrix(minor=i).tocsr()
105
+
106
+ def _getcol(self, i):
107
+ """Returns a copy of column i of the matrix, as a (m x 1)
108
+ CSC matrix (column vector).
109
+ """
110
+ M, N = self.shape
111
+ i = int(i)
112
+ if i < 0:
113
+ i += N
114
+ if i < 0 or i >= N:
115
+ raise IndexError('index (%d) out of range' % i)
116
+ return self._get_submatrix(major=i, copy=True)
117
+
118
+ def _get_intXarray(self, row, col):
119
+ return self._major_index_fancy(col)._get_submatrix(minor=row)
120
+
121
+ def _get_intXslice(self, row, col):
122
+ if col.step in (1, None):
123
+ return self._get_submatrix(major=col, minor=row, copy=True)
124
+ return self._major_slice(col)._get_submatrix(minor=row)
125
+
126
+ def _get_sliceXint(self, row, col):
127
+ if row.step in (1, None):
128
+ return self._get_submatrix(major=col, minor=row, copy=True)
129
+ return self._get_submatrix(major=col)._minor_slice(row)
130
+
131
+ def _get_sliceXarray(self, row, col):
132
+ return self._major_index_fancy(col)._minor_slice(row)
133
+
134
+ def _get_arrayXint(self, row, col):
135
+ return self._get_submatrix(major=col)._minor_index_fancy(row)
136
+
137
+ def _get_arrayXslice(self, row, col):
138
+ return self._major_slice(col)._minor_index_fancy(row)
139
+
140
+ # these functions are used by the parent class (_cs_matrix)
141
+ # to remove redundancy between csc_array and csr_matrix
142
+ @staticmethod
143
+ def _swap(x):
144
+ """swap the members of x if this is a column-oriented matrix
145
+ """
146
+ return x[1], x[0]
147
+
148
+
149
+ def isspmatrix_csc(x):
150
+ """Is `x` of csc_matrix type?
151
+
152
+ Parameters
153
+ ----------
154
+ x
155
+ object to check for being a csc matrix
156
+
157
+ Returns
158
+ -------
159
+ bool
160
+ True if `x` is a csc matrix, False otherwise
161
+
162
+ Examples
163
+ --------
164
+ >>> from scipy.sparse import csc_array, csc_matrix, coo_matrix, isspmatrix_csc
165
+ >>> isspmatrix_csc(csc_matrix([[5]]))
166
+ True
167
+ >>> isspmatrix_csc(csc_array([[5]]))
168
+ False
169
+ >>> isspmatrix_csc(coo_matrix([[5]]))
170
+ False
171
+ """
172
+ return isinstance(x, csc_matrix)
173
+
174
+
175
+ # This namespace class separates array from matrix with isinstance
176
+ class csc_array(_csc_base, sparray):
177
+ """
178
+ Compressed Sparse Column array.
179
+
180
+ This can be instantiated in several ways:
181
+ csc_array(D)
182
+ where D is a 2-D ndarray
183
+
184
+ csc_array(S)
185
+ with another sparse array or matrix S (equivalent to S.tocsc())
186
+
187
+ csc_array((M, N), [dtype])
188
+ to construct an empty array with shape (M, N)
189
+ dtype is optional, defaulting to dtype='d'.
190
+
191
+ csc_array((data, (row_ind, col_ind)), [shape=(M, N)])
192
+ where ``data``, ``row_ind`` and ``col_ind`` satisfy the
193
+ relationship ``a[row_ind[k], col_ind[k]] = data[k]``.
194
+
195
+ csc_array((data, indices, indptr), [shape=(M, N)])
196
+ is the standard CSC representation where the row indices for
197
+ column i are stored in ``indices[indptr[i]:indptr[i+1]]``
198
+ and their corresponding values are stored in
199
+ ``data[indptr[i]:indptr[i+1]]``. If the shape parameter is
200
+ not supplied, the array dimensions are inferred from
201
+ the index arrays.
202
+
203
+ Attributes
204
+ ----------
205
+ dtype : dtype
206
+ Data type of the array
207
+ shape : 2-tuple
208
+ Shape of the array
209
+ ndim : int
210
+ Number of dimensions (this is always 2)
211
+ nnz
212
+ size
213
+ data
214
+ CSC format data array of the array
215
+ indices
216
+ CSC format index array of the array
217
+ indptr
218
+ CSC format index pointer array of the array
219
+ has_sorted_indices
220
+ has_canonical_format
221
+ T
222
+
223
+ Notes
224
+ -----
225
+
226
+ Sparse arrays can be used in arithmetic operations: they support
227
+ addition, subtraction, multiplication, division, and matrix power.
228
+
229
+ Advantages of the CSC format
230
+ - efficient arithmetic operations CSC + CSC, CSC * CSC, etc.
231
+ - efficient column slicing
232
+ - fast matrix vector products (CSR, BSR may be faster)
233
+
234
+ Disadvantages of the CSC format
235
+ - slow row slicing operations (consider CSR)
236
+ - changes to the sparsity structure are expensive (consider LIL or DOK)
237
+
238
+ Canonical format
239
+ - Within each column, indices are sorted by row.
240
+ - There are no duplicate entries.
241
+
242
+ Examples
243
+ --------
244
+
245
+ >>> import numpy as np
246
+ >>> from scipy.sparse import csc_array
247
+ >>> csc_array((3, 4), dtype=np.int8).toarray()
248
+ array([[0, 0, 0, 0],
249
+ [0, 0, 0, 0],
250
+ [0, 0, 0, 0]], dtype=int8)
251
+
252
+ >>> row = np.array([0, 2, 2, 0, 1, 2])
253
+ >>> col = np.array([0, 0, 1, 2, 2, 2])
254
+ >>> data = np.array([1, 2, 3, 4, 5, 6])
255
+ >>> csc_array((data, (row, col)), shape=(3, 3)).toarray()
256
+ array([[1, 0, 4],
257
+ [0, 0, 5],
258
+ [2, 3, 6]])
259
+
260
+ >>> indptr = np.array([0, 2, 3, 6])
261
+ >>> indices = np.array([0, 2, 2, 0, 1, 2])
262
+ >>> data = np.array([1, 2, 3, 4, 5, 6])
263
+ >>> csc_array((data, indices, indptr), shape=(3, 3)).toarray()
264
+ array([[1, 0, 4],
265
+ [0, 0, 5],
266
+ [2, 3, 6]])
267
+
268
+ """
269
+
270
+
271
+ class csc_matrix(spmatrix, _csc_base):
272
+ """
273
+ Compressed Sparse Column matrix.
274
+
275
+ This can be instantiated in several ways:
276
+ csc_matrix(D)
277
+ where D is a 2-D ndarray
278
+
279
+ csc_matrix(S)
280
+ with another sparse array or matrix S (equivalent to S.tocsc())
281
+
282
+ csc_matrix((M, N), [dtype])
283
+ to construct an empty matrix with shape (M, N)
284
+ dtype is optional, defaulting to dtype='d'.
285
+
286
+ csc_matrix((data, (row_ind, col_ind)), [shape=(M, N)])
287
+ where ``data``, ``row_ind`` and ``col_ind`` satisfy the
288
+ relationship ``a[row_ind[k], col_ind[k]] = data[k]``.
289
+
290
+ csc_matrix((data, indices, indptr), [shape=(M, N)])
291
+ is the standard CSC representation where the row indices for
292
+ column i are stored in ``indices[indptr[i]:indptr[i+1]]``
293
+ and their corresponding values are stored in
294
+ ``data[indptr[i]:indptr[i+1]]``. If the shape parameter is
295
+ not supplied, the matrix dimensions are inferred from
296
+ the index arrays.
297
+
298
+ Attributes
299
+ ----------
300
+ dtype : dtype
301
+ Data type of the matrix
302
+ shape : 2-tuple
303
+ Shape of the matrix
304
+ ndim : int
305
+ Number of dimensions (this is always 2)
306
+ nnz
307
+ size
308
+ data
309
+ CSC format data array of the matrix
310
+ indices
311
+ CSC format index array of the matrix
312
+ indptr
313
+ CSC format index pointer array of the matrix
314
+ has_sorted_indices
315
+ has_canonical_format
316
+ T
317
+
318
+ Notes
319
+ -----
320
+
321
+ Sparse matrices can be used in arithmetic operations: they support
322
+ addition, subtraction, multiplication, division, and matrix power.
323
+
324
+ Advantages of the CSC format
325
+ - efficient arithmetic operations CSC + CSC, CSC * CSC, etc.
326
+ - efficient column slicing
327
+ - fast matrix vector products (CSR, BSR may be faster)
328
+
329
+ Disadvantages of the CSC format
330
+ - slow row slicing operations (consider CSR)
331
+ - changes to the sparsity structure are expensive (consider LIL or DOK)
332
+
333
+ Canonical format
334
+ - Within each column, indices are sorted by row.
335
+ - There are no duplicate entries.
336
+
337
+ Examples
338
+ --------
339
+
340
+ >>> import numpy as np
341
+ >>> from scipy.sparse import csc_matrix
342
+ >>> csc_matrix((3, 4), dtype=np.int8).toarray()
343
+ array([[0, 0, 0, 0],
344
+ [0, 0, 0, 0],
345
+ [0, 0, 0, 0]], dtype=int8)
346
+
347
+ >>> row = np.array([0, 2, 2, 0, 1, 2])
348
+ >>> col = np.array([0, 0, 1, 2, 2, 2])
349
+ >>> data = np.array([1, 2, 3, 4, 5, 6])
350
+ >>> csc_matrix((data, (row, col)), shape=(3, 3)).toarray()
351
+ array([[1, 0, 4],
352
+ [0, 0, 5],
353
+ [2, 3, 6]])
354
+
355
+ >>> indptr = np.array([0, 2, 3, 6])
356
+ >>> indices = np.array([0, 2, 2, 0, 1, 2])
357
+ >>> data = np.array([1, 2, 3, 4, 5, 6])
358
+ >>> csc_matrix((data, indices, indptr), shape=(3, 3)).toarray()
359
+ array([[1, 0, 4],
360
+ [0, 0, 5],
361
+ [2, 3, 6]])
362
+
363
+ """
364
+
llmeval-env/lib/python3.10/site-packages/scipy/sparse/_data.py ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Base class for sparse matrice with a .data attribute
2
+
3
+ subclasses must provide a _with_data() method that
4
+ creates a new matrix with the same sparsity pattern
5
+ as self but with a different data array
6
+
7
+ """
8
+
9
+ import numpy as np
10
+
11
+ from ._base import _spbase, _ufuncs_with_fixed_point_at_zero
12
+ from ._sputils import isscalarlike, validateaxis
13
+
14
+ __all__ = []
15
+
16
+
17
+ # TODO implement all relevant operations
18
+ # use .data.__methods__() instead of /=, *=, etc.
19
+ class _data_matrix(_spbase):
20
+ def __init__(self):
21
+ _spbase.__init__(self)
22
+
23
+ @property
24
+ def dtype(self):
25
+ return self.data.dtype
26
+
27
+ @dtype.setter
28
+ def dtype(self, newtype):
29
+ self.data.dtype = newtype
30
+
31
+ def _deduped_data(self):
32
+ if hasattr(self, 'sum_duplicates'):
33
+ self.sum_duplicates()
34
+ return self.data
35
+
36
+ def __abs__(self):
37
+ return self._with_data(abs(self._deduped_data()))
38
+
39
+ def __round__(self, ndigits=0):
40
+ return self._with_data(np.around(self._deduped_data(), decimals=ndigits))
41
+
42
+ def _real(self):
43
+ return self._with_data(self.data.real)
44
+
45
+ def _imag(self):
46
+ return self._with_data(self.data.imag)
47
+
48
+ def __neg__(self):
49
+ if self.dtype.kind == 'b':
50
+ raise NotImplementedError('negating a boolean sparse array is not '
51
+ 'supported')
52
+ return self._with_data(-self.data)
53
+
54
+ def __imul__(self, other): # self *= other
55
+ if isscalarlike(other):
56
+ self.data *= other
57
+ return self
58
+ else:
59
+ return NotImplemented
60
+
61
+ def __itruediv__(self, other): # self /= other
62
+ if isscalarlike(other):
63
+ recip = 1.0 / other
64
+ self.data *= recip
65
+ return self
66
+ else:
67
+ return NotImplemented
68
+
69
+ def astype(self, dtype, casting='unsafe', copy=True):
70
+ dtype = np.dtype(dtype)
71
+ if self.dtype != dtype:
72
+ matrix = self._with_data(
73
+ self.data.astype(dtype, casting=casting, copy=True),
74
+ copy=True
75
+ )
76
+ return matrix._with_data(matrix._deduped_data(), copy=False)
77
+ elif copy:
78
+ return self.copy()
79
+ else:
80
+ return self
81
+
82
+ astype.__doc__ = _spbase.astype.__doc__
83
+
84
+ def conjugate(self, copy=True):
85
+ if np.issubdtype(self.dtype, np.complexfloating):
86
+ return self._with_data(self.data.conjugate(), copy=copy)
87
+ elif copy:
88
+ return self.copy()
89
+ else:
90
+ return self
91
+
92
+ conjugate.__doc__ = _spbase.conjugate.__doc__
93
+
94
+ def copy(self):
95
+ return self._with_data(self.data.copy(), copy=True)
96
+
97
+ copy.__doc__ = _spbase.copy.__doc__
98
+
99
+ def count_nonzero(self):
100
+ return np.count_nonzero(self._deduped_data())
101
+
102
+ count_nonzero.__doc__ = _spbase.count_nonzero.__doc__
103
+
104
+ def power(self, n, dtype=None):
105
+ """
106
+ This function performs element-wise power.
107
+
108
+ Parameters
109
+ ----------
110
+ n : scalar
111
+ n is a non-zero scalar (nonzero avoids dense ones creation)
112
+ If zero power is desired, special case it to use `np.ones`
113
+
114
+ dtype : If dtype is not specified, the current dtype will be preserved.
115
+
116
+ Raises
117
+ ------
118
+ NotImplementedError : if n is a zero scalar
119
+ If zero power is desired, special case it to use
120
+ `np.ones(A.shape, dtype=A.dtype)`
121
+ """
122
+ if not isscalarlike(n):
123
+ raise NotImplementedError("input is not scalar")
124
+ if not n:
125
+ raise NotImplementedError(
126
+ "zero power is not supported as it would densify the matrix.\n"
127
+ "Use `np.ones(A.shape, dtype=A.dtype)` for this case."
128
+ )
129
+
130
+ data = self._deduped_data()
131
+ if dtype is not None:
132
+ data = data.astype(dtype)
133
+ return self._with_data(data ** n)
134
+
135
+ ###########################
136
+ # Multiplication handlers #
137
+ ###########################
138
+
139
+ def _mul_scalar(self, other):
140
+ return self._with_data(self.data * other)
141
+
142
+
143
+ # Add the numpy unary ufuncs for which func(0) = 0 to _data_matrix.
144
+ for npfunc in _ufuncs_with_fixed_point_at_zero:
145
+ name = npfunc.__name__
146
+
147
+ def _create_method(op):
148
+ def method(self):
149
+ result = op(self._deduped_data())
150
+ return self._with_data(result, copy=True)
151
+
152
+ method.__doc__ = (f"Element-wise {name}.\n\n"
153
+ f"See `numpy.{name}` for more information.")
154
+ method.__name__ = name
155
+
156
+ return method
157
+
158
+ setattr(_data_matrix, name, _create_method(npfunc))
159
+
160
+
161
+ def _find_missing_index(ind, n):
162
+ for k, a in enumerate(ind):
163
+ if k != a:
164
+ return k
165
+
166
+ k += 1
167
+ if k < n:
168
+ return k
169
+ else:
170
+ return -1
171
+
172
+
173
+ class _minmax_mixin:
174
+ """Mixin for min and max methods.
175
+
176
+ These are not implemented for dia_matrix, hence the separate class.
177
+ """
178
+
179
+ def _min_or_max_axis(self, axis, min_or_max):
180
+ N = self.shape[axis]
181
+ if N == 0:
182
+ raise ValueError("zero-size array to reduction operation")
183
+ M = self.shape[1 - axis]
184
+ idx_dtype = self._get_index_dtype(maxval=M)
185
+
186
+ mat = self.tocsc() if axis == 0 else self.tocsr()
187
+ mat.sum_duplicates()
188
+
189
+ major_index, value = mat._minor_reduce(min_or_max)
190
+ not_full = np.diff(mat.indptr)[major_index] < N
191
+ value[not_full] = min_or_max(value[not_full], 0)
192
+
193
+ mask = value != 0
194
+ major_index = np.compress(mask, major_index)
195
+ value = np.compress(mask, value)
196
+
197
+ if axis == 0:
198
+ return self._coo_container(
199
+ (value, (np.zeros(len(value), dtype=idx_dtype), major_index)),
200
+ dtype=self.dtype, shape=(1, M)
201
+ )
202
+ else:
203
+ return self._coo_container(
204
+ (value, (major_index, np.zeros(len(value), dtype=idx_dtype))),
205
+ dtype=self.dtype, shape=(M, 1)
206
+ )
207
+
208
+ def _min_or_max(self, axis, out, min_or_max):
209
+ if out is not None:
210
+ raise ValueError("Sparse arrays do not support an 'out' parameter.")
211
+
212
+ validateaxis(axis)
213
+ if self.ndim == 1:
214
+ if axis not in (None, 0, -1):
215
+ raise ValueError("axis out of range")
216
+ axis = None # avoid calling special axis case. no impact on 1d
217
+
218
+ if axis is None:
219
+ if 0 in self.shape:
220
+ raise ValueError("zero-size array to reduction operation")
221
+
222
+ zero = self.dtype.type(0)
223
+ if self.nnz == 0:
224
+ return zero
225
+ m = min_or_max.reduce(self._deduped_data().ravel())
226
+ if self.nnz != np.prod(self.shape):
227
+ m = min_or_max(zero, m)
228
+ return m
229
+
230
+ if axis < 0:
231
+ axis += 2
232
+
233
+ if (axis == 0) or (axis == 1):
234
+ return self._min_or_max_axis(axis, min_or_max)
235
+ else:
236
+ raise ValueError("axis out of range")
237
+
238
+ def _arg_min_or_max_axis(self, axis, argmin_or_argmax, compare):
239
+ if self.shape[axis] == 0:
240
+ raise ValueError("Cannot apply the operation along a zero-sized dimension.")
241
+
242
+ if axis < 0:
243
+ axis += 2
244
+
245
+ zero = self.dtype.type(0)
246
+
247
+ mat = self.tocsc() if axis == 0 else self.tocsr()
248
+ mat.sum_duplicates()
249
+
250
+ ret_size, line_size = mat._swap(mat.shape)
251
+ ret = np.zeros(ret_size, dtype=int)
252
+
253
+ nz_lines, = np.nonzero(np.diff(mat.indptr))
254
+ for i in nz_lines:
255
+ p, q = mat.indptr[i:i + 2]
256
+ data = mat.data[p:q]
257
+ indices = mat.indices[p:q]
258
+ extreme_index = argmin_or_argmax(data)
259
+ extreme_value = data[extreme_index]
260
+ if compare(extreme_value, zero) or q - p == line_size:
261
+ ret[i] = indices[extreme_index]
262
+ else:
263
+ zero_ind = _find_missing_index(indices, line_size)
264
+ if extreme_value == zero:
265
+ ret[i] = min(extreme_index, zero_ind)
266
+ else:
267
+ ret[i] = zero_ind
268
+
269
+ if axis == 1:
270
+ ret = ret.reshape(-1, 1)
271
+
272
+ return self._ascontainer(ret)
273
+
274
+ def _arg_min_or_max(self, axis, out, argmin_or_argmax, compare):
275
+ if out is not None:
276
+ raise ValueError("Sparse types do not support an 'out' parameter.")
277
+
278
+ validateaxis(axis)
279
+
280
+ if self.ndim == 1:
281
+ if axis not in (None, 0, -1):
282
+ raise ValueError("axis out of range")
283
+ axis = None # avoid calling special axis case. no impact on 1d
284
+
285
+ if axis is not None:
286
+ return self._arg_min_or_max_axis(axis, argmin_or_argmax, compare)
287
+
288
+ if 0 in self.shape:
289
+ raise ValueError("Cannot apply the operation to an empty matrix.")
290
+
291
+ if self.nnz == 0:
292
+ return 0
293
+
294
+ zero = self.dtype.type(0)
295
+ mat = self.tocoo()
296
+ # Convert to canonical form: no duplicates, sorted indices.
297
+ mat.sum_duplicates()
298
+ extreme_index = argmin_or_argmax(mat.data)
299
+ extreme_value = mat.data[extreme_index]
300
+ num_col = mat.shape[-1]
301
+
302
+ # If the min value is less than zero, or max is greater than zero,
303
+ # then we do not need to worry about implicit zeros.
304
+ if compare(extreme_value, zero):
305
+ # cast to Python int to avoid overflow and RuntimeError
306
+ return int(mat.row[extreme_index]) * num_col + int(mat.col[extreme_index])
307
+
308
+ # Cheap test for the rare case where we have no implicit zeros.
309
+ size = np.prod(self.shape)
310
+ if size == mat.nnz:
311
+ return int(mat.row[extreme_index]) * num_col + int(mat.col[extreme_index])
312
+
313
+ # At this stage, any implicit zero could be the min or max value.
314
+ # After sum_duplicates(), the `row` and `col` arrays are guaranteed to
315
+ # be sorted in C-order, which means the linearized indices are sorted.
316
+ linear_indices = mat.row * num_col + mat.col
317
+ first_implicit_zero_index = _find_missing_index(linear_indices, size)
318
+ if extreme_value == zero:
319
+ return min(first_implicit_zero_index, extreme_index)
320
+ return first_implicit_zero_index
321
+
322
+ def max(self, axis=None, out=None):
323
+ """
324
+ Return the maximum of the array/matrix or maximum along an axis.
325
+ This takes all elements into account, not just the non-zero ones.
326
+
327
+ Parameters
328
+ ----------
329
+ axis : {-2, -1, 0, 1, None} optional
330
+ Axis along which the sum is computed. The default is to
331
+ compute the maximum over all elements, returning
332
+ a scalar (i.e., `axis` = `None`).
333
+
334
+ out : None, optional
335
+ This argument is in the signature *solely* for NumPy
336
+ compatibility reasons. Do not pass in anything except
337
+ for the default value, as this argument is not used.
338
+
339
+ Returns
340
+ -------
341
+ amax : coo_matrix or scalar
342
+ Maximum of `a`. If `axis` is None, the result is a scalar value.
343
+ If `axis` is given, the result is a sparse.coo_matrix of dimension
344
+ ``a.ndim - 1``.
345
+
346
+ See Also
347
+ --------
348
+ min : The minimum value of a sparse array/matrix along a given axis.
349
+ numpy.matrix.max : NumPy's implementation of 'max' for matrices
350
+
351
+ """
352
+ return self._min_or_max(axis, out, np.maximum)
353
+
354
+ def min(self, axis=None, out=None):
355
+ """
356
+ Return the minimum of the array/matrix or maximum along an axis.
357
+ This takes all elements into account, not just the non-zero ones.
358
+
359
+ Parameters
360
+ ----------
361
+ axis : {-2, -1, 0, 1, None} optional
362
+ Axis along which the sum is computed. The default is to
363
+ compute the minimum over all elements, returning
364
+ a scalar (i.e., `axis` = `None`).
365
+
366
+ out : None, optional
367
+ This argument is in the signature *solely* for NumPy
368
+ compatibility reasons. Do not pass in anything except for
369
+ the default value, as this argument is not used.
370
+
371
+ Returns
372
+ -------
373
+ amin : coo_matrix or scalar
374
+ Minimum of `a`. If `axis` is None, the result is a scalar value.
375
+ If `axis` is given, the result is a sparse.coo_matrix of dimension
376
+ ``a.ndim - 1``.
377
+
378
+ See Also
379
+ --------
380
+ max : The maximum value of a sparse array/matrix along a given axis.
381
+ numpy.matrix.min : NumPy's implementation of 'min' for matrices
382
+
383
+ """
384
+ return self._min_or_max(axis, out, np.minimum)
385
+
386
+ def nanmax(self, axis=None, out=None):
387
+ """
388
+ Return the maximum of the array/matrix or maximum along an axis, ignoring any
389
+ NaNs. This takes all elements into account, not just the non-zero
390
+ ones.
391
+
392
+ .. versionadded:: 1.11.0
393
+
394
+ Parameters
395
+ ----------
396
+ axis : {-2, -1, 0, 1, None} optional
397
+ Axis along which the maximum is computed. The default is to
398
+ compute the maximum over all elements, returning
399
+ a scalar (i.e., `axis` = `None`).
400
+
401
+ out : None, optional
402
+ This argument is in the signature *solely* for NumPy
403
+ compatibility reasons. Do not pass in anything except
404
+ for the default value, as this argument is not used.
405
+
406
+ Returns
407
+ -------
408
+ amax : coo_matrix or scalar
409
+ Maximum of `a`. If `axis` is None, the result is a scalar value.
410
+ If `axis` is given, the result is a sparse.coo_matrix of dimension
411
+ ``a.ndim - 1``.
412
+
413
+ See Also
414
+ --------
415
+ nanmin : The minimum value of a sparse array/matrix along a given axis,
416
+ ignoring NaNs.
417
+ max : The maximum value of a sparse array/matrix along a given axis,
418
+ propagating NaNs.
419
+ numpy.nanmax : NumPy's implementation of 'nanmax'.
420
+
421
+ """
422
+ return self._min_or_max(axis, out, np.fmax)
423
+
424
+ def nanmin(self, axis=None, out=None):
425
+ """
426
+ Return the minimum of the array/matrix or minimum along an axis, ignoring any
427
+ NaNs. This takes all elements into account, not just the non-zero
428
+ ones.
429
+
430
+ .. versionadded:: 1.11.0
431
+
432
+ Parameters
433
+ ----------
434
+ axis : {-2, -1, 0, 1, None} optional
435
+ Axis along which the minimum is computed. The default is to
436
+ compute the minimum over all elements, returning
437
+ a scalar (i.e., `axis` = `None`).
438
+
439
+ out : None, optional
440
+ This argument is in the signature *solely* for NumPy
441
+ compatibility reasons. Do not pass in anything except for
442
+ the default value, as this argument is not used.
443
+
444
+ Returns
445
+ -------
446
+ amin : coo_matrix or scalar
447
+ Minimum of `a`. If `axis` is None, the result is a scalar value.
448
+ If `axis` is given, the result is a sparse.coo_matrix of dimension
449
+ ``a.ndim - 1``.
450
+
451
+ See Also
452
+ --------
453
+ nanmax : The maximum value of a sparse array/matrix along a given axis,
454
+ ignoring NaNs.
455
+ min : The minimum value of a sparse array/matrix along a given axis,
456
+ propagating NaNs.
457
+ numpy.nanmin : NumPy's implementation of 'nanmin'.
458
+
459
+ """
460
+ return self._min_or_max(axis, out, np.fmin)
461
+
462
+ def argmax(self, axis=None, out=None):
463
+ """Return indices of maximum elements along an axis.
464
+
465
+ Implicit zero elements are also taken into account. If there are
466
+ several maximum values, the index of the first occurrence is returned.
467
+
468
+ Parameters
469
+ ----------
470
+ axis : {-2, -1, 0, 1, None}, optional
471
+ Axis along which the argmax is computed. If None (default), index
472
+ of the maximum element in the flatten data is returned.
473
+ out : None, optional
474
+ This argument is in the signature *solely* for NumPy
475
+ compatibility reasons. Do not pass in anything except for
476
+ the default value, as this argument is not used.
477
+
478
+ Returns
479
+ -------
480
+ ind : numpy.matrix or int
481
+ Indices of maximum elements. If matrix, its size along `axis` is 1.
482
+ """
483
+ return self._arg_min_or_max(axis, out, np.argmax, np.greater)
484
+
485
+ def argmin(self, axis=None, out=None):
486
+ """Return indices of minimum elements along an axis.
487
+
488
+ Implicit zero elements are also taken into account. If there are
489
+ several minimum values, the index of the first occurrence is returned.
490
+
491
+ Parameters
492
+ ----------
493
+ axis : {-2, -1, 0, 1, None}, optional
494
+ Axis along which the argmin is computed. If None (default), index
495
+ of the minimum element in the flatten data is returned.
496
+ out : None, optional
497
+ This argument is in the signature *solely* for NumPy
498
+ compatibility reasons. Do not pass in anything except for
499
+ the default value, as this argument is not used.
500
+
501
+ Returns
502
+ -------
503
+ ind : numpy.matrix or int
504
+ Indices of minimum elements. If matrix, its size along `axis` is 1.
505
+ """
506
+ return self._arg_min_or_max(axis, out, np.argmin, np.less)
llmeval-env/lib/python3.10/site-packages/scipy/sparse/_sputils.py ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Utility functions for sparse matrix module
2
+ """
3
+
4
+ import sys
5
+ from typing import Any, Literal, Optional, Union
6
+ import operator
7
+ import numpy as np
8
+ from math import prod
9
+ import scipy.sparse as sp
10
+ from scipy._lib._util import np_long, np_ulong
11
+
12
+
13
+ __all__ = ['upcast', 'getdtype', 'getdata', 'isscalarlike', 'isintlike',
14
+ 'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype']
15
+
16
+ supported_dtypes = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc,
17
+ np.uintc, np_long, np_ulong, np.longlong, np.ulonglong,
18
+ np.float32, np.float64, np.longdouble,
19
+ np.complex64, np.complex128, np.clongdouble]
20
+
21
+ _upcast_memo = {}
22
+
23
+
24
+ def upcast(*args):
25
+ """Returns the nearest supported sparse dtype for the
26
+ combination of one or more types.
27
+
28
+ upcast(t0, t1, ..., tn) -> T where T is a supported dtype
29
+
30
+ Examples
31
+ --------
32
+ >>> from scipy.sparse._sputils import upcast
33
+ >>> upcast('int32')
34
+ <type 'numpy.int32'>
35
+ >>> upcast('bool')
36
+ <type 'numpy.bool_'>
37
+ >>> upcast('int32','float32')
38
+ <type 'numpy.float64'>
39
+ >>> upcast('bool',complex,float)
40
+ <type 'numpy.complex128'>
41
+
42
+ """
43
+
44
+ t = _upcast_memo.get(hash(args))
45
+ if t is not None:
46
+ return t
47
+
48
+ upcast = np.result_type(*args)
49
+
50
+ for t in supported_dtypes:
51
+ if np.can_cast(upcast, t):
52
+ _upcast_memo[hash(args)] = t
53
+ return t
54
+
55
+ raise TypeError(f'no supported conversion for types: {args!r}')
56
+
57
+
58
+ def upcast_char(*args):
59
+ """Same as `upcast` but taking dtype.char as input (faster)."""
60
+ t = _upcast_memo.get(args)
61
+ if t is not None:
62
+ return t
63
+ t = upcast(*map(np.dtype, args))
64
+ _upcast_memo[args] = t
65
+ return t
66
+
67
+
68
+ def upcast_scalar(dtype, scalar):
69
+ """Determine data type for binary operation between an array of
70
+ type `dtype` and a scalar.
71
+ """
72
+ return (np.array([0], dtype=dtype) * scalar).dtype
73
+
74
+
75
+ def downcast_intp_index(arr):
76
+ """
77
+ Down-cast index array to np.intp dtype if it is of a larger dtype.
78
+
79
+ Raise an error if the array contains a value that is too large for
80
+ intp.
81
+ """
82
+ if arr.dtype.itemsize > np.dtype(np.intp).itemsize:
83
+ if arr.size == 0:
84
+ return arr.astype(np.intp)
85
+ maxval = arr.max()
86
+ minval = arr.min()
87
+ if maxval > np.iinfo(np.intp).max or minval < np.iinfo(np.intp).min:
88
+ raise ValueError("Cannot deal with arrays with indices larger "
89
+ "than the machine maximum address size "
90
+ "(e.g. 64-bit indices on 32-bit machine).")
91
+ return arr.astype(np.intp)
92
+ return arr
93
+
94
+
95
+ def to_native(A):
96
+ """
97
+ Ensure that the data type of the NumPy array `A` has native byte order.
98
+
99
+ `A` must be a NumPy array. If the data type of `A` does not have native
100
+ byte order, a copy of `A` with a native byte order is returned. Otherwise
101
+ `A` is returned.
102
+ """
103
+ dt = A.dtype
104
+ if dt.isnative:
105
+ # Don't call `asarray()` if A is already native, to avoid unnecessarily
106
+ # creating a view of the input array.
107
+ return A
108
+ return np.asarray(A, dtype=dt.newbyteorder('native'))
109
+
110
+
111
+ def getdtype(dtype, a=None, default=None):
112
+ """Function used to simplify argument processing. If 'dtype' is not
113
+ specified (is None), returns a.dtype; otherwise returns a np.dtype
114
+ object created from the specified dtype argument. If 'dtype' and 'a'
115
+ are both None, construct a data type out of the 'default' parameter.
116
+ Furthermore, 'dtype' must be in 'allowed' set.
117
+ """
118
+ # TODO is this really what we want?
119
+ if dtype is None:
120
+ try:
121
+ newdtype = a.dtype
122
+ except AttributeError as e:
123
+ if default is not None:
124
+ newdtype = np.dtype(default)
125
+ else:
126
+ raise TypeError("could not interpret data type") from e
127
+ else:
128
+ newdtype = np.dtype(dtype)
129
+ if newdtype == np.object_:
130
+ raise ValueError(
131
+ "object dtype is not supported by sparse matrices"
132
+ )
133
+
134
+ return newdtype
135
+
136
+
137
+ def getdata(obj, dtype=None, copy=False) -> np.ndarray:
138
+ """
139
+ This is a wrapper of `np.array(obj, dtype=dtype, copy=copy)`
140
+ that will generate a warning if the result is an object array.
141
+ """
142
+ data = np.array(obj, dtype=dtype, copy=copy)
143
+ # Defer to getdtype for checking that the dtype is OK.
144
+ # This is called for the validation only; we don't need the return value.
145
+ getdtype(data.dtype)
146
+ return data
147
+
148
+
149
+ def get_index_dtype(arrays=(), maxval=None, check_contents=False):
150
+ """
151
+ Based on input (integer) arrays `a`, determine a suitable index data
152
+ type that can hold the data in the arrays.
153
+
154
+ Parameters
155
+ ----------
156
+ arrays : tuple of array_like
157
+ Input arrays whose types/contents to check
158
+ maxval : float, optional
159
+ Maximum value needed
160
+ check_contents : bool, optional
161
+ Whether to check the values in the arrays and not just their types.
162
+ Default: False (check only the types)
163
+
164
+ Returns
165
+ -------
166
+ dtype : dtype
167
+ Suitable index data type (int32 or int64)
168
+
169
+ """
170
+
171
+ int32min = np.int32(np.iinfo(np.int32).min)
172
+ int32max = np.int32(np.iinfo(np.int32).max)
173
+
174
+ # not using intc directly due to misinteractions with pythran
175
+ dtype = np.int32 if np.intc().itemsize == 4 else np.int64
176
+ if maxval is not None:
177
+ maxval = np.int64(maxval)
178
+ if maxval > int32max:
179
+ dtype = np.int64
180
+
181
+ if isinstance(arrays, np.ndarray):
182
+ arrays = (arrays,)
183
+
184
+ for arr in arrays:
185
+ arr = np.asarray(arr)
186
+ if not np.can_cast(arr.dtype, np.int32):
187
+ if check_contents:
188
+ if arr.size == 0:
189
+ # a bigger type not needed
190
+ continue
191
+ elif np.issubdtype(arr.dtype, np.integer):
192
+ maxval = arr.max()
193
+ minval = arr.min()
194
+ if minval >= int32min and maxval <= int32max:
195
+ # a bigger type not needed
196
+ continue
197
+
198
+ dtype = np.int64
199
+ break
200
+
201
+ return dtype
202
+
203
+
204
+ def get_sum_dtype(dtype: np.dtype) -> np.dtype:
205
+ """Mimic numpy's casting for np.sum"""
206
+ if dtype.kind == 'u' and np.can_cast(dtype, np.uint):
207
+ return np.uint
208
+ if np.can_cast(dtype, np.int_):
209
+ return np.int_
210
+ return dtype
211
+
212
+
213
+ def isscalarlike(x) -> bool:
214
+ """Is x either a scalar, an array scalar, or a 0-dim array?"""
215
+ return np.isscalar(x) or (isdense(x) and x.ndim == 0)
216
+
217
+
218
+ def isintlike(x) -> bool:
219
+ """Is x appropriate as an index into a sparse matrix? Returns True
220
+ if it can be cast safely to a machine int.
221
+ """
222
+ # Fast-path check to eliminate non-scalar values. operator.index would
223
+ # catch this case too, but the exception catching is slow.
224
+ if np.ndim(x) != 0:
225
+ return False
226
+ try:
227
+ operator.index(x)
228
+ except (TypeError, ValueError):
229
+ try:
230
+ loose_int = bool(int(x) == x)
231
+ except (TypeError, ValueError):
232
+ return False
233
+ if loose_int:
234
+ msg = "Inexact indices into sparse matrices are not allowed"
235
+ raise ValueError(msg)
236
+ return loose_int
237
+ return True
238
+
239
+
240
+ def isshape(x, nonneg=False, *, allow_1d=False) -> bool:
241
+ """Is x a valid tuple of dimensions?
242
+
243
+ If nonneg, also checks that the dimensions are non-negative.
244
+ If allow_1d, shapes of length 1 or 2 are allowed.
245
+ """
246
+ ndim = len(x)
247
+ if ndim != 2 and not (allow_1d and ndim == 1):
248
+ return False
249
+ for d in x:
250
+ if not isintlike(d):
251
+ return False
252
+ if nonneg and d < 0:
253
+ return False
254
+ return True
255
+
256
+
257
+ def issequence(t) -> bool:
258
+ return ((isinstance(t, (list, tuple)) and
259
+ (len(t) == 0 or np.isscalar(t[0]))) or
260
+ (isinstance(t, np.ndarray) and (t.ndim == 1)))
261
+
262
+
263
+ def ismatrix(t) -> bool:
264
+ return ((isinstance(t, (list, tuple)) and
265
+ len(t) > 0 and issequence(t[0])) or
266
+ (isinstance(t, np.ndarray) and t.ndim == 2))
267
+
268
+
269
+ def isdense(x) -> bool:
270
+ return isinstance(x, np.ndarray)
271
+
272
+
273
+ def validateaxis(axis) -> None:
274
+ if axis is None:
275
+ return
276
+ axis_type = type(axis)
277
+
278
+ # In NumPy, you can pass in tuples for 'axis', but they are
279
+ # not very useful for sparse matrices given their limited
280
+ # dimensions, so let's make it explicit that they are not
281
+ # allowed to be passed in
282
+ if axis_type == tuple:
283
+ raise TypeError("Tuples are not accepted for the 'axis' parameter. "
284
+ "Please pass in one of the following: "
285
+ "{-2, -1, 0, 1, None}.")
286
+
287
+ # If not a tuple, check that the provided axis is actually
288
+ # an integer and raise a TypeError similar to NumPy's
289
+ if not np.issubdtype(np.dtype(axis_type), np.integer):
290
+ raise TypeError(f"axis must be an integer, not {axis_type.__name__}")
291
+
292
+ if not (-2 <= axis <= 1):
293
+ raise ValueError("axis out of range")
294
+
295
+
296
+ def check_shape(args, current_shape=None, *, allow_1d=False) -> tuple[int, ...]:
297
+ """Imitate numpy.matrix handling of shape arguments
298
+
299
+ Parameters
300
+ ----------
301
+ args : array_like
302
+ Data structures providing information about the shape of the sparse array.
303
+ current_shape : tuple, optional
304
+ The current shape of the sparse array or matrix.
305
+ If None (default), the current shape will be inferred from args.
306
+ allow_1d : bool, optional
307
+ If True, then 1-D or 2-D arrays are accepted.
308
+ If False (default), then only 2-D arrays are accepted and an error is
309
+ raised otherwise.
310
+
311
+ Returns
312
+ -------
313
+ new_shape: tuple
314
+ The new shape after validation.
315
+ """
316
+ if len(args) == 0:
317
+ raise TypeError("function missing 1 required positional argument: "
318
+ "'shape'")
319
+ if len(args) == 1:
320
+ try:
321
+ shape_iter = iter(args[0])
322
+ except TypeError:
323
+ new_shape = (operator.index(args[0]), )
324
+ else:
325
+ new_shape = tuple(operator.index(arg) for arg in shape_iter)
326
+ else:
327
+ new_shape = tuple(operator.index(arg) for arg in args)
328
+
329
+ if current_shape is None:
330
+ if allow_1d:
331
+ if len(new_shape) not in (1, 2):
332
+ raise ValueError('shape must be a 1- or 2-tuple of positive '
333
+ 'integers')
334
+ elif len(new_shape) != 2:
335
+ raise ValueError('shape must be a 2-tuple of positive integers')
336
+ if any(d < 0 for d in new_shape):
337
+ raise ValueError("'shape' elements cannot be negative")
338
+ else:
339
+ # Check the current size only if needed
340
+ current_size = prod(current_shape)
341
+
342
+ # Check for negatives
343
+ negative_indexes = [i for i, x in enumerate(new_shape) if x < 0]
344
+ if not negative_indexes:
345
+ new_size = prod(new_shape)
346
+ if new_size != current_size:
347
+ raise ValueError('cannot reshape array of size {} into shape {}'
348
+ .format(current_size, new_shape))
349
+ elif len(negative_indexes) == 1:
350
+ skip = negative_indexes[0]
351
+ specified = prod(new_shape[:skip] + new_shape[skip+1:])
352
+ unspecified, remainder = divmod(current_size, specified)
353
+ if remainder != 0:
354
+ err_shape = tuple('newshape' if x < 0 else x for x in new_shape)
355
+ raise ValueError('cannot reshape array of size {} into shape {}'
356
+ ''.format(current_size, err_shape))
357
+ new_shape = new_shape[:skip] + (unspecified,) + new_shape[skip+1:]
358
+ else:
359
+ raise ValueError('can only specify one unknown dimension')
360
+
361
+ if len(new_shape) != 2 and not (allow_1d and len(new_shape) == 1):
362
+ raise ValueError('matrix shape must be two-dimensional')
363
+
364
+ return new_shape
365
+
366
+
367
+ def check_reshape_kwargs(kwargs):
368
+ """Unpack keyword arguments for reshape function.
369
+
370
+ This is useful because keyword arguments after star arguments are not
371
+ allowed in Python 2, but star keyword arguments are. This function unpacks
372
+ 'order' and 'copy' from the star keyword arguments (with defaults) and
373
+ throws an error for any remaining.
374
+ """
375
+
376
+ order = kwargs.pop('order', 'C')
377
+ copy = kwargs.pop('copy', False)
378
+ if kwargs: # Some unused kwargs remain
379
+ raise TypeError('reshape() got unexpected keywords arguments: {}'
380
+ .format(', '.join(kwargs.keys())))
381
+ return order, copy
382
+
383
+
384
+ def is_pydata_spmatrix(m) -> bool:
385
+ """
386
+ Check whether object is pydata/sparse matrix, avoiding importing the module.
387
+ """
388
+ base_cls = getattr(sys.modules.get('sparse'), 'SparseArray', None)
389
+ return base_cls is not None and isinstance(m, base_cls)
390
+
391
+
392
+ def convert_pydata_sparse_to_scipy(
393
+ arg: Any, target_format: Optional[Literal["csc", "csr"]] = None
394
+ ) -> Union[Any, "sp.spmatrix"]:
395
+ """
396
+ Convert a pydata/sparse array to scipy sparse matrix,
397
+ pass through anything else.
398
+ """
399
+ if is_pydata_spmatrix(arg):
400
+ arg = arg.to_scipy_sparse()
401
+ if target_format is not None:
402
+ arg = arg.asformat(target_format)
403
+ elif arg.format not in ("csc", "csr"):
404
+ arg = arg.tocsc()
405
+ return arg
406
+
407
+
408
+ ###############################################################################
409
+ # Wrappers for NumPy types that are deprecated
410
+
411
+ # Numpy versions of these functions raise deprecation warnings, the
412
+ # ones below do not.
413
+
414
+ def matrix(*args, **kwargs):
415
+ return np.array(*args, **kwargs).view(np.matrix)
416
+
417
+
418
+ def asmatrix(data, dtype=None):
419
+ if isinstance(data, np.matrix) and (dtype is None or data.dtype == dtype):
420
+ return data
421
+ return np.asarray(data, dtype=dtype).view(np.matrix)
422
+
423
+ ###############################################################################
424
+
425
+
426
+ def _todata(s) -> np.ndarray:
427
+ """Access nonzero values, possibly after summing duplicates.
428
+
429
+ Parameters
430
+ ----------
431
+ s : sparse array
432
+ Input sparse array.
433
+
434
+ Returns
435
+ -------
436
+ data: ndarray
437
+ Nonzero values of the array, with shape (s.nnz,)
438
+
439
+ """
440
+ if isinstance(s, sp._data._data_matrix):
441
+ return s._deduped_data()
442
+
443
+ if isinstance(s, sp.dok_array):
444
+ return np.fromiter(s.values(), dtype=s.dtype, count=s.nnz)
445
+
446
+ if isinstance(s, sp.lil_array):
447
+ data = np.empty(s.nnz, dtype=s.dtype)
448
+ sp._csparsetools.lil_flatten_to_array(s.data, data)
449
+ return data
450
+
451
+ return s.tocoo()._deduped_data()
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aden ADDED
Binary file (133 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Anadyr ADDED
Binary file (743 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aqtau ADDED
Binary file (606 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Aqtobe ADDED
Binary file (615 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Ashgabat ADDED
Binary file (375 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Atyrau ADDED
Binary file (616 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Bahrain ADDED
Binary file (152 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Baku ADDED
Binary file (744 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Bangkok ADDED
Binary file (152 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Barnaul ADDED
Binary file (753 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Beirut ADDED
Binary file (732 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Brunei ADDED
Binary file (320 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Choibalsan ADDED
Binary file (619 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Chongqing ADDED
Binary file (393 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Chungking ADDED
Binary file (393 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Damascus ADDED
Binary file (1.23 kB). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dhaka ADDED
Binary file (231 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dubai ADDED
Binary file (133 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Dushanbe ADDED
Binary file (366 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Famagusta ADDED
Binary file (940 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Gaza ADDED
Binary file (2.95 kB). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Hebron ADDED
Binary file (2.97 kB). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Ho_Chi_Minh ADDED
Binary file (236 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Hong_Kong ADDED
Binary file (775 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Irkutsk ADDED
Binary file (760 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Istanbul ADDED
Binary file (1.2 kB). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Jakarta ADDED
Binary file (248 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Jerusalem ADDED
Binary file (1.07 kB). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kabul ADDED
Binary file (159 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kamchatka ADDED
Binary file (727 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kashgar ADDED
Binary file (133 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kathmandu ADDED
Binary file (161 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Katmandu ADDED
Binary file (161 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Khandyga ADDED
Binary file (775 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kolkata ADDED
Binary file (220 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Krasnoyarsk ADDED
Binary file (741 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kuching ADDED
Binary file (320 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Kuwait ADDED
Binary file (133 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Magadan ADDED
Binary file (751 Bytes). View file
 
llmeval-env/lib/python3.10/site-packages/tzdata/zoneinfo/Asia/Muscat ADDED
Binary file (133 Bytes). View file