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


Python atom.Atom类代码示例

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


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

示例1: repeat

 def repeat(self,n1,n2,n3):
     #...unit vectors to be repeated
     self.a1= self.a1*n1
     self.a2= self.a2*n2
     self.a3= self.a3*n3
     n123= n1*n2*n3
     nsid= 0
     for ai in self.atoms:
         nsid= max(nsid,ai.sid)
     natm0= self.num_atoms()
     atoms0= copy.copy(self.atoms)
     self.atoms= []
     aid= 0
     for i1 in range(n1):
         for i2 in range(n2):
             for i3 in range(n3):
                 for ai0 in atoms0:
                     aid += 1
                     ai= Atom()
                     ai.sid= ai0.sid
                     ai.symbol= ai0.symbol
                     ai.ifmv= ai0.ifmv
                     x= ai0.pos[0]/n1 +1.0/n1*i1
                     y= ai0.pos[1]/n2 +1.0/n2*i2
                     z= ai0.pos[2]/n3 +1.0/n3*i3
                     ai.set_pos(x,y,z)
                     ai.set_vel(ai0.vel[0],ai0.vel[1],ai0.vel[2])
                     ai.set_id(aid)
                     self.atoms.append(ai)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: __init__

 def __init__(self, file):
     fh = open(file, 'rb')
     size = os.stat(file).st_size
     while fh.tell() < size:
         root_atom = Atom( stream=fh, offset=fh.tell() )
         root_atom.seek( 0, os.SEEK_END )
         self.append( root_atom )
开发者ID:SteveMarshall,项目名称:mp4-quicktime,代码行数:7,代码来源:mp4file.py

示例3: __getattr__

 def __getattr__(self, name):
     attr = None
     if self.__cachedir__ and Atom.is_cached(self.__cachedir__, name):
         attr = Atom.load(self.__cachedir__, name, is_client=self.__is_client__)
         setattr(self, name, attr)
         return attr
     if self.__source__ is None and self.__factory__ is not None:
         source = self.__factory__()
         self.__source__ = source
         #Not really the right place for this.
         #if self.__cachedir__ is not None:
         #    print '%s = %s' % (self.__cachedir__, len(self))
     if self.__source__ is not None:
         attr = getattr(self.__source__, name)
     if attr is not None and self.__index__ is not None:
         #Although this is simple and effective it is not very efficienct
         #    a = Ai(Bi(C[xy])))
         #Using this method:
         #    ax = Cx[Bi][Ai], xy = ay[Bi][Ai]
         #A better approach is to calculate the index then apply it
         #    bai = Bi[Ai], ax = Cx[bai], ay = Cx[bai]
         attr = attr[self.__index__]
     if attr is not None:
         setattr(self, name, attr)
     return attr
开发者ID:leonhardbrenner,项目名称:buckysoap,代码行数:25,代码来源:element.py

示例4: toDatalogRules

 def toDatalogRules(self):
     if self.body.operator == '':
         ruleTop = str(self.head.toDatalog('top')) + ' :- ' + str(self.body.subqueries[0].toDatalog('top'))
         ruleBot = str(self.head.toDatalog('bot')) + ' :- ' + str(self.body.subqueries[0].toDatalog('bot'))
         return [ruleTop, ruleBot]        
     elif self.body.operator == '!':
         freshAtom = Atom.freshWithArgs(self.body.getArgs())                             
         ruleTop = str(self.head.toDatalog('top')) + ' :- not_exists(' + str(freshAtom.toDatalog('bot')) + ')'
         ruleBot = str(self.head.toDatalog('bot')) + ' :- not_exists(' + str(freshAtom.toDatalog('top')) + ')'
         subqueryRule = Rule()
         subqueryRule.head = freshAtom
         subqueryRule.body = self.body.subqueries[0]             
         return [ruleTop, ruleBot] + subqueryRule.toDatalogRules()
     elif self.body.operator == '~':
         freshAtom = Atom.freshWithArgs(self.body.getArgs())                             
         ruleTop = str(self.head.toDatalog('top')) + ' :- ' + str(freshAtom.toDatalog('bot'))
         ruleBot = str(self.head.toDatalog('bot')) + ' :- ' + str(freshAtom.toDatalog('top'))
         subqueryRule = Rule()
         subqueryRule.head = freshAtom
         subqueryRule.body = self.body.subqueries[0]             
         return [ruleTop, ruleBot] + subqueryRule.toDatalogRules()
     elif self.body.operator == '^':
         freshAtoms = []
         datalogRules = []
         for subquery in self.body.subqueries:
             freshAtom = Atom.freshWithArgs(subquery.getArgs())
             freshAtoms.append(freshAtom)
             newRule = Rule()
             newRule.head = freshAtom
             newRule.body = subquery
             datalogRules += newRule.toDatalogRules()
         ruleTop = str(self.head.toDatalog('top')) + ' :- ' + ','.join([str(x.toDatalog('top')) for x in freshAtoms])
         ruleBot = str(self.head.toDatalog('bot')) + ' :- ' + ','.join([str(x.toDatalog('bot')) for x in freshAtoms])    
         datalogRules += [ruleTop, ruleBot]
         return datalogRules        
