def test_from_table(self): N = np.random.randint(3,10) a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])), np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2), np.ones(N*2), )).T t = Table(a,{'varying':1,'constant':4,'ones':1}) c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'ones'}) assert len(c['material']) == N for i,m in enumerate(c['material']): assert m['homogenization'] == 1 and (m['constituents'][0]['O'] == [1,0,1,1]).all()
def test_from_table(self): N = np.random.randint(3, 10) a = np.vstack((np.hstack((np.arange(N), np.arange(N)[::-1])), np.ones(N * 2), np.zeros(N * 2), np.ones(N * 2))).T t = Table(a, {'varying': 2, 'constant': 2}) c = ConfigMaterial.from_table(t, constituents={ 'a': 'varying', 'b': '1_constant' }, c='2_constant') assert len(c['material']) == N for i, m in enumerate(c['material']): c = m['constituents'][0] assert m['c'] == 1 and c['b'] == 0 and c['a'] == [i, 1]