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

Python node.Node类代码示例

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

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



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

示例1: parseSystemList

    def parseSystemList(self):
        systemslist = []
        while self.currentToken.type in ('IDENTIFIER'):
            identifier = self.parseIdentifier()

            #EXTENSION of UPPAAL language: instantiation on system line
            #e.g. system Template(0), Template(1);
            if self.currentToken.type == 'LPAREN':
                # Process(5, true)
                #        ^
                inst = self.parseTemplateInstantiation(identifier)
            else:
                # Process
                params = []
                inst = Node("TemplateInstantiation", params, identifier,
                        ident=identifier, parameters=params)

            inst.priority = self.prioritycounter

            if self.currentToken.type == 'COMMA':            
                self.accept('COMMA') 
            elif self.currentToken.type == 'LESS':
                self.accept('LESS') 
                self.prioritycounter += 1

            systemslist.append( inst )

            if self.currentToken.type == 'SEMI':
                self.accept('SEMI')
                break
        return systemslist
开发者ID:bencaldwell,项目名称:pyuppaal,代码行数:31,代码来源:systemdec_parser.py


示例2: reduced_error_pruning

def reduced_error_pruning(root,training_set,validation_set):
    '''
    take the a node, training set, and validation set and returns the improved node.
    You can implement this as you choose, but the goal is to remove some nodes such that doing so improves validation accuracy.
    '''
    if root.label != None or not validation_set:
        return root

    else:
        baseacc = validation_accuracy(root,validation_set)
        #treebest = root
        # To prune the tree, remove the subtree and assign 
        # it a leaf node whose value is the most common 
        # classification of examples associated with that node.
        newtree = Node()
        newtree.label = mode(validation_set)
        if validation_accuracy(newtree,validation_set) > baseacc:
            return newtree 
        if root.is_nominal: # if the tree split according to nominal
            new = split_on_nominal(validation_set, root.decision_attribute)
            i = 0
            for key in root.children:
                validation_set = new[i]
                root.children[key] = reduced_error_pruning(root.children[key],training_set,validation_set)
                i = i + 1
        else: # if the tree split according to numeric 
            new = split_on_numerical(validation_set, root.decision_attribute, root.splitting_value)
            validation0 = new[0]
            validation1 = new[1]
            root.children[0] = reduced_error_pruning(root.children[0],training_set,validation0)
            root.children[1] = reduced_error_pruning(root.children[1],training_set,validation1)
        return root
开发者ID:britlovefan,项目名称:DecisionTree,代码行数:32,代码来源:pruning.py


示例3: __init__

class FilterGroupNodeWrapper:
    def __init__(self, name, filters=OrderedDict()):
        self.name = name
        self.node = Node("ros_vision", "filter_chain_node.py", name)
        self.reset_params()
        self.node.run()
        create_filter_srv_name = '/%s/create_filter' % name
        rospy.wait_for_service(create_filter_srv_name)
        self.create_filter = rospy.ServiceProxy(create_filter_srv_name, CreateFilter)

        i = 0
        for filter_name in filters.keys():
            i += 1

            if 'type' in filters[filter_name].keys():
                filter_type = filters[filter_name]['type']
                del filters[filter_name]['type']

                for parameter_name in filters[filter_name].keys():
                    rosparam.set_param('/%s/%s/%s' % (name, filter_name, parameter_name), str(filters[filter_name][parameter_name]))

                self.create_filter(filter_name, filter_type, i)

    def reset_params(self):
        for p in rosparam.list_params(self.name):
            rosparam.delete_param(p)

    def kill(self):
        self.node.kill()
开发者ID:ETS-Robotics,项目名称:ros_vision,代码行数:29,代码来源:filter_group_node_wrapper.py


示例4: test_parse_tree_manual

 def test_parse_tree_manual(self):
     root = Node()
     current = root
     current.set_root()
     self.assertEqual(root, current)
     current = root.new_left()
     introspection = current
     current = introspection.new_left()
     current = current.parent
     self.assertEqual(introspection, current)
     current.token = '!'
     self.assertEqual('!', introspection.token)
     current.left = None
     self.assertIsNone(introspection.left)
     current = current.new_right()
     a = current
     current.token = 'a'
     self.assertEqual('a', a.token)
     current = current.parent
     self.assertEqual(introspection, current)
     current = current.parent
     self.assertEqual(current, root)
     current.token = ':'
     self.assertEqual(':', root.token)
     current = current.new_right()
     F = current
     current.token = 'F'
     self.assertEqual('F', F.token)
     current = current.parent
     self.assertEqual(root, current)
     current = current.parent
     self.assertEqual(root, current)
