fast
This commit is contained in:
parent
5f03e8cf8f
commit
b38a498197
|
@ -688,11 +688,9 @@ class Geom:
|
||||||
|
|
||||||
def renumber(self):
|
def renumber(self):
|
||||||
"""Renumber sorted material indices to 0,...,N-1."""
|
"""Renumber sorted material indices to 0,...,N-1."""
|
||||||
renumbered = np.empty(self.grid,dtype=self.material.dtype)
|
_,renumbered = np.unique(self.material,return_inverse=True)
|
||||||
for i, oldID in enumerate(np.unique(self.material)):
|
|
||||||
renumbered = np.where(self.material == oldID, i, renumbered)
|
|
||||||
|
|
||||||
return Geom(material = renumbered,
|
return Geom(material = renumbered.reshape(self.grid),
|
||||||
size = self.size,
|
size = self.size,
|
||||||
origin = self.origin,
|
origin = self.origin,
|
||||||
comments = self.comments+[util.execution_stamp('Geom','renumber')],
|
comments = self.comments+[util.execution_stamp('Geom','renumber')],
|
||||||
|
|
Loading…
Reference in New Issue