本文整理汇总了Python中sieve.sieve函数的典型用法代码示例。如果您正苦于以下问题:Python sieve函数的具体用法?Python sieve怎么用?Python sieve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sieve函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test3
def test3():
s = sieve.sieve()
i = iter(s)
for x in sieve.sieve():
if x > 151:
break
assert x == 157
print x
开发者ID:mtruong09,项目名称:cse491-numberz,代码行数:8,代码来源:test3.py
示例2: test2
def test2():
s = sieve.sieve()
i = iter(s)
for x in sieve.sieve():
if x > 10:
break
assert x == 11
print x
开发者ID:mtruong09,项目名称:cse491-numberz,代码行数:8,代码来源:test2.py
示例3: test3
def test3():
sieveInstance = sieve.sieve()
i = iter(sieveInstance)
i.next()
i.next()
assert i.next() == 7
print "Test 3 Passes"
开发者ID:AdamPro13,项目名称:cse491-numberz,代码行数:7,代码来源:test.py
示例4: test
def test(r):
print 'Running test for', r, 'items'
for n, i in zip(range(r), sieve.sieve()):
print i
print '\n'
开发者ID:credwards27,项目名称:cse491-numberz,代码行数:7,代码来源:example.py
示例5: test1
def test1():
s = sieve.sieve() #create an object of type sieve
i = iter(s) #create an interator for the object sieve
#Check if next value is equal to 3
#Error would occur if the value is not equal to 3
assert i.next() == 3
开发者ID:chuy2412,项目名称:cse491-numberz,代码行数:7,代码来源:test1.py
示例6: test1
def test1():
s = sieve.sieve() #make a sieve object from file sieve
i = iter(s) #make iterator
val=i.next() #run iterator once, put value in val
assert val == 3 #check if value is 3. if not 3, fail.
print "Value should be 3, actual value is:"
print val
开发者ID:khessiny,项目名称:cse491-numberz,代码行数:7,代码来源:test1.py
示例7: factorize
def factorize(p):
"""Returns a list of the prime factors of p.
If a number is a factor multiple times (such as with squares or cubes),
it will be included in the factor list once for each multiplication.
If p is itself prime, returns a list consisting of one element, p.
Args:
p: integer, the number for which to find prime factors.
Returns:
A list of the prime factors for p, or an empty list if p < 2.
Raises:
ValueError: p is < 2.
"""
primes = sieve(p)
# If p is prime, it should be at the end of the list and will have
# no other factors
if primes[-1] == p:
return [p]
factors = []
for prime in primes:
if p == 1:
break
# Use while instead of if for squares, cubes, etc
while p % prime == 0:
factors.append(prime)
p /= prime
return factors
开发者ID:mmweber2,项目名称:adm,代码行数:31,代码来源:factorize.py
示例8: createAlgsList
def createAlgsList(self):
# First we populate the list of algorithms with those created
# extending GeoAlgorithm directly (those that execute GDAL
# using the console)
self.preloadedAlgs = [nearblack(), information(), warp(), translate(),
rgb2pct(), pct2rgb(), merge(), buildvrt(), polygonize(), gdaladdo(),
ClipByExtent(), ClipByMask(), contour(), rasterize(), proximity(),
sieve(), fillnodata(), ExtractProjection(), gdal2xyz(),
hillshade(), slope(), aspect(), tri(), tpi(), roughness(),
ColorRelief(), GridInvDist(), GridAverage(), GridNearest(),
GridDataMetrics(), gdaltindex(), gdalcalc(), rasterize_over(),
# ----- OGR tools -----
OgrInfo(), Ogr2Ogr(), Ogr2OgrClip(), Ogr2OgrClipExtent(),
Ogr2OgrToPostGis(), Ogr2OgrToPostGisList(), Ogr2OgrPointsOnLines(),
Ogr2OgrBuffer(), Ogr2OgrDissolve(), Ogr2OgrOneSideBuffer(),
Ogr2OgrTableToPostGisList(), OgrSql(),
]
# And then we add those that are created as python scripts
folder = self.scriptsFolder()
if os.path.exists(folder):
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(self.scriptsFolder(),
descriptionFile)
alg = GdalScriptAlgorithm(fullpath)
self.preloadedAlgs.append(alg)
except WrongScriptException as e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
开发者ID:Geoneer,项目名称:QGIS,代码行数:30,代码来源:GdalOgrAlgorithmProvider.py
示例9: test2
def test2():
s = sieve.sieve()
i = iter(s)
for x in range(4):
i.next()
assert i.next() == 13
开发者ID:andre223,项目名称:cse491-numberz,代码行数:7,代码来源:test2.py
示例10: test1
def test1():
s = sieve.sieve()
i = iter(s)
n = i.next()
print n
assert n == 3
print "***Test 1 passed!***"
开发者ID:savelama,项目名称:cse491-numberz,代码行数:7,代码来源:test.py
示例11: test3
def test3():
"3 is a bigger number than 2 or 1, and thats a fact"
s = sieve.sieve()
i = iter(s)
i.next()
i.next()
assert i.next() == 7
开发者ID:Tempas,项目名称:cse491-numberz,代码行数:7,代码来源:test.py
示例12: test2
def test2():
s = sieve.sieve()
i = iter(s)
print i.next()
print i.next()
assert i.next() == 7
print "***Test 2 passed!***"
开发者ID:savelama,项目名称:cse491-numberz,代码行数:7,代码来源:test.py
示例13: test3
def test3():
s = sieve.sieve()
i = iter(s)
for x in range(8):
i.next()
assert i.next() == 29
开发者ID:andre223,项目名称:cse491-numberz,代码行数:7,代码来源:test3.py
示例14: test2
def test2():
s = sieve.sieve() # create an object of type sieve
s.next() # move to the next prime number (3)
# Check if next value is equal to 5
# Error would occur if the value is not equal to 5
assert s.next() == 5
开发者ID:chuy2412,项目名称:cse491-numberz,代码行数:8,代码来源:test2.py
示例15: test3
def test3():
primes_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
ctr = 1
for n, i in zip(sieve.sieve(), primes_list):
if ctr == 11:
break
assert n == i
ctr += 1
开发者ID:FauxJake,项目名称:cse491-numberz,代码行数:8,代码来源:test.py
示例16: test2
def test2():
s = sieve.sieve()
i = iter(s)
for x in range(3):
i.next()
assert i.next() == 11 # the fifth prime number should be 11
开发者ID:mcl0720,项目名称:cse491-numberz,代码行数:8,代码来源:test2.py
示例17: test2
def test2():
sve = sieve.sieve()
i = iter(sve)
nxt = i.next()
print nxt
nxt = i.next()
print nxt
assert nxt == 5
开发者ID:mill2121,项目名称:cse491-numberz,代码行数:8,代码来源:test1.py
示例18: test3
def test3():
s = sieve.sieve() # make a sieve object from file sieve
i = iter(s) # make iterator
val = i.next() # run iterator once, put value in val
assert val != 2 # check if value not 2
print "Value should not be 2, actual value is:"
print val
开发者ID:khessiny,项目名称:cse491-numberz,代码行数:8,代码来源:test3.py
示例19: test3
def test3():
s = sieve.sieve()
i = iter(s)
for c in range(10):
print i.next()
assert i.next() == 37
print "***Test 3 passed!***"
开发者ID:savelama,项目名称:cse491-numberz,代码行数:9,代码来源:test.py
示例20: test2
def test2():
s = sieve.sieve()
i = iter(s)
for n in range(10):
i.next()
assert i.next() == 37
开发者ID:acromarti,项目名称:cse491-numberz,代码行数:9,代码来源:test2.py
注:本文中的sieve.sieve函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论