本文整理汇总了Python中openmdao.main.api.SimulationRoot类的典型用法代码示例。如果您正苦于以下问题:Python SimulationRoot类的具体用法?Python SimulationRoot怎么用?Python SimulationRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimulationRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
""" Called before each test in this class. """
self.startdir = os.getcwd()
self.tempdir = tempfile.mkdtemp(prefix='test_file-')
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
self.model = set_as_top(Model())
示例2: setUp
def setUp(self):
# SimulationRoot is static and so some junk can be left
# over from other tests when running under nose, so
# set it to cwd here just to be safe
SimulationRoot.chroot(os.getcwd())
pcompmod._count = 0
self.asm = set_as_top(Assembly())
obj = self.asm.add('scomp1', SimpleComp())
self.asm.add('scomp2', SimpleComp())
self.asm.driver.workflow.add(['scomp1', 'scomp2'])
with self.asm.dir_context:
filename = 'top.data.vt'
with open(filename, 'w') as out:
out.write('vt data\n')
obj.cont_in.data = FileRef(filename, self.asm)
filename = 'top.data.vt2'
with open(filename, 'w') as out:
out.write('vt2 data\n')
obj.cont_in.vt2.data = FileRef(filename, self.asm)
filename = 'top.data.vt3'
with open(filename, 'w') as out:
out.write('vt3 data\n')
obj.cont_in.vt2.vt3.data = FileRef(filename, self.asm)
示例3: setUp
def setUp(self):
SimulationRoot.chroot(DIRECTORY)
with open(INP_FILE, 'w') as out:
out.write(INP_DATA)
if os.path.exists(ENV_FILE):
os.remove(ENV_FILE)
dum = Assembly() # create this here to prevent any Assemblies in tests to be 'first'
示例4: tearDown
def tearDown(self):
""" Called after each test in this class. """
self.model.pre_delete() # Paranoia. Only needed by NPSS I think.
self.model = None
os.chdir(self.startdir)
SimulationRoot.chroot(self.startdir)
if not os.environ.get('OPENMDAO_KEEPDIRS', False):
try:
shutil.rmtree(self.tempdir)
except OSError:
pass
# Not always added, but we need to ensure the egg is not in sys.path.
egg_name = self.egg_name
paths = sys.path
if egg_name is not None:
if sys.platform == "win32":
egg_name = egg_name.lower()
paths = [path.lower() for path in sys.path]
for i, path in enumerate(paths):
if path.endswith(egg_name) or egg_name in path:
del sys.path[i]
break
示例5: tearDown
def tearDown(self):
os.chdir(self.startdir)
SimulationRoot.chroot(self.startdir)
if not os.environ.get('OPENMDAO_KEEPDIRS', False):
try:
shutil.rmtree(self.tempdir)
except OSError:
pass
示例6: tearDown
def tearDown(self):
""" Called after each test in this class. """
os.chdir(self.startdir)
SimulationRoot.chroot(self.startdir)
if not os.environ.get('OPENMDAO_KEEPDIRS', False):
try:
shutil.rmtree(self.tempdir)
except OSError:
pass
示例7: tearDown
def tearDown(self):
GridEngineServer._QSUB[:] = self.orig_qsub
GridEngineAllocator._QHOST[:] = self.orig_qhost
os.chdir(self.startdir)
SimulationRoot.chroot(self.startdir)
if not os.environ.get('OPENMDAO_KEEPDIRS', False):
try:
shutil.rmtree(self.tempdir)
except OSError:
pass
示例8: setUp
def setUp(self):
self.tempdir = tempfile.mkdtemp(prefix='test_pbs-')
self.startdir = os.getcwd()
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
# Force use of fake 'qsub'.
self.orig_qsub = list(PBS_Server._QSUB)
PBS_Server._QSUB[:] = \
['python', os.path.join(TestCase.directory, 'pbs_qsub.py')]
示例9: setUp
def setUp(self):
self.startdir = os.getcwd()
self.tempdir = tempfile.mkdtemp(prefix='test_stl-')
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
self.top = set_as_top(Assembly())
self.top.add('plug_noz', PlugNozzleGeometry())
self.top.driver.workflow.add('plug_noz')
self.top.run()
示例10: setUp
def setUp(self):
random.seed(10)
numpy_random.seed(10)
self.startdir = os.getcwd()
self.tempdir = tempfile.mkdtemp(prefix='test_caseiter-')
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
#os.chdir(self.directory)
self.model = set_as_top(MyModel())
self.generate_cases()
示例11: setUp
def setUp(self):
global TMPDIR
self.startdir = os.getcwd()
self.tempdir = tempfile.mkdtemp(prefix='test_extcode-')
TMPDIR = self.tempdir
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
shutil.copy(os.path.join(DIRECTORY, 'sleep.py'),
os.path.join(self.tempdir, 'sleep.py'))
with open(INP_FILE, 'w') as out:
out.write(INP_DATA)
dum = Assembly() # create this here to prevent any Assemblies in tests to be 'first'
示例12: setUp
def setUp(self):
""" Called before each test in this class. """
self.startdir = os.getcwd()
self.tempdir = tempfile.mkdtemp(prefix='test_eggsave-')
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
self.model = set_as_top(Model())
self.model.name = 'Egg_TestModel'
self.child_objs = [self.model.Source, self.model.Sink,
self.model.Oddball, self.model.Oddball.oddcomp,
self.model.Oddball.oddcont]
self.egg_name = None
示例13: tearDown
def tearDown(self):
for directory in ("a", "b"):
if os.path.exists(directory):
shutil.rmtree(directory)
if os.path.exists("error.out"):
try:
os.remove("error.out")
# Windows processes greedily clutch files. I see no
# way to delete this file in test_timeout
except WindowsError:
pass
SimulationRoot.chroot(ORIG_DIR)
示例14: setUp
def setUp(self):
self.tempdir = tempfile.mkdtemp(prefix='test_ge-')
self.startdir = os.getcwd()
os.chdir(self.tempdir)
SimulationRoot.chroot(self.tempdir)
# Force use of fake 'qsub'.
self.orig_qsub = list(GridEngineServer._QSUB)
GridEngineServer._QSUB[:] = \
['python', os.path.join(TestCase.directory, 'ge_qsub.py')]
# Force use of fake 'qhost'.
self.orig_qhost = list(GridEngineAllocator._QHOST)
GridEngineAllocator._QHOST[:] = \
['python', os.path.join(TestCase.directory, 'ge_qhost.py')]
示例15: tearDown
def tearDown(self):
for directory in ('a', 'b'):
if os.path.exists(directory):
shutil.rmtree(directory, onerror=onerror)
for name in (ENV_FILE, INP_FILE, 'input', 'output',
'sleep.in', 'sleep.out', 'sleep.err'):
if os.path.exists(name):
os.remove(name)
if os.path.exists("error.out"):
try:
os.remove("error.out")
# Windows processes greedily clutch files. I see no
# way to delete this file in test_timeout
except WindowsError:
pass
SimulationRoot.chroot(ORIG_DIR)