Commit d0ecad3b authored by Louis Beauloye's avatar Louis Beauloye
Browse files

Options in part ok

parent a17530a1
......@@ -848,11 +848,11 @@ class MbsDirdyn(object):
raise ValueError('>>DIRDYN>> The size of compute_Qc is not consistent with njoint').with_traceback(err.__traceback__) from None
# if error during the cast
else:
raise TypeError("{:} is {:}, can not be casted from {:}.".format(key, options[key]['convert'], type(value))).with_traceback(err.__traceback__)
raise TypeError("{:} is {:}, can not be casted from {:}.".format(key, options[key]['convert'], type(value))).with_traceback(err.__traceback__) from None
except AttributeError as err:
# if error during cast of strings (i.e in str_to_bytes)
raise TypeError("{:} is str, {:} can not be casted.".format(key, type(value))).with_traceback(err.__traceback__)
raise TypeError("{:} is str, {:} can not be casted.".format(key, type(value))).with_traceback(err.__traceback__) from None
except TypeError as err:
# if wrong type in integrator or compute_QC
......
......@@ -347,21 +347,21 @@ class MbsPart(object):
determine the rank of the Jacobian matrix.
default is 1.e-2.
"""
options = {'rowperm': {'convert': int, 'c_name': 'rowperm'},
'visualise': {'convert': int, 'c_name': 'visualise'},
'drivers': {'convert': int, 'c_name': 'drivers'},
'verbose': {'convert': int, 'c_name': 'verbose'},
'clearmbsglobal': {'convert': int, 'c_name': 'clearmbsglobal'},
'random_amplitude': {'convert': float, 'c_name': 'random_amplitude'}
}
for key, value in kwargs.items():
if key == "rowperm":
self.mbs_part_ptr.contents.options.contents.rowperm = value
elif key == "visualise":
self.mbs_part_ptr.contents.options.contents.visualise = value
elif key == "drivers":
self.mbs_part_ptr.contents.options.contents.drivers = value
elif key == "verbose":
self.mbs_part_ptr.contents.options.contents.verbose = value
elif key == "clearmbsglobal":
self.mbs_part_ptr.contents.options.contents.clearmbsglobal = value
elif key == "random_amplitude":
self.mbs_part_ptr.contents.options.contents.random_amplitude = value
else:
print(">>PART>> The option " + key + " is not defined in this module.")
if key not in options:
raise TypeError("{:} is an invalid option name.".format(key))
try:
c_name = options[key]['c_name']
setattr(self.mbs_part_ptr.contents.options.contents, c_name, options[key]['convert'](value))
except ValueError as err:
raise TypeError("{:} is {:}, can not be casted from {:}.".format(key, options[key]['convert'], type(value))).with_traceback(err.__traceback__) from None
def get_options(self, *args):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment