本文整理匯總了Python中MA.repeat方法的典型用法代碼示例。如果您正苦於以下問題:Python MA.repeat方法的具體用法?Python MA.repeat怎麽用?Python MA.repeat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MA
的用法示例。
在下文中一共展示了MA.repeat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: replicate_axis
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import repeat [as 別名]
def replicate_axis(data, axis, size):
"""
Returns a new array with an additional axis of the specified size.
The new axis is formed by replicating along the other axes.
"""
assert axis > 0
repeat_map = size * Numeric.ones(data.shape[axis-1])
shape = list(data.shape)
data = MA.repeat(data, repeat_map, axis=axis-1)
shape.insert(axis, size)
data.shape = tuple(shape)
return data
示例2: testRepeat
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import repeat [as 別名]
def testRepeat (self):
"test repeat"
assert eq(MA.repeat(self.a, (0,1,2,3,0,0)), [1,2,2,3,3,3])
assert MA.repeat(self.a, (0,)*6).typecode() == self.a.typecode()
assert eq(MA.repeat(self.a, (0,)*6), [])
assert eq(MA.repeat(self.m, (0,2,1), -1), [[2,2,3],[12,12,13]])