avoid invalid DADF5
This commit is contained in:
parent
b79fc5c097
commit
b13e7e174b
|
@ -567,9 +567,13 @@ class Result:
|
|||
formula = kwargs['formula']
|
||||
for d in re.findall(r'#(.*?)#',formula):
|
||||
formula = formula.replace(f'#{d}#',f"kwargs['{d}']['data']")
|
||||
data = eval(formula)
|
||||
|
||||
if not hasattr(data,'shape') or data.shape[0] != kwargs[d]['data'].shape[0]:
|
||||
raise ValueError("'{}' results in invalid shape".format(kwargs['formula']))
|
||||
|
||||
return {
|
||||
'data': eval(formula),
|
||||
'data': data,
|
||||
'label': kwargs['label'],
|
||||
'meta': {
|
||||
'unit': kwargs['unit'],
|
||||
|
|
|
@ -123,6 +123,10 @@ class TestResult:
|
|||
in_file = default.place('x')
|
||||
assert np.allclose(in_memory,in_file)
|
||||
|
||||
def test_add_calculation_invalid(self,default):
|
||||
default.add_calculation('np.linalg.norm(#F#,axis=0)','wrong_dim')
|
||||
assert default.get('wrong_dim') is None
|
||||
|
||||
def test_add_stress_Cauchy(self,default):
|
||||
default.add_stress_Cauchy('P','F')
|
||||
in_memory = mechanics.stress_Cauchy(default.place('P'), default.place('F'))
|
||||
|
|
Loading…
Reference in New Issue