本文整理汇总了Python中openmdao.lib.casehandlers.api.DBCaseRecorder.close方法的典型用法代码示例。如果您正苦于以下问题:Python DBCaseRecorder.close方法的具体用法?Python DBCaseRecorder.close怎么用?Python DBCaseRecorder.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openmdao.lib.casehandlers.api.DBCaseRecorder
的用法示例。
在下文中一共展示了DBCaseRecorder.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_close
# 需要导入模块: from openmdao.lib.casehandlers.api import DBCaseRecorder [as 别名]
# 或者: from openmdao.lib.casehandlers.api.DBCaseRecorder import close [as 别名]
def test_close(self):
# :memory: can be used after close.
recorder = DBCaseRecorder()
inps = ['str', 'unicode', 'list']
recorder.register(self, inps, [])
inputs = ['Normal String', u'Unicode String', ['Hello', 'world']]
recorder.record(self, inputs, [], None, '', '')
recorder.close()
recorder.record(self, inputs, [], None, '', '')
# File-based DB recorder can not be used after close.
tmpdir = tempfile.mkdtemp()
try:
dfile = os.path.join(tmpdir, 'junk.db')
recorder = DBCaseRecorder(dfile)
recorder.register(self, inps, [])
recorder.record(self, inputs, [], None, '', '')
recorder.close()
code = "recorder.record(self, inputs, [], None, '', '')"
assert_raises(self, code, globals(), locals(), RuntimeError,
'Attempt to record on closed recorder')
finally:
try:
shutil.rmtree(tmpdir, onerror=onerror)
except OSError:
logging.error("problem removing directory %s", tmpdir)
示例2: test_close
# 需要导入模块: from openmdao.lib.casehandlers.api import DBCaseRecorder [as 别名]
# 或者: from openmdao.lib.casehandlers.api.DBCaseRecorder import close [as 别名]
def test_close(self):
# :memory: can be used after close.
recorder = DBCaseRecorder()
case = Case(inputs=[('str', 'Normal String'),
('unicode', u'Unicode String'),
('list', ['Hello', 'world'])]) # Check pickling.
recorder.record(case)
recorder.close()
recorder.record(case)
# File-based DB recorder can not be used after close.
tmpdir = tempfile.mkdtemp()
try:
dfile = os.path.join(tmpdir, 'junk.db')
recorder = DBCaseRecorder(dfile)
recorder.record(case)
recorder.close()
assert_raises(self, 'recorder.record(case)',
globals(), locals(), RuntimeError,
'Attempt to record on closed recorder')
finally:
try:
shutil.rmtree(tmpdir)
except OSError:
logging.error("problem removing directory %s" % tmpdir)
示例3: test_close
# 需要导入模块: from openmdao.lib.casehandlers.api import DBCaseRecorder [as 别名]
# 或者: from openmdao.lib.casehandlers.api.DBCaseRecorder import close [as 别名]
def test_close(self):
# :memory: can be used after close.
recorder = DBCaseRecorder()
case = Case(
inputs=[("str", "Normal String"), ("unicode", u"Unicode String"), ("list", ["Hello", "world"])]
) # Check pickling.
recorder.record(case)
recorder.close()
recorder.record(case)
# File-based DB recorder can not be used after close.
tmpdir = tempfile.mkdtemp()
try:
dfile = os.path.join(tmpdir, "junk.db")
recorder = DBCaseRecorder(dfile)
recorder.record(case)
recorder.close()
assert_raises(
self, "recorder.record(case)", globals(), locals(), RuntimeError, "Attempt to record on closed recorder"
)
finally:
try:
shutil.rmtree(tmpdir)
except OSError:
logging.error("problem removing directory %s" % tmpdir)
示例4: test_tables_already_exist
# 需要导入模块: from openmdao.lib.casehandlers.api import DBCaseRecorder [as 别名]
# 或者: from openmdao.lib.casehandlers.api.DBCaseRecorder import close [as 别名]
def test_tables_already_exist(self):
dbdir = tempfile.mkdtemp()
dbname = os.path.join(dbdir, 'junk_dbfile')
recorder = DBCaseRecorder(dbname)
recorder.close()
recorder = DBCaseRecorder(dbname, append=True)
recorder.close()
try:
recorder = DBCaseRecorder(dbname)
recorder.close()
except Exception as err:
self.assertEqual('table cases already exists', str(err))
else:
self.fail('expected Exception')
try:
shutil.rmtree(dbdir, onerror=onerror)
except OSError:
logging.error("problem removing directory %s", dbdir)