corrected add_primitive test
This commit is contained in:
parent
4bf3b92609
commit
752d6f773b
|
@ -45,10 +45,7 @@ class TestGeom:
|
||||||
old = default.get_microstructure()
|
old = default.get_microstructure()
|
||||||
new = np.random.randint(200,size=default.grid)
|
new = np.random.randint(200,size=default.grid)
|
||||||
default.set_microstructure(np.ma.MaskedArray(new,np.full_like(new,masked)))
|
default.set_microstructure(np.ma.MaskedArray(new,np.full_like(new,masked)))
|
||||||
if masked:
|
assert np.all(default.microstructure==(old if masked else new))
|
||||||
assert np.all(default.microstructure==old)
|
|
||||||
else:
|
|
||||||
assert np.all(default.microstructure==new)
|
|
||||||
|
|
||||||
|
|
||||||
def test_write_read_str(self,default,tmpdir):
|
def test_write_read_str(self,default,tmpdir):
|
||||||
|
@ -192,19 +189,19 @@ class TestGeom:
|
||||||
e = default.grid
|
e = default.grid
|
||||||
assert np.all(modified.microstructure[:e[0],:e[1],:e[2]] == default.microstructure)
|
assert np.all(modified.microstructure[:e[0],:e[1],:e[2]] == default.microstructure)
|
||||||
|
|
||||||
@pytest.mark.parametrize('center',[np.random.random(3)*.5,
|
@pytest.mark.parametrize('center1,center2',[(np.random.random(3)*.5,np.random.random(3)),
|
||||||
np.random.randint(4,10,(3))])
|
(np.random.randint(4,8,(3)),np.random.randint(9,12,(3)))])
|
||||||
@pytest.mark.parametrize('diameter',[np.random.random(3)*.5,
|
@pytest.mark.parametrize('diameter',[np.random.random(3)*.5,
|
||||||
np.random.randint(4,10,(3))])
|
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."""
|
"""Same volume fraction for periodic microstructures and different center."""
|
||||||
o = np.random.random(3)-.5
|
o = np.random.random(3)-.5
|
||||||
g = np.random.randint(8,32,(3))
|
g = np.random.randint(8,32,(3))
|
||||||
s = np.random.random(3)+.5
|
s = np.random.random(3)+.5
|
||||||
G_1 = Geom(np.ones(g,'i'),s,o)
|
G_1 = Geom(np.ones(g,'i'),s,o)
|
||||||
G_2 = Geom(np.ones(g,'i'),s,o)
|
G_2 = Geom(np.ones(g,'i'),s,o)
|
||||||
G_1.add_primitive(diameter,center,1)
|
G_1.add_primitive(diameter,center1,1)
|
||||||
G_2.add_primitive(diameter,center,1)
|
G_2.add_primitive(diameter,center2,1)
|
||||||
assert np.count_nonzero(G_1.microstructure!=2) == np.count_nonzero(G_2.microstructure!=2)
|
assert np.count_nonzero(G_1.microstructure!=2) == np.count_nonzero(G_2.microstructure!=2)
|
||||||
|
|
||||||
@pytest.mark.parametrize('trigger',[[1],[]])
|
@pytest.mark.parametrize('trigger',[[1],[]])
|
||||||
|
|
Loading…
Reference in New Issue