本文整理汇总了Python中pele.storage.Database.properties方法的典型用法代码示例。如果您正苦于以下问题:Python Database.properties方法的具体用法?Python Database.properties怎么用?Python Database.properties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pele.storage.Database
的用法示例。
在下文中一共展示了Database.properties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDB
# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import properties [as 别名]
#.........这里部分代码省略.........
self.assertEqual(self.nminima, self.db.number_of_minima())
self.assertIn(m, self.db.minima())
def test_getTSfromID(self):
ts = self.db.transition_states()[0]
ts1 = self.db.getTransitionStateFromID(ts._id)
self.assertEqual(ts, ts1)
def test_property(self):
# add some system properties and ensure they were added correctly
self.db.add_property("natoms", 10)
p = self.db.get_property("natoms")
self.assertEqual(p.value(), 10)
self.db.add_property("eps", 2.1)
p = self.db.get_property("eps")
self.assertEqual(p.value(), 2.1)
self.db.add_property("author", "Jake")
p = self.db.get_property("author")
self.assertEqual(p.value(), "Jake")
self.db.add_property("data", [1, 2])
p = self.db.get_property("data")
self.assertEqual(p.value(), [1, 2])
# assert that the not set values are None
p = self.db.get_property("natoms")
self.assertIsNone(p.string_value)
self.assertIsNone(p.float_value)
self.assertIsNone(p.pickle_value)
p = self.db.get_property("noprop")
self.assertIsNone(p)
props = self.db.properties(as_dict=True)
self.assertIsInstance(props, dict)
self.assertDictContainsSubset(dict(natoms=10), props)
self.assertEqual(len(props.items()), 4)
props = self.db.properties(as_dict=False)
self.assertIn(("natoms", 10), [p.item() for p in props])
self.assertEqual(len(props), 4)
def test_property_dtype(self):
# add some system properties and ensure they were added correctly
self.db.add_property("natoms", 10, dtype="int")
p = self.db.get_property("natoms")
self.assertEqual(p.value(), 10)
self.db.add_property("eps", 2.1, dtype="float")
p = self.db.get_property("eps")
self.assertEqual(p.value(), 2.1)
self.db.add_property("author", "Jake", dtype="string")
p = self.db.get_property("author")
self.assertEqual(p.value(), "Jake")
self.db.add_property("data", [1, 2], dtype="pickle")
p = self.db.get_property("data")
self.assertEqual(p.value(), [1, 2])
def test_bad_property(self):
self.db.add_property("natoms", 10, dtype="string")
p = self.db.get_property("natoms")
self.assertEqual(p.value(), "10")
def test_property_overwrite_false(self):
self.db.add_property("natoms", 10)
# overwriting with the same value should not raise error
self.db.add_property("natoms", 10, overwrite=False)