MCPcopy
hub / github.com/numpy/numpy / _leading_trailing

Function _leading_trailing

numpy/_core/arrayprint.py:438–455  ·  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

436
437
438def _leading_trailing(a, edgeitems, index=()):
439 """
440 Keep only the N-D corners (leading and trailing edges) of an array.
441
442 Should be passed a base-class ndarray, since it makes no guarantees about
443 preserving subclasses.
444 """
445 axis = len(index)
446 if axis == a.ndim:
447 return a[index]
448
449 if a.shape[axis] > 2 * edgeitems:
450 return concatenate((
451 _leading_trailing(a, edgeitems, index + np.index_exp[:edgeitems]),
452 _leading_trailing(a, edgeitems, index + np.index_exp[-edgeitems:])
453 ), axis=axis)
454 else:
455 return _leading_trailing(a, edgeitems, index + np.index_exp[:])
456
457
458def _object_format(o):

Callers 1

_array2stringFunction · 0.85

Calls 1

concatenateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…