当前位置: 首页>>代码示例>>Python>>正文


Python DBCaseRecorder.close方法代码示例

本文整理汇总了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)
开发者ID:FashtimeDotCom,项目名称:OpenMDAO-Framework,代码行数:28,代码来源:test_dbcaserecorder.py

示例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)
开发者ID:akhi28,项目名称:OpenMDAO-Framework,代码行数:27,代码来源:test_dbcaserecorder.py

示例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)
开发者ID:naylor-b,项目名称:OpenMDAO-Framework,代码行数:27,代码来源:test_dbcaserecorder.py

示例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)
开发者ID:FashtimeDotCom,项目名称:OpenMDAO-Framework,代码行数:21,代码来源:test_dbcaserecorder.py


注:本文中的openmdao.lib.casehandlers.api.DBCaseRecorder.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。