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


Python Network类代码示例

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


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

示例1: l4_sendto

def l4_sendto(node, dest_nid, data):

	# get port table for this node and set values for destination target
	PortTable = node.GetPortTable()
	for link in PortTable:
		info = PortTable[link]

		if info[0] == dest_nid:
			dest_port = info[2]

	# get md5 hash of data for checksum
	m = hashlib.md5()
	m.update(data)
	checksum = m.hexdigest()


	# build datagram
	frame = {}
	frame['source_nid'] = node.GetNID()
	frame['source_port'] = node.GetPort()
	frame['destination_nid'] = dest_nid
	frame['destination_port'] = dest_port
	frame['sequence_number'] = 1
	frame['ack_number'] = 1
	frame['window_size'] = 15
	frame['checksum'] = checksum
	frame['data'] = data

	# encode payload
	payload = json.dumps(frame)

	Network.l3_sendto(node, dest_nid, payload)
开发者ID:spitfire4040,项目名称:CPE_701,代码行数:32,代码来源:Transport.py

示例2: read_output

    def read_output(self, settings):
        # output_file = open(self.output_dir + "/output/banjo/top.graph.txt", 'r')

        output_file = open(self.output_dir + "./output/banjo/top.graph.txt", "r")

        import re

        network = []
        for i in range(len(self.gene_list)):
            row = []
            for j in range(len(self.gene_list)):
                row.append(0)
            network.append(row)

        lines = output_file.readlines()

        for i, line in enumerate(lines):
            line = line.strip()
            if line != "" and line[0] == '"':
                line = re.sub(r"\(.*?\)", "", line).replace('"', "").replace(";", "").strip().replace("->", "")
                # print line

                ls = line.split()
                edge = ls[1]
                gene = ls[0]
                network[int(gene)][int(edge)] = 1
                network[int(edge)][int(gene)] = 1
        net = Network()
        net.read_netmatrix(network, self.gene_list)
        self.network = net
开发者ID:remtcs,项目名称:Network-Inference-Workspace,代码行数:30,代码来源:banjo.py

示例3: launch

def launch(name):
    # Game
    game = Game.Game()
    
    # Try to connect 
    socket = Network.connect("192.168.0.3", 8080)
    Protocol.setName(socket, name)
    
    # Thread for inputs
    q = queue.Queue()
    t = None
    startThread(t, q)
    
        
    # Main event loop
    data = bytes()
    while True:
        # Send commands
        try:  
            line = q.get_nowait()
            interpretCommand(line, socket)
        except queue.Empty:
            pass
        
        # Get order
        order = Network.getOrder(socket)
        
        try:
            if order is not None:
                Protocol.manageOrder(socket, order, game)
        except Protocol.ByeException:
            break    
    
    socket.close()
开发者ID:SfietKonstantin,项目名称:iaproject,代码行数:34,代码来源:ia.py

示例4: read_output

    def read_output(self,settings):
      # Code to write for collecting the output files from the algorithm, writes to the
      # output list in the object
      # What we want to do here is get the prediction rate on the last time
      # point and the network so we can compare it against a gold std.
      # This file is a bunch of zscores, so we have to load the cutoff we want
      output_file = open(self.output_dir + "/output/ranked_edges.txt", 'r')
      topn = None
      if "top_n_edges" in settings["genie3"].keys():
        topn = settings["genie3"]["top_n_edges"]
      else:
        topn = len(self.gene_list)
      zscores = []
      for line in output_file:
          gene1, gene2, zscore = line.split()
          zscore = float(zscore)
          zscores.append((gene1, gene2, zscore))
      zscores = sorted(zscores, key=lambda zscore: abs(zscore[2]), reverse=True)

      self.zscores = zscores[:]
      network = []

      #for i,zscore in enumerate(zscores):
          #if i < topn:
            #gene1, gene2, zscore = zscore
            #zscores[i] = (gene1, gene2, 1)
          #else:
            #gene1, gene2, zscore = zscore
            #zscores[i] = (gene1, gene2, 0)
      net = Network()
      net.read_networklist(zscores)
      net.gene_list = self.gene_list
      self.network = net

      return self.zscores
开发者ID:remtcs,项目名称:Network-Inference-Workspace,代码行数:35,代码来源:genie3.py

示例5: memberVarience

def memberVarience(population, alpha):
    diffSum = 0.0
    for member in population:
        mg = Network.vectorizeMatrix(member.genome)
        ag = Network.vectorizeMatrix(alpha.genome)
        diffSum = diffSum + Network.outputError(mg, ag)
    return diffSum / len(population)
开发者ID:jerold,项目名称:CI-Project-3,代码行数:7,代码来源:trainingStrategy.py

示例6: handle_help

 def handle_help(command):
   mainString = "Try out the website! {}\n(Password: "+command.group.getPassword()+")"
   try:
     return mainString.format(Network.getIPAddress())
   except RuntimeError:
     IP = Network.readIPFile()
     if IP:
       return mainString.format(Network.readIPFile() + " (hopefully...)")
     return mainString.format("I have no idea what it is, but it probably exists! (Go yell at Daniel)")
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:9,代码来源:Commands.py

示例7: testUpdate

def testUpdate():
    
    input = [0.35,0.9] 
    MyNetwork = Network( (2,2,1) )
    
    MyNetwork.layers[0].nodes = np.array(input)
    MyNetwork.layers[1].weights = np.array([ [0.1,0.8],[0.4,0.6] ])
    MyNetwork.layers[2].weights = np.array([ [0.3,0.9] ])
       
    MyNetwork.update()      
开发者ID:EtienneDesticourt,项目名称:OCR-with-a-neural-network,代码行数:10,代码来源:tests.py

示例8: read_output

    def read_output(self, settings):
        # Code to write for collecting the output files from the algorithm, writes to the
        # output list in the object
        # What we want to do here is get the prediction rate on the last time
        # point and the network so we can compare it against a gold std.
        output_file = self.output_dir + "/output/" + "/nir_output.txt"

        net = Network()
        net.read_netmatrix_file(output_file, self.gene_list)
        self.network = net
开发者ID:remtcs,项目名称:Network-Inference-Workspace,代码行数:10,代码来源:nir.py

示例9: sendMsg

	def sendMsg(self, to_nick, format, *args):
		#sends a message to a nick as this client
		#eventually, will use the client's preferred notification method, for now it's PRIVMSGs
		#Network.sendMsg(IRCMessage(":", self.nick, "PRIVMSG", to_nick, format % args))
		if(isinstance(format, types.StringTypes)):
			text=format % args
		else:
			text=format
		
		for line in IRCMessage.wrapText(text):
			Network.sendMsg(IRCMessage(":", self.nick, "PRIVMSG", to_nick, line))
开发者ID:BasementCat,项目名称:ffservices,代码行数:11,代码来源:Pseudoclient.py

示例10: testHandshake

    def testHandshake(self):
        s = TestServer()
        c = TestConnection()
        c.connect("localhost")

        c.sendPacket("moikka")

        Network.communicate(100)
        client = s.clients.values()[0]
        assert client.packet == "moikka"
        assert client.id == 1
开发者ID:Hawkheart,项目名称:fof-reborn,代码行数:11,代码来源:NetworkTest.py

示例11: read_output

    def read_output(self,settings):
        # Code to write for collecting the output files from the algorithm, writes to the
      # output list in the object
      # What we want to do here is get the prediction rate on the last time
      # point and the network so we can compare it against a gold std.
      # This file is a bunch of zscores, so we have to load the cutoff we want
      output_file = self.output_dir + "/output/inferelator_output.csv"

      net = Network()
      net.read_netmatrix_file(output_file, self.gene_list)
      self.network = net

      return self.network
开发者ID:remtcs,项目名称:Network-Inference-Workspace,代码行数:13,代码来源:inferelator_pipeline.py

示例12: run

    def run(self, name, datafiles, goldnet_file):
        import numpy

        os.chdir(os.environ["gene_path"])

        datastore = ReadData(datafiles[0], "steadystate")
        for file in datafiles[1:]:
            datastore.combine(ReadData(file, "steadystate"))
        datastore.normalize()

        settings = {}
        settings = ReadConfig(settings)
        # TODO: CHANGE ME
        settings["global"]["working_dir"] = os.getcwd() + '/'

        # Setup job manager
        print "Starting new job manager"
        jobman = JobManager(settings)

        # Make GENIE3 jobs
        genie3 = GENIE3()
        genie3.setup(datastore, settings, name)

        print "Queuing job..."
        jobman.queueJob(genie3)

        print jobman.queue
        print "Running queue..."
        jobman.runQueue()
        jobman.waitToClear()

        print "Queue finished"
        job = jobman.finished[0]
        print job.alg.gene_list
        print job.alg.read_output(settings)
        jobnet = job.alg.network
        print "PREDICTED NETWORK:"
        print job.alg.network.network
        print jobnet.original_network

        if goldnet_file != None:
            goldnet = Network()
            goldnet.read_goldstd(goldnet_file)
            print "GOLD NETWORK:"
            print goldnet.network
            print jobnet.analyzeMotifs(goldnet).ToString()
            print jobnet.calculateAccuracy(goldnet)

        return jobnet.original_network
开发者ID:remtcs,项目名称:Network-Inference-Workspace,代码行数:49,代码来源:genie3.py

示例13: create_empty_network

def create_empty_network():
    """
    Args:
        None
    Returns:
        hidden_layers:  list of Neuron object lists representing the hidden layers
        output_layer:   list of Neuron objects representing the output layer
    Notes:

    """
    hidden_layers = []
    for item in range(const.NUM_HIDDEN_LAYERS):
        hidden_layers.append(Network.make_hidden_layer())
    output_layer = Network.make_output_layer()
    return hidden_layers, output_layer
开发者ID:jciochon,项目名称:251-project-2,代码行数:15,代码来源:main.py

示例14: __init__

 def __init__(self,speed=None,health=None,max_health=None,dmg=None,armor=None,size=None,brain=None,name="Yuval",location=None,turns=0):
     if speed == None:
         speed = attribute()
     if health == None:
         health = attribute()
     if max_health == None:
         max_health = attribute()
     if dmg == None:
         dmg = attribute()
     if armor == None:
         armor = attribute()
     if size == None:
         size = attribute()
     if location == None:
         location = [400,400]
     self.location = location
     if brain == None:
         brain = [3,2,3]
     brain1 = Network.network(brain)
     self.brain = brain1
     self.speed = speed
     self.health = health
     self.max_health = max_health
     self.dmg = dmg
     self.armor = armor
     self.size = size
     self.name = name
     self.speed.value = 20
     self.turns = turns
开发者ID:yuvalkk11e,项目名称:Deep-Wild,代码行数:29,代码来源:animal.py

示例15: search_by_tvrage_string

    def search_by_tvrage_string(self):
        """
        Search using TVRage's search API, with a string show name input.
        If it matches exactly (ignoring hyphens), then consider it a 100% match.
        Otherwise, score each potential match starting from the start_score.
        """
        for show_name in self.show_names:
            url = tvrage.SEARCH_URL % String.Quote(show_name, True)
            xml = Network.fetch_xml(url)

            i = 0
            for show_xml in xml.xpath("//show"):
                i += 1
                result_show = str(show_xml.xpath("./name")[0].text)

                if tvrage.sanitize_show_name(show_name) == tvrage.sanitize_show_name(result_show):
                    Log("Found exact match in title %s" % result_show)
                    score = 100
                else:
                    score = self.start_score - i

                nextResult = MetadataSearchResult(id=str(show_xml.xpath("./showid")[0].text),
                                                  name=result_show,
                                                  year=show_xml.xpath("./started")[0].text,
                                                  score=score,
                                                  lang=self.lang)
                self.results.Append(nextResult)
                Log(repr(nextResult))
开发者ID:cfairbanks,项目名称:Plex-Plugins,代码行数:28,代码来源:TVRageSearcher.py


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