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


Python Database.get_property方法代码示例

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


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

示例1: _get_database_params

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def _get_database_params(dbname):
    db = Database(dbname, createdb=False)
    interactions = db.get_property("interactions").value()
    db_nspins = db.get_property("nspins").value()
    db_p = db.get_property("p").value()
    params = (db_nspins, db_p, interactions)
    return db, params
开发者ID:Mahdisadjadi,项目名称:pele,代码行数:9,代码来源:start_server.py

示例2: get_database_params

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def get_database_params(dbname, nspins, p):
    db = Database(dbname, createdb=False)
    interactions = db.get_property("interactions").value()
    db_nspins = db.get_property("nspins").value()
    db_p = db.get_property("p").value()
    # check that parameters match
    assert db_nspins == nspins
    assert db_p == p
    return db, interactions
开发者ID:Mahdisadjadi,项目名称:pele,代码行数:11,代码来源:start_serial.py

示例3: run_gui_db

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def run_gui_db(dbname="pspin_spherical_p3_N20.sqlite"):
    from pele.gui import run_gui
    try:
        db = Database(dbname, createdb=False)
        interactions = db.get_property("interactions").value()
        nspins = db.get_property("nspins").value()
        p = db.get_property("p").value()
    except IOError:
        interactions=None
    system = MeanFieldPSpinSphericalSystem(nspins, p=p, interactions=interactions)
    run_gui(system, db=dbname)
开发者ID:Mahdisadjadi,项目名称:pele,代码行数:13,代码来源:pspin_spherical_system.py

示例4: create_soft_sphere_system_from_db

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def create_soft_sphere_system_from_db(dbname):
    from pele.storage import Database
    db = Database(dbname, createdb=False)
    
    radii = db.get_property("radii").value()
    boxvec = db.get_property("boxvec").value()
    power = db.get_property("power").value()
    print radii
    
    system = SoftSphereSystem(radii, boxvec, power=power)
    db = system.create_database(dbname, createdb=False)
    
    return system, db
开发者ID:Mahdisadjadi,项目名称:pele,代码行数:15,代码来源:soft_sphere_bulk.py

示例5: run_gui_db

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def run_gui_db(dbname="xy_10x10.sqlite"):
    from pele.gui import run_gui
    from pele.storage import Database
    try:
        db = Database(dbname, createdb=False)
        phases = db.get_property("phases").value()
    except IOError:
        phases=None
    system = XYModlelSystem(dim=[10,10], phi_disorder=np.pi, phases=phases)
    run_gui(system, db=dbname)
开发者ID:Mahdisadjadi,项目名称:pele,代码行数:12,代码来源:xy_model_system.py

示例6: create_BLJ_system_from_db

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]
def create_BLJ_system_from_db(dbname):
    from pele.storage import Database
    db = Database(dbname, createdb=False)
    
    natoms = db.get_property("natoms").value()
    boxvec = db.get_property("boxvec").value()
    ntypeA = db.get_property("ntypeA").value()
    initial_coords = db.get_property("initial_coords").value()
    #print radii
    
    system = BLJBulk(natoms, boxvec, ntypeA=ntypeA)

    # The next line is a nasty hack to avoid an odd error.
    # When we call create_database on an exisiting database, it compares all the system properties
    # against the ones that are saved in the database. It then commits any changes to the database,
    # but that step seems to fail when trying to overwrite a sequence object (in this case the kwargs
    # dictionary) with another sequence. Instead, I overwrite with a None-type object first. Then in
    # the next command we are overwriting a None-type with a dictionary, which doesn't cause an error.
    db.add_property("potential_kwargs",{})

    db = system.create_database(dbname, createdb=False, overwrite_properties=True)
    
    return system, db, initial_coords
开发者ID:sniblett402,项目名称:pele,代码行数:25,代码来源:blj_bulk.py

示例7: TestDB

# 需要导入模块: from pele.storage import Database [as 别名]
# 或者: from pele.storage.Database import get_property [as 别名]

#.........这里部分代码省略.........
        m1 = self.db._highest_energy_minimum()
        m2 = self.db.minima()[-1]
        self.assertEqual(m1, m2)
    
    def test_maximum_number_of_minima(self):
        m = self.db.addMinimum(-1., [-1.], max_n_minima=self.nminima)
        self.assertEqual(self.nminima, self.db.number_of_minima())
        self.assertIn(m, self.db.minima())

    def test_maximum_number_of_minima_largestE(self):
        e = float(self.nminima + 1)
        m = self.db.addMinimum(e, [e], max_n_minima=self.nminima)
        self.assertEqual(self.nminima, self.db.number_of_minima())
        self.assertIsNone(m)
        
        #ensure the highest energy minimum is still in the database
        mmax = self.db._highest_energy_minimum()
        self.assertEqual(mmax.energy, float(self.nminima-1))
        
    def test_maximum_number_of_minima_minima_adder(self):
        ma = self.db.minimum_adder(max_n_minima=self.nminima)
        m = ma(-1., [-1.])
        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
开发者ID:borislavujo,项目名称:pele,代码行数:70,代码来源:test_database.py


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