DAMASK_EICMD/python/tests/test_LoadcaseGrid.py

23 lines
812 B
Python
Raw Normal View History

2023-03-27 23:03:11 +05:30
import numpy as np
from numpy import ma
from damask import LoadcaseGrid
class TestGridConfig:
def test_dumper(self):
a = ma.MaskedArray(np.arange(3,dtype=float),mask=[0,1,0])
assert str(LoadcaseGrid({'a':a})) == 'a: [0.0, x, 2.0]\n'
assert str(LoadcaseGrid({'a':a.astype(int)})) == 'a: [0, x, 2]\n'
assert str(LoadcaseGrid({'a':a.data})) == 'a: [0.0, 1.0, 2.0]\n'
def test_init(self):
assert LoadcaseGrid() \
== LoadcaseGrid({'solver':{},
'loadstep':[],
})
assert LoadcaseGrid(solver={'mechanical':'spectral_basic'}) \
== LoadcaseGrid({'solver':{'mechanical':'spectral_basic'},
'loadstep':[],
})