开发者ID:ptsankov,项目名称:bellog,代码行数:35,代码来源:rule.py

示例5: __init__

    def __init__(self, source=None, factory=None, cachedir=None, index=None,
                 cnames=None, name=None, columns=None, is_client=True, kw={}):
        if cachedir and not os.path.exists(cachedir):
            os.makedirs(cachedir)
        self.__cachedir__ = cachedir
        self.__source__ = source
        self.__factory__ = factory
        self.__index__ = index

        #cnames and source.cnames
        def __cnames():
            __cnames = None
            if cnames:
                if hasattr(cnames, '__call__'):
                    __cnames = cnames(self)
                elif isinstance(cnames, str):
                    __cnames = cnames.split(',')
                else:
                    __cnames = cnames
            else:
                __cnames = []
                if source is not None:
                    __cnames += source.__cnames__
                if kw:
                    __cnames += [x for x in kw.keys() if x not in __cnames]
            return __cnames
        self.__cnames__ = __cnames()

        if columns is not None:
            for name, value in zip(self.__cnames__, columns):
                setattr(self, name, value)

        if name is None:
            if source is not None:
                name = source.__name__
            else:
                name = 'element_%s' % id(self)
        self.__name__ = name

        self.__columns__ = columns
        self.__is_client__ = is_client
        for name, value in kw.items():
            if isinstance(value, str):
                value = getcolumn(self, value)
            elif hasattr(value, '__call__'):
                value = value(self)
                if isinstance(value, list):
                    value = Atom.fromlist(value)
                value = value
            if isinstance(value, list):
                value = Atom.fromlist(value)
            elif isinstance(value, np.ndarray) and not isinstance(value, Atom):
                value = Atom(value)
            setattr(self, name, value)

        if cachedir is not None:
            for name in self.__cnames__:
                if not Atom.is_cached(cachedir, name):
                    getattr(self, name).persist(cachedir, name)
开发者ID:leonhardbrenner,项目名称:buckysoap,代码行数:59,代码来源:element.py

示例6: __init__

    def __init__(self):
        if RootWindow._singleton is not None:
            raise RootWindow._singleton

        self.wid = connection.setup.roots[0].root
        Atom.build_cache()
        self.windows = set()

        self.listen()
开发者ID:Belluka,项目名称:pytyle,代码行数:9,代码来源:window.py

示例7: set_below

    def set_below(self, below):
        self._send_client_event(
            Atom.get_atom('_NET_WM_STATE'),
            [
                1 if below else 0,
                Atom.get_atom('_NET_WM_STATE_BELOW'),
            ]
        )

        connection.push()
开发者ID:Belluka,项目名称:pytyle,代码行数:10,代码来源:window.py

示例8: read_akr

 def read_akr(self,fname='akr0000'):
     f=open(fname,'r')
     # 1st: lattice constant
     self.alc= float(f.readline().split()[0])
     # 2nd-4th: cell vectors
     for i in range(3):
         data= f.readline().split()
         self.a1[i]= float(data[0])
         self.a2[i]= float(data[1])
         self.a3[i]= float(data[2])
     # 5th: num of atoms
     natm= int(f.readline().split()[0])
     # 9th-: atom positions
     self.atoms= []
     symbol = None
     for i in range(natm):
         data= [float(x) for x in f.readline().split()]
         ai= Atom()
         ai.set_sid(data[0])
         ai.set_pos(data[1],data[2],data[3])
         ai.set_vel(data[4],data[5],data[6])
         if self.specorder:
             symbol = self.specorder[ai.sid-1]
         if symbol and ai.symbol != symbol:
             ai.set_symbol(symbol)
         self.atoms.append(ai)
     f.close()
开发者ID:,项目名称:,代码行数:27,代码来源:

示例9: restore

    def restore(self):
        self._send_client_event(
            Atom.get_atom('_NET_WM_STATE'),
            [
                0, # _NET_WM_STATE_REMOVE = 0, _NET_WM_STATE_ADD = 1, _NET_WM_STATE_TOGGLE = 2
                Atom.get_atom('_NET_WM_STATE_MAXIMIZED_VERT'),
                Atom.get_atom('_NET_WM_STATE_MAXIMIZED_HORZ')
            ]
        )

        connection.push()
开发者ID:Belluka,项目名称:pytyle,代码行数:11,代码来源:window.py

示例10: remove_decorations

    def remove_decorations(self):
        if XROOT.wm() == 'openbox':
            self._send_client_event(
                Atom.get_atom('_NET_WM_STATE'),
                [
                    1,
                    Atom.get_atom('_OB_WM_STATE_UNDECORATED')
                ]
            )
        else:
            self._set_property('_MOTIF_WM_HINTS', [2, 0, 0, 0, 0])

        connection.push()
开发者ID:Belluka,项目名称:pytyle,代码行数:13,代码来源:window.py

示例11: read_POSCAR

 def read_POSCAR(self,fname='POSCAR'):
     with open(fname,'r') as f:
         # 1st line: comment
         f.readline()
         # 2nd: lattice constant
         self.alc= float(f.readline().split()[0])
         # 3rd-5th: cell vectors
         self.a1= np.array([float(x) for x in f.readline().split()])
         self.a2= np.array([float(x) for x in f.readline().split()])
         self.a3= np.array([float(x) for x in f.readline().split()])
         # 6th: species names or number of each species
         buff= f.readline().split()
         if not buff[0].isdigit():
             spcs = copy.deepcopy(buff)
             buff= f.readline().split()
             if not self.specorder:
                 self.specorder = spcs
         num_species= np.array([ int(n) for n in buff])
         natm= 0
         for n in num_species:
             natm += n
         #print("Number of atoms = {0:5d}".format(natm))
         # 7th or 8th line: comment
         c7= f.readline()
         if c7[0] in ('s','S'):
             c8= f.readline()
         # Atom positions hereafter
         self.atoms= []
         for i in range(natm):
             buff= f.readline().split()
             ai= Atom()
             sid= 1
             m= 0
             sindex=0
             symbol = None
             for n in num_species:
                 m += n
                 if i < m:
                     if spcs and self.specorder:
                         sid = self.specorder.index(spcs[sindex]) + 1
                         symbol = spcs[sindex]
                     break
                 sid += 1
                 sindex += 1
             ai.set_id(i+1)
             ai.set_sid(sid)
             if symbol:
                 ai.symbol = symbol
             ai.set_pos(float(buff[0]),float(buff[1]),float(buff[2]))
             ai.set_vel(0.0,0.0,0.0)
             self.atoms.append(ai)
开发者ID:,项目名称:,代码行数:51,代码来源:

