• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vital.ConfigBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vital.ConfigBlock的典型用法代码示例。如果您正苦于以下问题:Python ConfigBlock类的具体用法?Python ConfigBlock怎么用?Python ConfigBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ConfigBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_write_fail

    def test_write_fail(self):
        cb = ConfigBlock()
        cb.set_value('foo', 'bar')

        nose.tools.assert_raises(VitalConfigBlockIoException,
                                 cb.write,
                                 '/not/valid')
开发者ID:Kitware,项目名称:vital,代码行数:7,代码来源:test_config_block.py


示例2: get_config

    def get_config(self, cb=None):
        """
        Return this algorithm's current configuration.

        As algorithms are named, the configuration returned will be contained
        inside a sub-block whose name matches this algorithm's name in order
        to separate

        :param cb: An optional existing ConfigBlock instance to add this
            algorithm's configuration to.
        :type cb: ConfigBlock

        :return: This named algorithm's current configuration. If a config block
            was given to this method, the same config block is returned.
        :rtype: vital.ConfigBlock

        """
        if cb is None:
            cb = ConfigBlock()

        self._call_cfunc(
            'vital_algorithm_%s_get_type_config' % self.type_name(),
            [ctypes.c_char_p, self.C_TYPE_PTR, ConfigBlock.c_ptr_type()],
            [self.name, self, cb],
            ConfigBlock.c_ptr_type()
        )

        return cb
开发者ID:Kitware,项目名称:kwiver,代码行数:28,代码来源:algorithm.py


示例3: test_subblock_view_match

 def test_subblock_view_match(self):
     cb = ConfigBlock()
     bname = 'block'
     va = 'va'
     cb.set_value(bname, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)
开发者ID:Kitware,项目名称:vital,代码行数:8,代码来源:test_config_block.py


示例4: test_check_conf

    def test_check_conf(self):
        ci = ConvertImage('ci')
        c = ConfigBlock()
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', '')
        nt.assert_false(ci.check_config(c))

        c.set_value('ci:type', 'not_an_impl')
        nt.assert_false(ci.check_config(c))
开发者ID:ALouis38,项目名称:vital,代码行数:10,代码来源:test_algo_convert_image.py


示例5: test_subblock_view_prefix_match

 def test_subblock_view_prefix_match(self):
     cb = ConfigBlock()
     bname = 'block'
     ka = 'ka'
     va = 'va'
     # intentionally not adding block separator
     cb.set_value(bname + ka, va)
     sb = cb.subblock_view(bname)
     keys = sb.available_keys()
     nose.tools.assert_equal(len(keys), 0)
开发者ID:Kitware,项目名称:vital,代码行数:10,代码来源:test_config_block.py


示例6: test_set_conf

    def test_set_conf(self):
        ci = ConvertImage('ci')
        nt.assert_false(ci)
        nt.assert_is_none(ci.impl_name())

        c = ConfigBlock()
        c.set_value('ci:type', 'bypass')
        ci.set_config(c)
        nt.assert_true(ci)
        nt.assert_equal(ci.impl_name(), 'bypass')
开发者ID:Purg,项目名称:vital,代码行数:10,代码来源:test_algo_convert_image.py


示例7: test_read_only_unset

 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     cb.unset_value('a')
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
开发者ID:ALouis38,项目名称:vital,代码行数:7,代码来源:test_config_block.py


示例8: test_get_value_no_exist

    def test_get_value_no_exist(self):
        cb = ConfigBlock()
        k1 = 'a'
        k2 = 'b'
        v2 = '2'

        nose.tools.assert_raises(
            VitalConfigBlockNoSuchValueException,
            cb.get_value, k1
        )
        nose.tools.assert_equal(cb.get_value(k2, v2), v2)
开发者ID:Kitware,项目名称:vital,代码行数:11,代码来源:test_config_block.py


示例9: test_read_only

    def test_read_only(self):
        cb = ConfigBlock()

        cb.set_value('a', '1')
        cb.mark_read_only('a')
        nose.tools.assert_equal(cb.get_value('a'), '1')
        cb.set_value('a', '2')
        nose.tools.assert_equal(cb.get_value('a'), '1')
开发者ID:ALouis38,项目名称:vital,代码行数:8,代码来源:test_config_block.py


示例10: test_get_value_nested

    def test_get_value_nested(self):
        cb = ConfigBlock()

        k1 = 'a'
        k2 = 'b'
        v = 'c'

        cb.set_value(k1 + ConfigBlock.BLOCK_SEP + k2, v)
        nose.tools.assert_equal(cb.get_value(k1 + ConfigBlock.BLOCK_SEP + k2),
                                v)

        sb = cb.subblock(k1)
        nose.tools.assert_equal(sb.get_value(k2), v)
开发者ID:Kitware,项目名称:vital,代码行数:13,代码来源:test_config_block.py


示例11: test_get_value_bool_default

    def test_get_value_bool_default(self):
        cb = ConfigBlock()

        nose.tools.assert_raises(
            VitalConfigBlockNoSuchValueException,
            cb.get_value_bool, 'not-a-key'
        )

        nose.tools.assert_true(
            cb.get_value_bool('not-a-key', True)
        )
        nose.tools.assert_false(
            cb.get_value_bool('not-a-key', False)
        )
开发者ID:Kitware,项目名称:vital,代码行数:14,代码来源:test_config_block.py


示例12: default_config_block

def default_config_block():
    c = ConfigBlock()

    c.set_value('image_list_file',
                '',
                'Path to an input file containing new-line separated paths to '
                'sequential image files')
    c.set_value('mask_list_file',
                '',
                'Optional path to an input file containing new-line '
                'separated paths to mask images. This list should be '
                'parallel in association to files specified in '
                '``image_list_file``. Mask image must be the same size as '
                'the image they are associated with.\n'
                '\n'
                'Leave this blank if no image masking is desired.')
    c.set_value('output_tracks_file',
                '',
                'Path to a file to write output tracks to. If this file '
                'exists, it will be overwritten.')

    image_reader, image_converter, feature_tracker = base_algorithms()
    image_reader.get_config(c)
    image_converter.get_config(c)
    feature_tracker.get_config(c)

    return c
开发者ID:Kitware,项目名称:maptk,代码行数:27,代码来源:track_features.py


示例13: test_set_value

 def test_set_value(self):
     cb = ConfigBlock()
     # Basic value string
     cb.set_value('foo', 'bar')
     # Should attempt casting non-string to string
     cb.set_value('bar', 124789)
     # Setting with a description
     cb.set_value('baz', 'a', "This is a description")
开发者ID:Kitware,项目名称:vital,代码行数:8,代码来源:test_config_block.py


示例14: test_get_value

    def test_get_value(self):
        cb = ConfigBlock()

        cb.set_value('a', 'b')
        cb.set_value('longer_value:foo', "BarBazThing")

        nose.tools.assert_equal(cb.get_value('a'), 'b')
        nose.tools.assert_equal(cb.get_value('longer_value:foo'),
                                'BarBazThing')
开发者ID:Kitware,项目名称:vital,代码行数:9,代码来源:test_config_block.py


示例15: test_set_value_description

    def test_set_value_description(self):
        cb = ConfigBlock()
        bname = 'sub'
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'
        da = 'da'
        db = 'db'

        cb.set_value(ka, va, da)
        cb.set_value(bname + ConfigBlock.BLOCK_SEP + kb, vb, db)
        cb.set_value(kc, vc)
        sb = cb.subblock('sub')

        nose.tools.assert_equal(cb.get_description(ka), da)
        nose.tools.assert_equal(sb.get_description(kb), db)
        nose.tools.assert_equal(cb.get_description(kc), "")
开发者ID:Kitware,项目名称:vital,代码行数:20,代码来源:test_config_block.py


示例16: test_merge_config

    def test_merge_config(self):
        cb1 = ConfigBlock()
        cb2 = ConfigBlock()
        ka = 'ka'
        kb = 'kb'
        kc = 'kc'
        va = 'va'
        vb = 'vb'
        vc = 'vc'

        cb1.set_value(ka, va)
        cb1.set_value(kb, va)
        cb2.set_value(kb, vb)
        cb2.set_value(kc, vc)

        cb1.merge_config(cb2)

        nose.tools.assert_equal(cb1.get_value(ka), va)
        nose.tools.assert_equal(cb1.get_value(kb), vb)
        nose.tools.assert_equal(cb1.get_value(kc), vc)
开发者ID:Kitware,项目名称:vital,代码行数:20,代码来源:test_config_block.py


示例17: test_image_load_save_diff

    def test_image_load_save_diff(self):
        fd, tmp_filename = tempfile.mkstemp()

        c = ConfigBlock()
        c.set_value('iio:type', 'vxl')
        iio = ImageIo('iio')
        iio.set_config(c)

        nt.assert_true(osp.isfile(self.test_image_filepath),
                       "Couldn't find image file")
        ic_orig = iio.load(self.test_image_filepath)
        iio.save(ic_orig, tmp_filename)
        ic_test = iio.load(tmp_filename)

        nt.assert_equal(ic_orig.size(), ic_test.size())
        nt.assert_equal(ic_orig.width(), ic_test.width())
        nt.assert_equal(ic_orig.height(), ic_test.height())
        nt.assert_equal(ic_orig.depth(), ic_test.depth())

        os.remove(tmp_filename)
        os.close(fd)
开发者ID:Purg,项目名称:vital,代码行数:21,代码来源:test_algo_image_io.py


示例18: test_subblock_nested

    def test_subblock_nested(self):
        cb = ConfigBlock()

        block_name = 'block'
        other_name = 'other'
        nestd_name = block_name + ConfigBlock.BLOCK_SEP + other_name

        ka = 'ka'
        kb = 'kb'
        va = 'va'
        vb = 'vb'

        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + ka, va)
        cb.set_value(nestd_name + ConfigBlock.BLOCK_SEP + kb, vb)

        sb = cb.subblock(nestd_name)

        nose.tools.assert_true(sb.has_value(ka))
        nose.tools.assert_equal(sb.get_value(ka), va)
        nose.tools.assert_true(sb.has_value(kb))
        nose.tools.assert_equal(sb.get_value(kb), vb)
开发者ID:Kitware,项目名称:vital,代码行数:21,代码来源:test_config_block.py


示例19: test_read_only_unset

 def test_read_only_unset(self):
     cb = ConfigBlock()
     cb.set_value('a', '1')
     cb.mark_read_only('a')
     nose.tools.assert_raises(
         VitalConfigBlockReadOnlyException,
         cb.unset_value, 'a'
     )
     nose.tools.assert_true(cb.has_value('a'))
     nose.tools.assert_equal(cb.get_value('a'), '1')
开发者ID:Kitware,项目名称:vital,代码行数:10,代码来源:test_config_block.py


示例20: test_available_keys

 def test_available_keys(self):
     cb = ConfigBlock()
     cb.set_value("foo", 1)
     cb.set_value('bar', 'baz')
     r = cb.available_keys()
     nose.tools.assert_set_equal(set(r),
                                 {'foo', 'bar'},
                                 "Returned key list was incorrect.")
开发者ID:Kitware,项目名称:vital,代码行数:8,代码来源:test_config_block.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python viterbi.viterbi函数代码示例发布时间:2022-05-26
下一篇:
Python visvis.use函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap