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


Python Filter.setCard方法代码示例

本文整理汇总了Python中filter.Filter.setCard方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.setCard方法的具体用法?Python Filter.setCard怎么用?Python Filter.setCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在filter.Filter的用法示例。


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

示例1: test_qeinput_filter

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setCard [as 别名]
    def test_qeinput_filter(self):
        input   = QEInput(config=fixtures.textMain)

        f  = Filter("fPlus")
        f.setParam("control", "calculation", "'md'")
        f.setCard({"name": "occupations", "lines": ("New line",)})

        input.applyFilter(f, "plus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterPlus)

        f  = Filter("fMinus")
        f.setNamelist({"name":"control"})
        f.setCard({"name": "k_points"})

        input.applyFilter(f, "minus")
        self.assertEqual(input.toString(), fixtures.assertInputFilterMinus)
开发者ID:,项目名称:,代码行数:18,代码来源:

示例2: test_filter_apply

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setCard [as 别名]
    def test_filter_apply(self):
        input   = QEInput(config=fixtures.textMain)
        # Filter that adds parameters to input
        fp       = Filter("fPlus")
        fp.setParam("control", "prefix", "'ni'")
        fp.setParam("control", "pseudo_dir", "''")
        fp.setParam("control", "outdir", "''")
        fp.setCard({"name": "occupations", "lines": ("New line",)})     # Add new card
        fp.setNamelist({"name": "cell", "params": {"hello": "world"}})  # Add new namelist
        fp.setNamelist({"name": "phonon"})
        fp.apply(input, "plus")

        self.assertEqual(input.toString(), fixtures.assertPlus)

        # Filter that removes parameters from input
        fm      = Filter("fMinus")
        fm.setCard({"name": "atomic_species"})
        fm.setNamelist({"name": "phonon"})    # Remove namelist
        fm.setParam("cell", "hello")        # Remove parameter that makes namelist empty
        fm.setParam("control", "prefix")    # Remove parameter
        fm.apply(input, "minus")
        self.assertEqual(input.toString(), fixtures.assertMinus)
开发者ID:,项目名称:,代码行数:24,代码来源:

示例3: test_filter_card

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setCard [as 别名]
    def test_filter_card(self):
        f       = Filter("filter")
        card    = {"name":      "k_points",
                   "lines":     ("4 4 4 1 1 1",),
                   "arg":       "automatic"}
        f.setCard(card)
        self.assertEqual(len(f.cards()), 1)

        cardF   = {"a": "b"}        # Doesn't have "name" key
        self.assertRaises(KeyError, f.setCard, cardF) # Exception, callable, parameters
        self.assertEqual(len(f.cards()), 1)     # Doesn't add card

        cardF2  = "simple string"
        self.assertRaises(TypeError, f.setCard, cardF2) # Exception, callable, parameters
        self.assertEqual(len(f.cards()), 1)     # Doesn't add card

        card    = f.cards()[0]      # Check values
        self.assertEqual(card.arg(), "automatic")
        self.assertEqual(card.name(), "k_points")
        self.assertEqual(card.toString(), fixtures.assertC_filter_card)

        f.removeCard("k_points")    # Remove card
        self.assertEqual(len(f.cards()), 0)
开发者ID:,项目名称:,代码行数:25,代码来源:


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