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

Python Network.Network类代码示例

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

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



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

示例1: getTotalPosts

    def getTotalPosts(self,url):
        xmldoc = Network().getURL(url)
        if xmldoc:
            try:
                xmldoc = minidom.parse(xmldoc)
            except ExpatError:
                logging.debug('unxexpected xml format')
                return False
                #log
                #return flase
            except OSError:
                logging.debug('unxexpected os error ')
                return False


            else:

                try:
                    itemlist= xmldoc.getElementsByTagName('posts')
                    return itemlist[0].attributes['total'].value
                except ExpatError:
                    logging.debug("No posts or total, check url..")
                    #log
                    #return flase
                return False
开发者ID:NulledExceptions,项目名称:TumblrTheRipper,代码行数:25,代码来源:Scraper.py


示例2: test_addProcessingWithName_types_AndFail

	def test_addProcessingWithName_types_AndFail(self):
		net = Network(self.empty())
		try:
			net.types = "DummyPortSource"
			self.fail("Exception expected")
		except AssertionError, e:
			self.assertEquals("Wrong processing name: types is a method", e.__str__())
开发者ID:RushOnline,项目名称:clam-project,代码行数:7,代码来源:NetworkTests.py


示例3: test_set_config_attribute

	def test_set_config_attribute(self) :
		net = Network(self.empty())
		net.p = "AudioSource"
		self.assertEquals(['1'], net.p._outports.__dir__() )
		net.p.NSources = 2
		self.assertEquals(['1', '2'], net.p._outports.__dir__() )
		self.assertEquals(2, net.p.NSources)
开发者ID:RushOnline,项目名称:clam-project,代码行数:7,代码来源:NetworkTests.py


示例4: __init__

    def __init__(self, date=None):
        Network.__init__(self,date=date)
        if not date:
            self.date = '1970-01-01'

        edges = [(1, 2),
                 (1, 3),
                 (2, 4),
                 (3, 2),
                 (3, 5),
                 (4, 2),
                 (4, 5),
                 (4, 6),
                 (5, 6),
                 (5, 7),
                 (5, 8),
                 (6, 8),
                 (7, 1),
                 (7, 5),
                 (7, 8),
                 (8, 6),
                 (8, 7),
                 ]
        for edge in edges:
            self.add_edge(edge[0], edge[1], 1.0)
开发者ID:SuperbBob,项目名称:trust-metrics,代码行数:25,代码来源:Dummy.py


示例5: start_new

def start_new(dimensions, learning_rate):
    n = Network(dimensions, learning_rate)

    current_accuracy = accuracy(n, test)
    best_accuracy = 0.0
    best_net = copy.deepcopy(n)

    for j in range(800):
        if j % 2 == 0:
            new_accuracy = accuracy(n, test)
            print(str(j) + ": " + str(new_accuracy))

            diff = abs(current_accuracy - new_accuracy) / (current_accuracy + new_accuracy) * 100
            if diff < 0.01:
                n.learning_rate = l_rate * 2
            else:
                n.learning_rate = l_rate

            if new_accuracy > best_accuracy:
                best_accuracy = new_accuracy
                best_net = copy.deepcopy(n)

            current_accuracy = new_accuracy

        for i in range(len(train)):
            n.cycle(train[i][:-1], convert_to_output_list(train[i][-1]))

    pickle.dump(best_net, open('best_net.p', 'wb'))
开发者ID:alloba,项目名称:NeuralNetwork,代码行数:28,代码来源:trainingmethods.py


