Merge remote-tracking branch 'origin/homogeneous_ConfigMaterial.from_table' into development
This commit is contained in:
commit
fce116aa8b
|
@ -69,8 +69,8 @@ class ConfigMaterial(Config):
|
||||||
_,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0)
|
_,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0)
|
||||||
|
|
||||||
idx = np.sort(idx)
|
idx = np.sort(idx)
|
||||||
constituents_ = {k:v[idx].squeeze() for k,v in constituents_.items()}
|
constituents_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in constituents_.items()}
|
||||||
kwargs_ = {k:v[idx].squeeze() for k,v in kwargs_.items()}
|
kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()}
|
||||||
|
|
||||||
return ConfigMaterial().material_add(constituents_,**kwargs_)
|
return ConfigMaterial().material_add(constituents_,**kwargs_)
|
||||||
|
|
||||||
|
@ -268,6 +268,7 @@ class ConfigMaterial(Config):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _constituents(N=1,**kwargs):
|
def _constituents(N=1,**kwargs):
|
||||||
"""Construct list of constituents."""
|
"""Construct list of constituents."""
|
||||||
|
N_material=1
|
||||||
for v in kwargs.values():
|
for v in kwargs.values():
|
||||||
if hasattr(v,'__len__') and not isinstance(v,str): N_material = len(v)
|
if hasattr(v,'__len__') and not isinstance(v,str): N_material = len(v)
|
||||||
|
|
||||||
|
|
|
@ -87,3 +87,7 @@ class TestConfigMaterial:
|
||||||
c = m['constituents'][0]
|
c = m['constituents'][0]
|
||||||
assert m['c'] == 1 and c['b'] == 0 and c['a'] == [i,1]
|
assert m['c'] == 1 and c['b'] == 0 and c['a'] == [i,1]
|
||||||
|
|
||||||
|
def test__constituents(self):
|
||||||
|
c = ConfigMaterial._constituents(c=1,v=[2,3])
|
||||||
|
assert c[0][0]['c'] == c[1][0]['c'] == 1
|
||||||
|
assert c[0][0]['v'] == c[1][0]['v'] -1 ==2
|
||||||
|
|
Loading…
Reference in New Issue