I would like to have this code:
chains3D = [[] for k in range(colors)]
def addr(x,y,z): return x + (nx) * (y + (ny) * (z))
for x in range(nx):
for y in range(ny):
for z in range(nz):
if (image[x,y,z] == background):
chains3D[1].append(addr(x,y,z))
else:
chains3D[0].append(addr(x,y,z))
in something like this:
chains2D = [[] for k in range(colors)]
def addr(x,y): return x + (nx) * y
for x in range(nx):
for y in range(ny):
if (image[x,y,0] == background):
chains2D[1].append(addr(x,y))
else:
chains2D[0].append(addr(x,y))
Ok I've solved the code issue, but now I've this error:
IndexError Traceback (most recent call last)
<ipython-input-5-6a7d44bd72b7> in <module>()
213 objectBoundaryChain = larBoundaryChain(partial_3,chains2D[1])
214 b2cells = csrChainToCellList(objectBoundaryChain)
--> 215 sup_cell_boundary = MKPOLS((V,[FV[f] for f in b2cells]))
216
217 # remove the (local) boundary (shared with the piece boundary) from the quotient cell
/Users/Fabio/larpy/lar.pyc in MKPOLS(model)
101 """
102 V, FV = model
--> 103 pols = [MKPOL([[V[v] for v in f],[range(1,len(f)+1)], None]) for f in FV]
104 return pols
105
IndexError: list index out of range
I don't know why f is equals to the last number of b2cells, instead of the first, but maybe this is not the real problem that produce this error
It is not entirely clear what you're trying to do and what is not working, but something that seemed weird is that you transformed:
return x + (nx) * (y + (ny) * (z))
into:
return x + (nx) * (y + (ny))
Shouldn't it have been:
return x + (nx) * y
instead? Considering that nz doesn't appear in your 3D version, ny shouldn't appear in the 2D one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.