开发者ID:lyriael,项目名称:j-logic,代码行数:32,代码来源:test_node.py


示例5: _get_link_details

    def _get_link_details(entity, link_name):
        """"Lookup the (edge_class, left_edge_id, right_edge_id, node_class)
        for the given entity and link_name.

        param entity: The current entity Node subclass
        :param str link_name: The association proxy name

        edge_class: The Edge subclass the association is proxied through
        left_edge_id: The edge.{src,dst}_id
        right_edge_id: The edge.{dst,src}_id (opposit of left_edge_id)
        node_class: The target node the association_proxy points to

        """

        # Look for the link_name in OUTBOUND edges from the current
        # entity
        for edge in Edge._get_edges_with_src(entity.__name__):
            if edge.__src_dst_assoc__ == link_name:
                return (edge, edge.src_id, edge.dst_id,
                        Node.get_subclass_named(edge.__dst_class__))

        # Look for the link_name in INBOUND edges from the current
        # entity
        for edge in Edge._get_edges_with_dst(entity.__name__):
            if edge.__dst_src_assoc__ == link_name:
                return (edge, edge.dst_id, edge.src_id,
                        Node.get_subclass_named(edge.__src_class__))

        raise AttributeError(
            "type object '{}' has no attribute '{}'"
            .format(entity.__name__, link_name))
开发者ID:NCI-GDC,项目名称:psqlgraph,代码行数:31,代码来源:query.py


示例6: test_node

    def test_node(self):
        node1 = Node(addr1, id1, 'version')
        node2 = Node(addr2, id2)
        node1b = Node(addr1, None)
        node1ip = Node(('127.0.0.2', 1111), id1)
        node1port = Node(addr2, id1)
        node1id = Node(addr1, id2)

        eq_(str(node1), '<node: %r %r (version)>' % (addr1, id1))
        #<node: ('127.0.0.1', 1111) 0x1313131313131313131313131313131313131313>

        eq_(node1.id, id1)
        assert node1.id != id2
        assert node1.addr == addr1
        eq_(node1.ip, addr1[0])
        assert node1.addr != addr2
        assert node1 == node1

        assert node1 != node1b
        node1b.id = id1
        assert node1 == node1b

        assert node1 != node2
        assert node1 != node1ip
        assert node1 != node1port
        assert node1 != node1id
开发者ID:pedromj,项目名称:pymdht,代码行数:26,代码来源:test_node.py


示例7: test_sibling

 def test_sibling(self):
     right = Node()
     left = Node()
     right.sibling = left
     left.sibling = right
     self.assertEqual(right, left.sibling)
     self.assertEqual(left, right.sibling)
开发者ID:lyriael,项目名称:j-logic,代码行数:7,代码来源:test_node.py


示例8: Queue

class Queue():
    def __init__(self):
        self.size = 0
        self.head = None
        self.tail = None

    def push(self, value):
        if self.size == 0:
            self.size = self.size + 1
            self.head = Node(value)
        else:
            node = Node(value)
            if not self.tail:
                self.tail = node
                self.tail.change_previous_node(self.head)
                self.head.change_next_node(self.tail)
            else:
                self.tail.change_next_node(node)
                node.change_previous_node(self.node)
                self.tail = node
            self.size = self.size + 1

    def pop(self):
        element_to_pop = self.head
        self.head = self.head.get_next_node()
        self.size = self.size - 1
        return element_to_pop

    def get_size(self):
        return self.size

    def peek(self):
        return self.head.get_value()
开发者ID:kakato10,项目名称:Algo-1,代码行数:33,代码来源:queue.py


示例9: p_call

def p_call(p):
  '''call : ID id_call LPAR par_call RPAR par_call2
            | ID id_call LPAR par_call params RPAR par_call2
           '''
  global pila_Oz
  global cont
  global param_cont
  global temp_cont
  global mem_temp
  global list_temp

  #Check for ")"
  item = pila_Oz.pop()
  if item == ")":
    #Take elements out of stack until no params
    while item != "(":
      item = pila_Oz.pop()
      if item != "(":
        param = "param" + str(param_cont)
        #IF ID
        if isinstance(item, str):
          var = variableFetch(item)
          if isinstance(var, Node):
            op1 = var.mem
        #IF TMP
        elif isinstance(item, Node):
          op1 = item.name
        #IF CTE
        else:
          cte_memoryAssign(item)
          item = cte_list[item]
          op1 = item
        #PARAMS
        cuadruplo_temp = Cuadruplo()
        cuadruplo_temp.set_cont(cont)
        cuadruplo_temp.set_operator("param")
        cuadruplo_temp.set_operand1(op1)
        cuadruplo_temp.set_result(param)
        cuadruplos_list.append(cuadruplo_temp)
        cont += 1
        param_cont += 1

    #POPS name
    subname = pila_Oz.pop()
     #GO SUB
    createCuad("goSub", subname, None, None)
    #TEMPORAL output
    func = functionFetch(subname)
    if func.ret:
      temp = Node()
      tname = subname
      temp.name = tname
      temp.mem  = mem_temp
      temp.value = func.ret.value
      list_temp.append(temp)
      pila_Oz.append(temp)
  
    temp_cont += 1
    mem_temp += 1
    param_cont = 0
