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


Python Network.Network类代码示例

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


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


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