MCPcopy Create free account
hub / github.com/NVIDIA/DALI / pad_center

Function pad_center

dali/test/python/test_audio_utils_librosa_ref.py:91–106  ·  view source on GitHub ↗
(data, *, size, axis=-1, **kwargs)

Source from the content-addressed store, hash-verified

89
90
91def pad_center(data, *, size, axis=-1, **kwargs):
92 kwargs.setdefault("mode", "constant")
93
94 n = data.shape[axis]
95
96 lpad = int((size - n) // 2)
97
98 lengths = [(0, 0)] * data.ndim
99 lengths[axis] = (lpad, int(size - n - lpad))
100
101 if lpad < 0:
102 raise RuntimeError(
103 ("Target size ({:d}) must be " "at least input size ({:d})").format(size, n)
104 )
105
106 return np.pad(data, lengths, **kwargs)
107
108
109def expand_to(x, *, ndim, axes):

Callers 1

stftFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected