def set_attribute(self, attribute, value):
if isinstance(value, np.ndarray):
getattr(self.veros_new, attribute)[...] = value
else:
setattr(self.veros_new, attribute, value)
for module in self.legacy_modules:
module_handle = getattr(self.veros_legacy, module)
if hasattr(module_handle, attribute):
try:
v = np.asfortranarray(value.copy2numpy())
except AttributeError:
v = np.asfortranarray(value)
setattr(module_handle, attribute, v)
assert np.all(value == getattr(module_handle, attribute)), attribute
return
raise AttributeError("Legacy pyOM has no attribute {}".format(attribute))
评论列表
文章目录