示例6: scrapePage

    def scrapePage(self, url):
        tumblrPage=Network.getURL(url)
        if not (tumblrPage):
            pass

        try:
            xmldoc = minidom.parse(tumblrPage)
            postlist = xmldoc.getElementsByTagName('post')
        except ExpatError:
            logging.debug('unxexpected xml format')
            pass
        except AttributeError:
            logging.debug('unxexpected ATTRIBUTE ERROR')
            pass
            # log
            # return flase
        else:
            if((postlist or xmldoc)==False):
                pass
            for eachpost in postlist:
                #logging.debug(eachpost.attributes['type'].value)
                if (self.tagging):
                    if not self.checkTags(eachpost):
                        continue

                if eachpost.attributes['type'].value == 'photo':
                    caption = self.checkCaption(eachpost)
                    urls =eachpost.getElementsByTagName('photo-url')


                    for eachurl in urls:
                        imageUrl = self.getImageUrl(eachurl)
                        if imageUrl:
                            imageFile=Network.getURL(imageUrl)
                            if imageFile:
                                #logging.debug(imageFile.headers.items())
                                imageFilename=Parser.formatImageName(imageUrl)
                                if(imageFilename):
                                    Parser.writeFile(imageFilename,imageFile)
                                    #logging.debug(eachpost.attributes.keys())
                                    image={
                                        'name':imageFilename,
                                        'caption':caption,
                                        'account':eachpost.attributes['id'].value,
                                        'url':eachpost.attributes['url'].value,
                                        'id': eachpost.attributes['id'].value,
                                        'source':eachpost.attributes['url-with-slug'].value

                                    }
                                    SQLLITE().insertImage(image)

                if eachpost.attributes['type'].value == 'video':
                    videoUrl= self.getVideoUrl(eachpost)
                    if videoUrl:
                        videoFile=Network.getURL(videoUrl)
                        if videoFile:
                            videoFilename = Parser.formatVideoName(videoUrl)
                            if videoFilename:
                                Parser.writeFile(videoFilename,videoFile)
开发者ID:NulledExceptions,项目名称:TumblrTheRipper,代码行数:59,代码来源:Scraper.py


示例7: test_code_whenNameIsAKeyword

	def test_code_whenNameIsAKeyword(self) :
		net = Network(self.empty())
		net["while"] = "DummyPortSource"
		self.assertEquals(
			"network[\"while\"] = 'DummyPortSource'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:8,代码来源:NetworkTests.py


示例8: test_code_whenNameHasUnderlines

	def test_code_whenNameHasUnderlines(self) :
		net = Network(self.empty())
		net.name_with_underlines = "DummyPortSource"
		self.assertEquals(
			"network.name_with_underlines = 'DummyPortSource'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:8,代码来源:NetworkTests.py


示例9: test_addProcessingAsItem

	def test_addProcessingAsItem(self) :
		net = Network(self.empty())
		net["processing1"] = "DummyPortSource"
		self.assertEquals(
			"network.processing1 = 'DummyPortSource'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:8,代码来源:NetworkTests.py


示例10: test_set_config_attribute_with_hold_apply

	def test_set_config_attribute_with_hold_apply(self) :
		net = Network(self.empty())
		net.p = "AudioSource"
		c = net.p._config
		c.hold()
		c.NSources = 2
		self.assertEquals(1, net.p.NSources)
		c.apply()
		self.assertEquals(2, net.p.NSources)
开发者ID:RushOnline,项目名称:clam-project,代码行数:9,代码来源:NetworkTests.py


示例11: test_clone_and_apply

	def test_clone_and_apply(self) :
		net = Network(self.empty())
		net.p = "AudioSource"
		c = net.p._config.clone()
		c.NSources = 2
		self.assertEquals(1, net.p.NSources)
		self.assertEquals(2, c.NSources)
		net.p._config = c
		self.assertEquals(2, net.p.NSources)
开发者ID:RushOnline,项目名称:clam-project,代码行数:9,代码来源:NetworkTests.py


示例12: test_deleteProcessingAsItem

	def test_deleteProcessingAsItem(self):
		net = Network(self.empty())
		net["processing1"] = "DummyPortSource"
		net["processing2"] = "DummyPortSink"
		del net["processing1"]
		self.assertEquals(
			"network.processing2 = 'DummyPortSink'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:10,代码来源:NetworkTests.py


示例13: test_deleteProcessingAsAttribute

	def test_deleteProcessingAsAttribute(self):
		net = Network(self.empty())
		net.processing1 = "DummyPortSource"
		net.processing2 = "DummyPortSink"
		del net.processing1
		self.assertEquals(
			"network.processing2 = 'DummyPortSink'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:10,代码来源:NetworkTests.py


示例14: gen_anomaly_dot

def gen_anomaly_dot(ano_list, netDesc, normalDesc, outputFileName):
    net = Network()
    net.init(netDesc, normalDesc)
    for ano_desc in ano_list:
        ano_type = ano_desc['anoType'].lower()
        AnoClass = ano_map[ano_type]
        A = AnoClass(ano_desc)
        net.InjectAnomaly( A )

    net.write(outputFileName)
开发者ID:JBonsink,项目名称:GSOC-2013,代码行数:10,代码来源:API.py


示例15: test_code_for_changing_config_attributes

	def test_code_for_changing_config_attributes(self):
		net = Network(self.empty())
		net.proc1 = "DummyProcessingWithStringConfiguration"
		net.proc1.AString = 'newvalue'
		self.assertMultiLineEqual(
			"network.proc1 = 'DummyProcessingWithStringConfiguration'\n"
			"network.proc1['AString'] = 'newvalue'\n"
			"network.proc1['OtherString'] = 'Another default value'\n"
			"\n\n"
			, net.code(fullConfig=True))
开发者ID:RushOnline,项目名称:clam-project,代码行数:10,代码来源:NetworkTests.py


示例16: test_route_length

def test_route_length(num_simulations, mixing_probability, drop_percentage):
    cumulative_length = 0
    for i in range(num_simulations):
        manet = Network()
        manet.init()
        result, length = manet.run(
            drop_percentage=drop_percentage, mixing_probability=mixing_probability
        )
        cumulative_length += length
    return cumulative_length / num_simulations
开发者ID:bpourkazemi,项目名称:MANET_simulator,代码行数:10,代码来源:simulator.py


示例17: parseXml

 def parseXml(node):
     field = Field()
     for child in node.childNodes:
         if child.tagName == Coordinates.getXmlName():
             field.addBoundary(Coordinates.parseXml(child))
         if child.tagName == Network.getXmlName():
             field.addNetwork(Network.parseXml(child))
         if child.tagName == District.getXmlName():
             field.addDistrict(District.parseXml(child))
     return field
开发者ID:Redoxee,项目名称:city_creator_esgi,代码行数:10,代码来源:Field.py


示例18: test_addTwoProcessingsDifferentType

	def test_addTwoProcessingsDifferentType(self) :
		net = Network(self.empty())
		net.processing1 = "DummyPortSource"
		net.processing2 = "DummyPortSink"
		self.assertEquals(
			"network.processing1 = 'DummyPortSource'\n"
			"network.processing2 = 'DummyPortSink'\n"
			"\n"
			"\n"
			, net.code())
开发者ID:RushOnline,项目名称:clam-project,代码行数:10,代码来源:NetworkTests.py


示例19: test_robustness

def test_robustness(num_simulations, drop_percentage):
    success, failure = 0, 0
    for i in range(num_simulations):
        manet = Network()
        manet.init()
        result = manet.run(drop_percentage=drop_percentage)
        if result:
            success += 1
        else:
            failure += 1
    return (success, failure, num_simulations)
开发者ID:bpourkazemi,项目名称:MANET_simulator,代码行数:11,代码来源:simulator.py


示例20: test_is_public

 def test_is_public(self):
     net = Network(IPv4Address('192.168.255.128'), 25)
     self.assertFalse(net.is_public())
     net = Network(IPv4Address('191.168.255.128'), 25)
     self.assertTrue(net.is_public())
     net = Network(IPv4Address('127.168.255.128'), 25)
     self.assertFalse(net.is_public())
     net = Network(IPv4Address('172.20.255.128'), 25)
     self.assertFalse(net.is_public())
     net = Network(IPv4Address('10.20.255.128'), 25)
     self.assertFalse(net.is_public())
开发者ID:malaman,项目名称:network_router,代码行数:11,代码来源:test_Network.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python NeuralNetwork.NeuralNetwork类代码示例发布时间:2022-05-24
下一篇:
Python Netflix.netflix_solve函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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