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

Function expand_to

dali/test/python/test_audio_utils_librosa_ref.py:109–131  ·  view source on GitHub ↗
(x, *, ndim, axes)

Source from the content-addressed store, hash-verified

107
108
109def expand_to(x, *, ndim, axes):
110 # Force axes into a tuple
111
112 try:
113 axes = tuple(axes)
114 except TypeError:
115 axes = tuple([axes])
116
117 if len(axes) != x.ndim:
118 raise RuntimeError(
119 "Shape mismatch between axes={} and input x.shape={}".format(axes, x.shape)
120 )
121
122 if ndim < x.ndim:
123 raise RuntimeError(
124 "Cannot expand x.shape={} to fewer dimensions ndim={}".format(x.shape, ndim)
125 )
126
127 shape = [1] * ndim
128 for i, axi in enumerate(axes):
129 shape[axi] = x.shape[i]
130
131 return x.reshape(shape)
132
133
134def dtype_r2c(d, *, default=np.complex64):

Callers 1

stftFunction · 0.85

Calls 1

reshapeMethod · 0.45

Tested by

no test coverage detected