开发者ID:lalokuyo,项目名称:Cat,代码行数:60,代码来源:rules.py


示例10: create_cct

def create_cct(data, flag):
    entry = "lttng_ust_cyg_profile:func_entry"
    exit = "lttng_ust_cyg_profile:func_exit"

    tree = Node("root",[])
    pointer = tree

    for each in data:
        if entry in each:
            if (flag):
                print ("cria no")
            begin = (each.find("addr"))
            begin += 7
            end = begin + 7
            name = (each[begin:end])
            print (name)
            print ()
            if("perf_thread_page_fault" in each):
                print ("page faults")
            if(pointer.get_label() == name):
                if (flag):
                    print("already there")
                pointer.increment()
            else:
                aux = Node(name, [])
                pointer.add_child(aux)
                aux.set_parent(pointer)
                pointer = aux

        if exit in each:
            if(flag):
                print ("fecha no")
            pointer = pointer.get_parent()

    return tree
开发者ID:FranciscoMeloJr,项目名称:Python-Tests,代码行数:35,代码来源:reader.py


示例11: add_node

    def add_node(self, node=None, pos=None, ori=None, commRange=None):
        """
        Add node to network.

        Attributes:
          `node` -- node to add, default: new node is created
          `pos` -- position (x,y), default: random free position in environment
          `ori` -- orientation from 0 to 2*pi, default: random orientation

        """
        if (not node):
            node = Node(commRange=commRange)
        assert(isinstance(node, Node))
        if not node.network:
            node.network = self
        else:
            logger.warning('Node is already in another network, can\'t add.')
            return None

        pos = pos if pos is not None else self.find_random_pos(n=100)
        ori = ori if ori is not None else rand() * 2 * pi
        ori = ori % (2 * pi)

        if (self._environment.is_space(pos)):
            Graph.add_node(self, node)
            self.pos[node] = array(pos)
            self.ori[node] = ori
            self.labels[node] = str(node.id)
            logger.debug('Node %d is placed on position %s.' % (node.id, pos))
            self.recalculate_edges([node])
        else:
            logger.error('Given position is not free space.')
        return node
开发者ID:engalex,项目名称:pymote,代码行数:33,代码来源:network.py


示例12: insert

    def insert(self, s):
        node = self.seen[ord(s)]

        if node is None:
            spawn = Node(symbol=s, weight=1)
            internal = Node(symbol='', weight=1, parent=self.NYT.parent,
                left=self.NYT, right=spawn)
            spawn.parent = internal
            self.NYT.parent = internal

            if internal.parent is not None:
                internal.parent.left = internal
            else:
                self.root = internal

            self.nodes.insert(0, internal)
            self.nodes.insert(0, spawn)

            self.seen[ord(s)] = spawn
            node = internal.parent

        while node is not None:
            largest = self.find_largest_node(node.weight)

            if (node is not largest and node is not largest.parent and
                largest is not node.parent):
                self.swap_node(node, largest)

            node.weight = node.weight + 1
            node = node.parent
开发者ID:sh1r0,项目名称:adaptive-huffman-coding,代码行数:30,代码来源:fgk.py


示例13: test_ping

def test_ping():
    node = Node('127.0.0.1:20000')
    reactor.listenTCP(20000, node)
    print node
    testMessage = Msg(0, 32812248528126350900072321242296281633, 10009, 293268701940054034179163628332357508988, 20000, -1, -1, True, {}, 0)
    node.send(testMessage, (32812248528126350900072321242296281633, 10009))
    node.send(testMessage, (32812248528126350900072321242296281633, 10009))
开发者ID:xuziyan001,项目名称:Kademlia-lbs,代码行数:7,代码来源:kademlia.py


示例14: mockLaunch

def mockLaunch(name, ami='ami-3d4ff254', instance_type='t1.micro', key_name='amazon2', zone='us-east-1d', security_group='quicklaunch-1', job=None):
    """ Simulate a node launch for dev purposes """

    i = {
         'name': name,
         'key_name': key_name,
         'public_dns_name': u'ec2-107-21-159-143.compute-1.amazonaws.com',
         'ip_address': u'107.21.159.143',
         'private_dns_name': u'ip-10-29-6-45.ec2.internal',
         'id': u'i-e2a5559d',
         'image_id': ami,
         'placement': zone,
         'dns_name': u'ec2-107-21-159-143.compute-1.amazonaws.com',
         'instance_type': instance_type,
         'private_ip_address': u'10.29.6.45',
         'user':user,
         'jobs':job
        }

    n = Node(i['name'], i['id'], i['image_id'], i['key_name'], i['placement'],
            i['instance_type'], i['dns_name'], i['private_dns_name'],
            i['ip_address'], i['private_ip_address'], i['user'], job)

    pprint.pprint(n.to_dict())
    addNode(n)
开发者ID:sleekslush,项目名称:Admiral,代码行数:25,代码来源:fabfile.py


示例15: __init__

 def __init__(self, name, lic=None, file=None):
     if file is None:
         self.name = name
         self.ntc = Netica()
         self.env = self.ntc.newenv(lic)
         self.ntc.initenv(self.env)
         self.net = self.ntc.newnet(name, self.env)
         self.nodes = []
     else:
         self.name = name
         self.ntc = Netica()
         self.env = self.ntc.newenv(lic)
         self.ntc.initenv(self.env)
         self.net = self.ntc.opennet(self.env, file)
         nodelist_p = self.ntc.getnetnodes(self.net)
         numnode = self.ntc.lengthnodelist(nodelist_p)
         self.nodes = []
         for i in range(numnode):
             nodei_p = self.ntc.nthnode(nodelist_p, i)
             nodename = self.ntc.getnodename(nodei_p)
             statename = 'init'; statenames = []; istate = 0
             while statename!='error':
                 statename = self.ntc.getnodestatename(nodei_p, istate)
                 statenames.append(statename)
                 istate += 1
             statenames = statenames[:-1]
             # default: no parents and continuous: therefore not the original nodes
             nodei = Node(nodename, parents=[], rvname='continuous')
             nodei.set_node_ptr(nodei_p)
             nodei.set_node_state_name(statenames)
             self.nodes.append(nodei)
开发者ID:cedavidyang,项目名称:pyNetica,代码行数:31,代码来源:network.py


示例16: randomNode

def randomNode():
    node = Node()
    node.x = random.randint(10, 500)
    node.y = random.randint(10, 300)
    node.color = "black"
    graph.add(node)
    return node
开发者ID:muxuehen,项目名称:pisio,代码行数:7,代码来源:pisio.py


示例17: __init__

    def __init__(self, site, log_path, output_split_logs = False):
        assert site is not None
        assert isinstance(site, str)
        assert log_path is not None
        assert isinstance(log_path, str)

        self._initialized = False
        self._nodes = None

        nodelogs = _split_node_data(log_path, output_split_logs)

        nodes = {}
        for nodeid, log in nodelogs.items():
            print " * Loading data for node nr. %d ..." % nodeid
            assert not (nodeid in nodes.keys())
        
            node = Node(site, nodeid, log)

            if node.initialized():
                nodes[nodeid] = node
            else:
                print "warning: discarding data on node nr. %d since it failed to parse its log\n" % nodeid

        self._nodes = nodes
        self._initialized = True
开发者ID:rccrdo,项目名称:senslab-size-estimation,代码行数:25,代码来源:network.py


示例18: __init__

 def __init__(self, cluster):
     # A lot of things are wrong in that method. It assumes that the ip
     # 127.0.0.<nbnode> is free and use standard ports without asking.
     # It should problably be fixed, but will be good enough for now.
     addr = '127.0.0.%d' % (len(cluster.nodes) + 1)
     self.path = tempfile.mkdtemp(prefix='bulkloader-')
     Node.__init__(self, 'bulkloader', cluster, False, (addr, 9160), (addr, 7000), str(9042), 2000, None)
开发者ID:Flux7Labs,项目名称:ccm,代码行数:7,代码来源:bulkloader.py


示例19: __init__

 def __init__(self, start, end):
     Node.__init__(self)
     self.start = start
     self.end = end
     self.outter = False
     self.inverse = None
     logger.info("the edge has been created")
开发者ID:matyukhin,项目名称:Graphs,代码行数:7,代码来源:edge.py


示例20: __init__

 def __init__(self):
     Node.__init__(self, -1)
     self.nodes = {}
     self.connections = {}
     self.index = 0
     self.tnodes = {}
     self.doprop = True
开发者ID:juancq,项目名称:character-evolver,代码行数:7,代码来源:network.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python node_manager_fkie.is_local函数代码示例发布时间:2022-05-27
下一篇:
Python node.stop函数代码示例发布时间: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