本文整理汇总了Python中filter.Filter.setParam方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.setParam方法的具体用法?Python Filter.setParam怎么用?Python Filter.setParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filter.Filter
的用法示例。
在下文中一共展示了Filter.setParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_qeinput_filter
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setParam [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)
示例2: test_filter_namelist
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setParam [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
示例3: test_filter_apply
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import setParam [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)