In [2]:
%pylab inline
import numpy as np
import ndap
reload(ndap)
subject = np.ones((3,4,5))
plotter = ndap.NDArrayPlotter(subject)
(fig, ax) = plotter.render(azim=-45)
In [30]:
subject = np.ones((3,4,5))
axis = 0 # Axis to use for inner-loop
ndim = subject.ndim-1 # Number of dimensions in array
shape = [0]*ndim
other_dim = 0
for dim in xrange(subject.ndim):
if dim == axis:
continue
shape[other_dim] = subject.shape[dim]
other_dim += 1
nelements = 1 # How many elements are there
for dim in xrange(ndim):
nelements *= shape[dim]
weight = [0]*ndim # "weight" of each dimension
acc = 1
for dim in range(0, ndim)[::-1]:
weight[dim] = acc
acc *= shape[dim]
eidx = 0
while(eidx<nelements):
coord = [0]*ndim
for dim in xrange(0, ndim):
coord[dim] = (eidx / weight[dim]) % shape[dim]
print coord
eidx +=1
print axis, ndim, shape, nelements, weight, nchunks, chunksize
In [11]:
In [ ]: