本文整理汇总了Python中openmdao.main.api.Assembly.replace方法的典型用法代码示例。如果您正苦于以下问题:Python Assembly.replace方法的具体用法?Python Assembly.replace怎么用?Python Assembly.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmdao.main.api.Assembly
的用法示例。
在下文中一共展示了Assembly.replace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mimic
# 需要导入模块: from openmdao.main.api import Assembly [as 别名]
# 或者: from openmdao.main.api.Assembly import replace [as 别名]
def test_mimic(self):
# Ensure we can mimic a driver.
top = Assembly()
top.add('c1', Component())
top.add('c2', Component())
top.driver.workflow.add(('c1', 'c2'))
top.driver.printvars = ['c1.force_execute', 'c2.force_execute']
recorder1 = FakeRecorder()
recorder2 = FakeRecorder()
top.driver.recorders = [recorder1, recorder2]
workflow_id = id(top.driver.workflow)
new_driver = Driver()
new_id = id(new_driver)
self.assertNotEqual(new_id, id(top.driver))
top.replace('driver', new_driver)
self.assertEqual(new_id, id(top.driver))
self.assertEqual(workflow_id, id(top.driver.workflow))
self.assertEqual(top.driver.printvars,
['c1.force_execute', 'c2.force_execute'])
self.assertEqual(top.driver.recorders, [recorder1, recorder2])