Just replaced the following code in jack/util/map.py's numpify function:
x_np = np.full(shape, pad, dtype)
dims = len(shape)
if dims == 0:
x_np=x
elif dims == 1:
x_np[0:shape[0]] = x
elif dims == 2:
for j, y in enumerate(x):
x_np[j, 0:len(y)] = [ys for ys in y]#this comprehension turns DynamicSubsampledList into a list
elif dims == 3:
for j, ys in enumerate(x):
for k, y in enumerate(ys):
x_np[j, k, 0:len(y)] = y
else:
raise (NotImplementedError)
# todo: extend to general case
pass
xs_np[key] = x_np
with the following recursive function - generalizes to dims > 3:
x_np = np.full(shape, pad, dtype)
nb_dims = len(shape)
if nb_dims == 0:
x_np = x
else:
def f(tensor, values):
t_shp = tensor.shape
if len(t_shp) > 1:
for _i, _values in enumerate(values):
f(tensor[_i], _values)
else:
tensor[0:len(values)] = [v for v in values]
f(x_np, x)
xs_np[key] = x_np
Just replaced the following code in
jack/util/map.py
'snumpify
function:with the following recursive function - generalizes to
dims > 3
:@tdmeeste @rockt in case it can be useful