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


Python Filter.setNamelist方法代码示例

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


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

示例1: test_qeinput_filter

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setNamelist [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_namelist

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setNamelist [as 别名]
    def test_filter_namelist(self):
        f       = Filter("filter")
        nldict  = {"name":      "control",
                   "params":    {"calculation": "'scf'",
                                 "restart_mode": "'from_scratch'"}}
        f.setNamelist(nldict)
        f.setParam("control", "tprnfor", ".true.")  # Set parameter for existing namelist
        nlA      = f.namelists()[0]
        self.assertEqual(nlA.get("tprnfor"), ".true.")

        f.setParam("system", "ibrav", "2")  # Set parameter for non-existing namelist
        self.assertEqual(len(f.namelists()), 2)
        nlB      = f.namelists()[1]
        self.assertEqual(nlB.get("ibrav"), "2")

        self.assertTrue(nlA.exists("calculation"))   # Before removing
        f.removeParam("control", "calculation")
        self.assertFalse(nlA.exists("calculation"))  # After removing
开发者ID:,项目名称:,代码行数:20,代码来源:

示例3: test_filter_apply

# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setNamelist [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,代码来源:


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