Skip to content

Commit c0aae6b

Browse files
committed
MAINT: only remove internal use in np.block
1 parent dff17a4 commit c0aae6b

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

numpy/core/shape_base.py

+12-19
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717
overrides.array_function_dispatch, module='numpy')
1818

1919

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-
2720
def _atleast_1d_dispatcher(*arys):
2821
return arys
2922

@@ -212,13 +205,6 @@ def atleast_3d(*arys):
212205
return res
213206

214207

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-
222208
def _arrays_for_stack_dispatcher(arrays, stacklevel=4):
223209
if not hasattr(arrays, '__getitem__') and hasattr(arrays, '__iter__'):
224210
warnings.warn('arrays to stack must be passed as a "sequence" type '
@@ -287,7 +273,7 @@ def vstack(tup):
287273
[4]])
288274
289275
"""
290-
return _concatenate([_atleast_2d(_m) for _m in tup], 0)
276+
return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
291277

292278

293279
@array_function_dispatch(_vhstack_dispatcher)
@@ -338,12 +324,12 @@ def hstack(tup):
338324
[3, 4]])
339325
340326
"""
341-
arrs = [_atleast_1d(_m) for _m in tup]
327+
arrs = [atleast_1d(_m) for _m in tup]
342328
# As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
343329
if arrs and arrs[0].ndim == 1:
344-
return _concatenate(arrs, 0)
330+
return _nx.concatenate(arrs, 0)
345331
else:
346-
return _concatenate(arrs, 1)
332+
return _nx.concatenate(arrs, 1)
347333

348334

349335
def _stack_dispatcher(arrays, axis=None, out=None):
@@ -427,7 +413,14 @@ def stack(arrays, axis=0, out=None):
427413

428414
sl = (slice(None),) * axis + (_nx.newaxis,)
429415
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)
431424

432425

433426
def _block_format_index(index):

0 commit comments

Comments
 (0)