本文整理汇总了Python中numpy.lib.shape_base.tile函数的典型用法代码示例。如果您正苦于以下问题:Python tile函数的具体用法?Python tile怎么用?Python tile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tile函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_empty
def test_empty(self):
a = np.array([[[]]])
b = np.array([[], []])
c = tile(b, 2).shape
d = tile(a, (3, 2, 5)).shape
assert_equal(c, (2, 0))
assert_equal(d, (3, 2, 0))
开发者ID:ContinuumIO,项目名称:numpy,代码行数:7,代码来源:test_shape_base.py
示例2: __init__
def __init__(self, L, N):
self.deltaX = float(L / float(N))
self.N = int(N + 1)
self.M = self.N
self.L = float(L)
self.X = []
# TODO !!! move this part to __call__ method
self.A = array(zeros([self.M, self.M]))
#self.filtera = array(self.A +1, dtype=bool)
self.filtera = self.A == self.A # COOL ! :)
self.DOF = array(tile(True, (self.M)), dtype=bool)
for i in range(self.M): # assuming DX=Constant
self.X.append(round(self.deltaX*i, 15)) # To avoid stupid 0.199
self.B = array(zeros([self.M, 1]))
self.T = array(tile(nan, (self.M,)))
# TODO for solve method
self.bcConduction = array(tile(False, (self.M, )), dtype=bool)
self.bcConvection = array(tile(False, (self.M, )), dtype=bool)
self.bcT = array(tile(True, (self.M, )), dtype=bool)
#self.bcRadiation = array(tile(False, (self.M, 1)), dtype=bool)
internalNodes = array([1., -2., 1.])
#
for i in range(1, int(self.M-1)):
# self.A[i, range(i-1, i+2)] = internalNodes
self.B[i] *= self.deltaX**2
开发者ID:guneysu-arsiv,项目名称:pytotube,代码行数:32,代码来源:pytotube.py
示例3: test_kroncompare
def test_kroncompare(self):
from numpy.random import randint
reps = [(2,), (1, 2), (2, 1), (2, 2), (2, 3, 2), (3, 2)]
shape = [(3,), (2, 3), (3, 4, 3), (3, 2, 3), (4, 3, 2, 4), (2, 2)]
for s in shape:
b = randint(0, 10, size=s)
for r in reps:
a = np.ones(r, b.dtype)
large = tile(b, r)
klarge = kron(a, b)
assert_equal(large, klarge)
开发者ID:ContinuumIO,项目名称:numpy,代码行数:12,代码来源:test_shape_base.py
示例4: test_basic
def test_basic(self):
a = np.array([0, 1, 2])
b = [[1, 2], [3, 4]]
assert_equal(tile(a, 2), [0, 1, 2, 0, 1, 2])
assert_equal(tile(a, (2, 2)), [[0, 1, 2, 0, 1, 2], [0, 1, 2, 0, 1, 2]])
assert_equal(tile(a, (1, 2)), [[0, 1, 2, 0, 1, 2]])
assert_equal(tile(b, 2), [[1, 2, 1, 2], [3, 4, 3, 4]])
assert_equal(tile(b, (2, 1)), [[1, 2], [3, 4], [1, 2], [3, 4]])
assert_equal(tile(b, (2, 2)), [[1, 2, 1, 2], [3, 4, 3, 4], [1, 2, 1, 2], [3, 4, 3, 4]])
开发者ID:SoumitraAgarwal,项目名称:numpy,代码行数:9,代码来源:test_shape_base.py
示例5: classify
def classify(inX,dataSet,labels,k):
dataSetSize = dataSet.shape[0]
diffMat = tile(inX,(dataSetSize,1)) -dataSet # 算距离
print(diffMat)
sqDiffMat = diffMat**2
sqDistances = sqDiffMat.sum(axis=1) #
distances = sqDistances**0.5 #
print(sqDistances)
sortedDistIndicies = distances.argsort()
classCount = {}
for i in range(k): # 距离最小的k个点
voteIlabel = labels[sortedDistIndicies[i]]
classCount[voteIlabel] = classCount.get(voteIlabel,0) + 1
sortedClassCount = sorted(classCount.items(),key=operator.itemgetter(1),reverse=True) # 排序
print(sortedClassCount)
return sortedClassCount[0][0]
开发者ID:Codefans-fan,项目名称:p2pSpider,代码行数:16,代码来源:knn.py
示例6: test_tile_one_repetition_on_array_gh4679
def test_tile_one_repetition_on_array_gh4679(self):
a = np.arange(5)
b = tile(a, 1)
b += 2
assert_equal(a, np.arange(5))
开发者ID:ContinuumIO,项目名称:numpy,代码行数:5,代码来源:test_shape_base.py
示例7: test_empty
def test_empty(self):
a = np.array([[[]]])
d = tile(a, (3, 2, 5)).shape
assert_equal(d, (3, 2, 0))
开发者ID:7924102,项目名称:numpy,代码行数:4,代码来源:test_shape_base.py
注:本文中的numpy.lib.shape_base.tile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论