parent
98e0ef3881
commit
855bf124d3
|
@ -787,11 +787,14 @@ class Geom:
|
||||||
New material indices.
|
New material indices.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
substituted = self.material.copy()
|
mapper = dict(zip(from_material,to_material))
|
||||||
for from_ma,to_ma in zip(from_material,to_material):
|
|
||||||
substituted[self.material==from_ma] = to_ma
|
def mp(entry):
|
||||||
|
return mapper[entry] if entry in mapper else entry
|
||||||
|
|
||||||
|
mp = np.vectorize(mp)
|
||||||
|
|
||||||
return Geom(material = substituted,
|
return Geom(material = mp(self.material).reshape(self.grid),
|
||||||
size = self.size,
|
size = self.size,
|
||||||
origin = self.origin,
|
origin = self.origin,
|
||||||
comments = self.comments+[util.execution_stamp('Geom','substitute')],
|
comments = self.comments+[util.execution_stamp('Geom','substitute')],
|
||||||
|
|
|
@ -195,6 +195,13 @@ class TestGeom:
|
||||||
modified.substitute(np.arange(default.material.max())+1+offset,
|
modified.substitute(np.arange(default.material.max())+1+offset,
|
||||||
np.arange(default.material.max())+1))
|
np.arange(default.material.max())+1))
|
||||||
|
|
||||||
|
def test_substitute_invariant(self,default):
|
||||||
|
f = np.unique(default.material.flatten())[:np.random.randint(1,default.material.max())]
|
||||||
|
t = np.random.permutation(f)
|
||||||
|
modified = default.substitute(f,t)
|
||||||
|
assert np.array_equiv(t,f) or (not geom_equal(modified,default))
|
||||||
|
assert geom_equal(default, modified.substitute(t,f))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('axis_angle',[np.array([1,0,0,86.7]), np.array([0,1,0,90.4]), np.array([0,0,1,90]),
|
@pytest.mark.parametrize('axis_angle',[np.array([1,0,0,86.7]), np.array([0,1,0,90.4]), np.array([0,0,1,90]),
|
||||||
np.array([1,0,0,175]),np.array([0,-1,0,178]),np.array([0,0,1,180])])
|
np.array([1,0,0,175]),np.array([0,-1,0,178]),np.array([0,0,1,180])])
|
||||||
|
|
Loading…
Reference in New Issue