|
17 | 17 | overrides.array_function_dispatch, module='numpy')
|
18 | 18 |
|
19 | 19 |
|
20 |
| -# Internal functions that elimainate the overhead of repeated dispatch. |
21 |
| -# Use getattr to protect against __array_function__ being disabled. |
22 |
| -_size = getattr(_nx.size, '__wrapped__', _nx.size) |
23 |
| -_ndim = getattr(_nx.ndim, '__wrapped__', _nx.ndim) |
24 |
| -_concatenate = getattr(_nx.concatenate, '__wrapped__', _nx.concatenate) |
25 |
| - |
26 |
| - |
27 | 20 | def _atleast_1d_dispatcher(*arys):
|
28 | 21 | return arys
|
29 | 22 |
|
@@ -212,13 +205,6 @@ def atleast_3d(*arys):
|
212 | 205 | return res
|
213 | 206 |
|
214 | 207 |
|
215 |
| -# More aliases to undispatched functions. |
216 |
| -# Use getattr to protect against __array_function__ being disabled. |
217 |
| -_atleast_1d = getattr(atleast_1d, '__wrapped__', atleast_1d) |
218 |
| -_atleast_2d = getattr(atleast_2d, '__wrapped__', atleast_2d) |
219 |
| -_atleast_3d = getattr(atleast_3d, '__wrapped__', atleast_3d) |
220 |
| - |
221 |
| - |
222 | 208 | def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
|
223 | 209 | if not hasattr(arrays, '__getitem__') and hasattr(arrays, '__iter__'):
|
224 | 210 | warnings.warn('arrays to stack must be passed as a "sequence" type '
|
@@ -287,7 +273,7 @@ def vstack(tup):
|
287 | 273 | [4]])
|
288 | 274 |
|
289 | 275 | """
|
290 |
| - return _concatenate([_atleast_2d(_m) for _m in tup], 0) |
| 276 | + return _nx.concatenate([atleast_2d(_m) for _m in tup], 0) |
291 | 277 |
|
292 | 278 |
|
293 | 279 | @array_function_dispatch(_vhstack_dispatcher)
|
@@ -338,12 +324,12 @@ def hstack(tup):
|
338 | 324 | [3, 4]])
|
339 | 325 |
|
340 | 326 | """
|
341 |
| - arrs = [_atleast_1d(_m) for _m in tup] |
| 327 | + arrs = [atleast_1d(_m) for _m in tup] |
342 | 328 | # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
|
343 | 329 | if arrs and arrs[0].ndim == 1:
|
344 |
| - return _concatenate(arrs, 0) |
| 330 | + return _nx.concatenate(arrs, 0) |
345 | 331 | else:
|
346 |
| - return _concatenate(arrs, 1) |
| 332 | + return _nx.concatenate(arrs, 1) |
347 | 333 |
|
348 | 334 |
|
349 | 335 | def _stack_dispatcher(arrays, axis=None, out=None):
|
@@ -427,7 +413,14 @@ def stack(arrays, axis=0, out=None):
|
427 | 413 |
|
428 | 414 | sl = (slice(None),) * axis + (_nx.newaxis,)
|
429 | 415 | expanded_arrays = [arr[sl] for arr in arrays]
|
430 |
| - return _concatenate(expanded_arrays, axis=axis, out=out) |
| 416 | + return _nx.concatenate(expanded_arrays, axis=axis, out=out) |
| 417 | + |
| 418 | + |
| 419 | +# Internal functions to elimainate the overhead of repeated dispatch inside |
| 420 | +# np.block. Use getattr to protect against __array_function__ being disabled. |
| 421 | +_size = getattr(_nx.size, '__wrapped__', _nx.size) |
| 422 | +_ndim = getattr(_nx.ndim, '__wrapped__', _nx.ndim) |
| 423 | +_concatenate = getattr(_nx.concatenate, '__wrapped__', _nx.concatenate) |
431 | 424 |
|
432 | 425 |
|
433 | 426 | def _block_format_index(index):
|
|
0 commit comments