I often end up trying to take a bunch of arrays and putting them in different dimensions as below,
x = x.reshape((x.size, 1, 1))
y = y.reshape((1, y.size, 1))
z = z.reshape((1, 1, z.size))
return x + y + z
I have two problems, I would like to do something like,
x = x.todim(0)
y = y.todim(1)
z = z.todim(2)
And achieve the same as above.
Also, I would like to do "tensor products" with different operators and have it be lazy evaluated because doing what I am doing often exploded the memory usage. But I do have a good reason for doing these kinds of things ... my insanity is justifiable.
EDIT:
Here is code I wrote to do it, but a built in would be nice is such exists
def todim(a, ndims, axis=0):
nshape = [a.shape[i-axis]
if i >= axis and (i-axis) < len(a.shape)
else 1
for i in range(ndims)]
return a.reshape(tuple(nshape))