• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python structure.Structure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中structure.Structure的典型用法代码示例。如果您正苦于以下问题:Python Structure类的具体用法?Python Structure怎么用?Python Structure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: fromString

 def fromString(self, data):
     Structure.fromString(self,data)
     # Parse the ctx_items
     data = self['ctx_items']
     for i in range(self['ctx_num']):
         item = CtxItemResult(data)
         self.__ctx_items.append(item)
         data = data[len(item):]
开发者ID:downloadmorerum,项目名称:py-kms,代码行数:8,代码来源:dcerpc.py


示例2: __init__

 def __init__(self, data = None, alignment = 0):
     self.__ctx_items = []
     Structure.__init__(self,data,alignment)
     if data is None:
         self['Pad'] = ''
         self['ctx_items'] = ''
         self['sec_trailer'] = ''
         self['auth_data'] = ''
开发者ID:downloadmorerum,项目名称:py-kms,代码行数:8,代码来源:dcerpc.py


示例3: _get_fk_data

 def _get_fk_data(self, table_name, fk, fk_value):
     reltable = Structure.get_fk_referenced_table(table_name, fk)
     reltable_pk = Structure.get_primary_key(reltable)
     if not self._cache.relation_exists(table_name, reltable):
         sql = SQLBuilder(reltable)
         sql.add_where_literal(Column(reltable, reltable_pk).in_(self._cache.get_all_keys(table_name, fk)))
         data = Query().execute_and_fetch(**sql.build_select())
         self._cache.save_relation(table_name, reltable, data)
     return Row(self._cache.get_relation_row(reltable, reltable_pk, fk_value), reltable, self)
开发者ID:davekr,项目名称:pypg,代码行数:9,代码来源:resultset.py


示例4: _get_rel_data_restricted

 def _get_rel_data_restricted(self, sql):
     attr, pk = self._restricted_table_attr, self._get_pk()
     relation_fk = Structure.get_foreign_key_for_table(attr, self._table_name)
     sql.add_where_condition(relation_fk, self.data[pk])
     data = Query().execute_and_fetch(**sql.build_select())
     from resultset import ResultSet
     return ResultSet(data, attr)
开发者ID:davekr,项目名称:pypg,代码行数:7,代码来源:row.py


示例5: _get_rel_data_restricted

 def _get_rel_data_restricted(self, sql):
     saved = self._restricted_table_call
     table_name, relation, pk, pk_value = saved['table_name'], saved['relation'], saved['pk'], saved['pk_value']
     relation_fk = Structure.get_foreign_key_for_table(relation, table_name)
     if not self._cache.relation_exists(table_name, relation):
         if sql._select_args:
             sql.add_select_arg(Column(relation, relation_fk))
         if sql._limit:
             union_sql = []
             union_parameters = []
             union_dict = {}
             for id in self._cache.get_all_keys(table_name, pk):
                 limiting_sql = copy.deepcopy(sql)
                 limiting_sql.add_where_literal(Column(relation, relation_fk) == id)
                 union_dict = limiting_sql.build_select() 
                 union_sql.append('(%s)' % union_dict['sql'])
                 union_parameters.extend(union_dict['parameters'])
             union_dict['sql'], union_dict['parameters'] = ' UNION '.join(union_sql), union_parameters
             data = Query().execute_and_fetch(**union_dict)
             self._cache.save_relation(table_name, relation, data)
         else:
             sql.add_where_literal(Column(relation, relation_fk).in_(self._cache.get_all_keys(table_name, pk)))
             data = Query().execute_and_fetch(**sql.build_select())
             self._cache.save_relation(table_name, relation, data)
     return ResultSet(self._cache.get_relation_set(relation, relation_fk, pk_value), relation, self._cache)
开发者ID:davekr,项目名称:pypg,代码行数:25,代码来源:resultset.py


示例6: select

 def select(self, *args):
     if args:
         map(lambda arg: self._check_is_instance(arg, 'Column'), args)
         args = list(args)
         args.append(Column(self._table_name, Structure.get_primary_key(self._table_name)))
         self._sql.add_select_args(args)
     return self._table_selected_instance()
开发者ID:davekr,项目名称:pypg,代码行数:7,代码来源:table.py


示例7: __init__

 def __init__(self, url):
     """Construct a new Firebase reference from a full Firebase URL."""
     self.connection = Connection(url, self)
     self.base_url = url
     self.structure = Structure(self)
     self.subscriptions = {}
     self.history = []
     self.connection.daemon = True
     self.connection.start()
     atexit.register(self.close)
     DataRef.__init__(self, self, "")
开发者ID:sidibemh,项目名称:python-firebasin,代码行数:11,代码来源:dataref.py


示例8: make_movie

    def make_movie(self,filename,filepath=None):
        if 'structures' in self:
            from structure import Structure
            if filepath==None:
                filepath = os.path.join(self.abspath,filename)
            else:
                filepath = os.path.join(filepath,filename)
            #end if
            movie = ''
            structures = self.structures

            aA = convert(self.input.system['celldm(1)'],'B','A')
            cell = self.input.cell_parameters.vectors
            for i in range(len(structures)):
                s = structures[i]
                struct = Structure(elem=s.atoms,pos=s.positions,axes=cell,scale=aA,units='A')
                struct=struct.tile(2,2,2)
                ss=struct.write_xyz()
                movie += ss
                open(filepath,'w').write(movie)
开发者ID:habanero-rice,项目名称:hclib,代码行数:20,代码来源:pwscf_analyzer.py


示例9: __getattr__

 def __getattr__(self, attr):
     self._check_deleted()
     if Structure.is_foreign_key(self._table_name, attr):
         if self._result_set:
             return self._result_set._get_fk_data(self._table_name, attr, self.data[attr])
         else:
             reltable = Structure.get_fk_referenced_table(self._table_name, attr)
             reltable_pk = Structure.get_primary_key(reltable)
             sql = SQLBuilder(reltable)
             sql.add_where_condition(reltable_pk, self.data[attr])
             data = Query().execute_and_fetch(**sql.build_select())
             return Row(data[0], reltable)
     else:
         self._check_relation_exists(attr)
         pk = self._get_pk()
         if self._result_set:
             return self._result_set._get_rel_data(self._table_name, attr, pk, self.data[pk])
         else:
             self._restricted_table_attr = attr
             from restricted import RestrictedTableSelect
             return RestrictedTableSelect(attr, SQLBuilder(attr), self)
开发者ID:davekr,项目名称:pypg,代码行数:21,代码来源:row.py


示例10: __init__

 def __init__(self, url, ssl_options=None):
     '''Construct a new Firebase reference from a full Firebase URL.'''
     self.connection = Connection(url, self, ssl_options=ssl_options)
     self.base_url = url
     self.structure = Structure(self)
     self.subscriptions = {}
     self.history = []
     self.connection.daemon = True
     self.connection.start()
     self._keep_alive()
     atexit.register(self.close)
     DataRef.__init__(self, self, '')
开发者ID:allanglen,项目名称:python-firebasin,代码行数:12,代码来源:dataref.py


示例11: __init__

    def __init__(self,structure=None,net_charge=0,net_spin=0,particles=None,**valency):

        self.pseudized = False

        if structure is None:
            self.structure = Structure()
        else:
            self.structure = structure
        #end if
        if particles is None:
            self.particles = Particles()
        else:
            self.particles = particles.copy()
        #end if

        self.folded_system = None
        if self.structure.folded_structure!=None:
            vratio = structure.volume()/structure.folded_structure.volume()
            ncells = int(round(vratio))
            if abs(vratio-ncells)>1e-4:
                self.error('volume of system does not divide evenly into folded system')
            #end if
            if net_charge%ncells!=0:
                self.error('net charge of system does not divide evenly into folded system')
            #end if
            if net_spin%ncells!=0:
                self.error('net_spin of system does not divide evenly into folded system')
            #end if
            self.folded_system = PhysicalSystem(
                structure  = structure.folded_structure,
                net_charge = net_charge/ncells,
                net_spin   = net_spin/ncells,
                particles  = particles,
                **valency
                )
        #end if

        self.valency_in = obj(**valency)
        self.net_charge_in = net_charge
        self.net_spin_in   = net_spin

        self.update_particles(clear=False)

        self.check_folded_system()
开发者ID:Paul-St-Young,项目名称:myNexus,代码行数:44,代码来源:physical_system.py


示例12: __init__

    def __init__(self,structure=None,net_charge=0,net_spin=0,particles=None,**valency):

        self.structure = structure
        self.particles = particles
        if structure==None:
            self.structure = Structure()
        #end if
        if particles==None:
            self.particles = Particles()
        #end if

        self.folded_system = None
        if self.structure.folded_structure!=None:
            self.folded_system = PhysicalSystem(
                structure  = structure.folded_structure,
                net_charge = net_charge,
                net_spin   = net_spin,
                particles  = particles,
                **valency
                )
        #end if

        #add ions
        pc = dict()
        elem = list(self.structure.elem)
        for ion in set(elem):
            pc[ion] = elem.count(ion)
        #end for
        self.add_particles(**pc)

        #pseudize
        if len(valency)>0:
            self.pseudize(**valency)
        #end if

        #add electrons
        self.generate_electrons(net_charge,net_spin)

        self.check_folded_system()
开发者ID:jyamu,项目名称:qmc,代码行数:39,代码来源:physical_system.py


