corrected add_primitive test

This commit is contained in:
Philip Eisenlohr 2020-08-09 23:14:32 +02:00
parent 4bf3b92609
commit 752d6f773b
1 changed files with 23 additions and 26 deletions

View File

@ -45,10 +45,7 @@ class TestGeom:
old = default.get_microstructure()
new = np.random.randint(200,size=default.grid)
default.set_microstructure(np.ma.MaskedArray(new,np.full_like(new,masked)))
if masked:
assert np.all(default.microstructure==old)
else:
assert np.all(default.microstructure==new)
assert np.all(default.microstructure==(old if masked else new))
def test_write_read_str(self,default,tmpdir):
@ -192,19 +189,19 @@ class TestGeom:
e = default.grid
assert np.all(modified.microstructure[:e[0],:e[1],:e[2]] == default.microstructure)
@pytest.mark.parametrize('center',[np.random.random(3)*.5,
np.random.randint(4,10,(3))])
@pytest.mark.parametrize('center1,center2',[(np.random.random(3)*.5,np.random.random(3)),
(np.random.randint(4,8,(3)),np.random.randint(9,12,(3)))])
@pytest.mark.parametrize('diameter',[np.random.random(3)*.5,
np.random.randint(4,10,(3))])
def test_add_primitive(self,diameter,center):
def test_add_primitive(self,diameter,center1,center2):
"""Same volume fraction for periodic microstructures and different center."""
o = np.random.random(3)-.5
g = np.random.randint(8,32,(3))
s = np.random.random(3)+.5
G_1 = Geom(np.ones(g,'i'),s,o)
G_2 = Geom(np.ones(g,'i'),s,o)
G_1.add_primitive(diameter,center,1)
G_2.add_primitive(diameter,center,1)
G_1.add_primitive(diameter,center1,1)
G_2.add_primitive(diameter,center2,1)
assert np.count_nonzero(G_1.microstructure!=2) == np.count_nonzero(G_2.microstructure!=2)
@pytest.mark.parametrize('trigger',[[1],[]])