示例12: _get_property

    def _get_property(self, atom_name):
        try:
            if not Atom.get_type_name(atom_name):
                return ''

            rsp = connection.get_core().GetProperty(
                False,
                self.wid,
                Atom.get_atom(atom_name),
                Atom.get_atom_type(atom_name),
                0,
                (2 ** 32) - 1
            ).reply()

            if Atom.get_type_name(atom_name) in ('UTF8_STRING', 'STRING'):
                if atom_name == 'WM_CLASS':
                    return Atom.null_terminated_to_strarray(rsp.value)
                else:
                    return Atom.ords_to_str(rsp.value)
            elif Atom.get_type_name(atom_name) in ('UTF8_STRING[]', 'STRING[]'):
                return Atom.null_terminated_to_strarray(rsp.value)
            else:
                return list(struct.unpack('I' * (len(rsp.value) / 4), rsp.value.buf()))
        except:
            pass
开发者ID:Belluka,项目名称:pytyle,代码行数:25,代码来源:window.py

示例13: make_sc

def make_sc(latconst=1.0):
    """
    Make a cell of simple cubic structure.
    """
    s= NAPSystem(specorder=_default_specorder)
    #...lattice
    a1= np.array([ 1.0, 0.0, 0.0 ])
    a2= np.array([ 0.0, 1.0, 0.0 ])
    a3= np.array([ 0.0, 0.0, 1.0 ])
    s.set_lattice(latconst,a1,a2,a3)
    p=[0.00, 0.00, 0.00]
    atom= Atom()
    atom.set_pos(p[0],p[1],p[2])
    atom.set_symbol(_default_specorder[0])
    s.add_atom(atom)
    return s
开发者ID:,项目名称:,代码行数:16,代码来源:

示例14: fromElements

 def fromElements(self, elements):
     query = Query()
     query.subqueries = []
     if elements[0] == '!':
         # negated query
         query.operator = '!'
         subquery = Query.fromElements(elements[1])
         query.subqueries.append(subquery)          
     elif elements[0] == '~':
         # inverted query
         query.operator = '~'
         subquery = Query.fromElements(elements[1])
         query.subqueries.append(subquery)
     elif elements[0] == '(':
         # infix query
         if elements[2] == '^':
             # conjunction            
             query.operator = '^'
             for subqueryElements in elements[1:-1:2]:
                 subquery = Query.fromElements(subqueryElements)                 
                 query.subqueries.append(subquery)
         elif elements[2] in ['-false->', '-bot->', '-top->', '-true->']:
             return Query.fromElements(Query.getOverride(elements[1], elements[2][1:-2], elements[3]))
         elif elements[2] == '-plus-':
             return Query.fromElements(Query.getPlus(elements[1], elements[3]))
         elif elements[2] == '-times-':
             return Query.fromElements(Query.getTimes(elements[1], elements[3]))
         elif elements[2] == '<':
             return Query.fromElements(['!', ['(', ['!', ['(', Query.getEq(elements[3], 'true'), '^', elements[1], ')'] ], '^', ['!', ['(', ['!', Query.getEq(elements[3], 'true')], '^', elements[5], ')'] ], ')' ] ])
     else:
         # atomic query
         query.operator = ''
         query.subqueries.append(Atom.fromElements(elements))
     return query
开发者ID:ptsankov,项目名称:bellog,代码行数:34,代码来源:query.py

示例15: main

def main():
    webStr = None
    queryString = None
    opts, args = getopt.getopt(sys.argv[1:], "i:q:", ["input", "query"])
    for o, a in opts:
        if o == "-i":
            webStr = a
        elif o == "-q":
            queryString = a

    if webStr is None or queryString is None:
        print "Incorrect usage"
        sys.exit(-1)

    xsb = XSB()
    try:
        webStr = webStr.replace("<newline>", "\n")
        polStr = "\n".join([l for l in webStr.split("\n") if ":-" in l])
        policy = Policy.fromString(escapeCharacters(polStr))
        query = Atom.fromElements(Grammar.parseAtom(escapeCharacters(queryString)))
        policy.processPolicy()
        policy.checkQuery(query)
        xsb.loadPolicy(policy)
        print xsb.query(query)
        xsb.close()
    except Exception as e:
        print "Error:", e
        xsb.close()
        sys.exit(-1)
开发者ID:ptsankov,项目名称:bellog,代码行数:29,代码来源:runWeb.py


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