MCPcopy Create free account
hub / github.com/numpy/numpy / _leading_trailing

Function _leading_trailing

numpy/core/arrayprint.py:369–386  ·  view source on GitHub ↗

Keep only the N-D corners (leading and trailing edges) of an array. Should be passed a base-class ndarray, since it makes no guarantees about preserving subclasses.

(a, edgeitems, index=())

Source from the content-addressed store, hash-verified

367
368
369def _leading_trailing(a, edgeitems, index=()):
370 """
371 Keep only the N-D corners (leading and trailing edges) of an array.
372
373 Should be passed a base-class ndarray, since it makes no guarantees about
374 preserving subclasses.
375 """
376 axis = len(index)
377 if axis == a.ndim:
378 return a[index]
379
380 if a.shape[axis] > 2*edgeitems:
381 return concatenate((
382 _leading_trailing(a, edgeitems, index + np.index_exp[ :edgeitems]),
383 _leading_trailing(a, edgeitems, index + np.index_exp[-edgeitems:])
384 ), axis=axis)
385 else:
386 return _leading_trailing(a, edgeitems, index + np.index_exp[:])
387
388
389def _object_format(o):

Callers 1

_array2stringFunction · 0.85

Calls 1

concatenateFunction · 0.70

Tested by

no test coverage detected