本文整理匯總了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)