0-based material indices
This commit is contained in:
parent
c3a413e023
commit
5f03e8cf8f
|
@ -687,10 +687,10 @@ class Geom:
|
|||
|
||||
|
||||
def renumber(self):
|
||||
"""Renumber sorted material indices to 1,...,N."""
|
||||
"""Renumber sorted material indices to 0,...,N-1."""
|
||||
renumbered = np.empty(self.grid,dtype=self.material.dtype)
|
||||
for i, oldID in enumerate(np.unique(self.material)):
|
||||
renumbered = np.where(self.material == oldID, i+1, renumbered)
|
||||
renumbered = np.where(self.material == oldID, i, renumbered)
|
||||
|
||||
return Geom(material = renumbered,
|
||||
size = self.size,
|
||||
|
|
|
@ -176,6 +176,7 @@ class TestGeom:
|
|||
material = default.material.copy()
|
||||
for m in np.unique(material):
|
||||
material[material==m] = material.max() + np.random.randint(1,30)
|
||||
default.material -= 1
|
||||
modified = Geom(material,
|
||||
default.size,
|
||||
default.origin)
|
||||
|
|
Loading…
Reference in New Issue