示例13: get_result

    def get_result(self, result_name, sim):
        result = obj()
        input = self.input
        if result_name == "structure":
            # OUTCAR structure is not as precise as CONTCAR structure
            # pa = self.load_analyzer_image()
            # elem       = input.poscar.elem
            # elem_count = input.poscar.elem_count
            # atoms = []
            # for i in range(len(elem)):
            #    atoms += elem_count[i]*[elem[i]]
            ##end for
            # structure = Structure(
            #    units = 'A',
            #    axes  = pa.lattice_vectors.copy(),
            #    elem  = atoms,
            #    pos   = pa.position.copy()
            #    )

            # get structure from CONTCAR
            ccfile = os.path.join(self.locdir, self.identifier + ".CONTCAR")
            if not os.path.exists(ccfile):
                self.error("CONTCAR file does not exist for relax simulation at " + self.locdir)
            # end if
            contcar = Poscar(ccfile)
            structure = Structure()
            if contcar.elem != None:
                structure.read_poscar(ccfile)
            else:
                elem, elem_count = self.system.structure.order_by_species()
                structure.read_poscar(ccfile, elem=elem)
            # end if
            if input.poscar.dynamic != None:
                structure.freeze(input.poscar.dynamic, negate=True)
            # end if
            result.structure = structure
        else:
            self.error("ability to get result " + result_name + " has not been implemented")
        # end if
        return result
开发者ID:Paul-St-Young,项目名称:myNexus,代码行数:40,代码来源:vasp.py


示例14: join

 def join(self, table, on=None):
     self._check_is_instance(table, 'Table')
     if on:
         self._check_is_instance(on, 'Literal')
         self._validate_on(table, on)
     else:
         Structure.tables_related(self._table_name, table._table_name)
         try:
             fk = Structure.get_foreign_key_for_table(self._table_name, table._table_name)
         except PyPgException:
             fk = Structure.get_foreign_key_for_table(table._table_name, self._table_name)
             on = Column(table._table_name, fk) == \
                     Column(self._table_name, Structure.get_primary_key(self._table_name))
         else:
             on = Column(self._table_name, fk) == \
                     Column(table._table_name, Structure.get_primary_key(table._table_name))
     self._sql.add_join(table._table_name, on)
     return self._table_select_instance()
开发者ID:davekr,项目名称:pypg,代码行数:18,代码来源:table.py


示例15: _check_relation_exists

 def _check_relation_exists(self, relation):
     Structure.table_exists(relation) 
     Structure.tables_related(relation, self._table_name)
开发者ID:davekr,项目名称:pypg,代码行数:3,代码来源:row.py


示例16: getData

 def getData(self):
     self['ctx_num'] = len(self.__ctx_items)
     for i in self.__ctx_items:
         self['ctx_items'] += i.getData()
     return Structure.getData(self)
开发者ID:downloadmorerum,项目名称:py-kms,代码行数:5,代码来源:dcerpc.py


示例17: _get_pk

 def _get_pk(self):
     pk= Structure.get_primary_key(self._table_name)
     if self.data.get(pk) is not None:
         return pk
     else:
         raise PyPgException('Incorectly formated naming for primary key. Please provide manager.Naming instance or set strict mode on.')
开发者ID:davekr,项目名称:pypg,代码行数:6,代码来源:row.py


示例18: test_structure

def test_structure(N,lt):
    '''
    N:
        The size of the lattice.
    lt:
        The lattice type.
    '''
    lts=construct_lattice(N=N,lattice_shape=lt)
    tgroup=TranslationGroup(Rs=lts.a*lts.N[:,newaxis],per=(True,False))
    lt=Structure(lts.sites)
    #test for bonds
    lt.usegroup(tgroup)
    lt.initbonds(K=17)
    #finding neighbors
    print 'find nearest neighbor %s'%lt.b1s.N
    print 'find second nearest neighbor %s'%lt.b2s.N
    print 'find third nearest neighbor %s'%lt.b3s.N
    isite=array([1]*lt.vdim)
    #find a site at specific position.
    print 'finding - %s'%isite,lt.findsite(isite)   
    i=0
    if lts.dimension==2:
        j=lts.l2index((0,N[1]-1,0))
        print 'measureing distance between site %s and %s -> %s'%(i,j,lt.measure(i,j))
        j=lts.l2index((N[0]-1,0,0))
        print 'measureing distance between site %s and %s -> %s'%(i,j,lt.measure(i,j))
    else:
        j=lt.nsite-1
        print 'measureing distance between site %s and %s -> %s'%(i,j,lt.measure(i,))
    ion()
    lt.show_bonds()
    lt.show_sites()
    pdb.set_trace()
    cla()
    #test for save and load functionality.
    lt.save_bonds()
    lt2=Structure(lts.sites)
    lt2.load_bonds()
    lt2.show_bonds()
    lt2.show_sites()
    axis('equal')
    pdb.set_trace()
开发者ID:Lynn-015,项目名称:NJU_DMRG,代码行数:42,代码来源:tests.py


示例19: __dir__

 def __dir__(self):
     attrs = ['create_mview', 'drop_view', 'set_debug', 'set_log', 'set_strict', 'set_naming', 'set_logger']
     return Structure.get_all_tables() + attrs
开发者ID:davekr,项目名称:pypg,代码行数:3,代码来源:pypg.py


示例20: __init__

 def __init__(self, basename):
     Structure.__init__(self, basename)
     self.flaps = []
开发者ID:apgodshall,项目名称:madesigner,代码行数:3,代码来源:wing.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python msg.event函数代码示例发布时间:2022-05-27
下一篇:
Python _config.BoundLoggerLazyProxy类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap