本文整理汇总了Python中sandbox.util.Parameter.Parameter.checkList方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.checkList方法的具体用法?Python Parameter.checkList怎么用?Python Parameter.checkList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sandbox.util.Parameter.Parameter
的用法示例。
在下文中一共展示了Parameter.checkList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: subList
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkList [as 别名]
def subList(self, indices):
"""
Returns a subset of this object, indicated by the given indices.
"""
Parameter.checkList(indices, Parameter.checkIndex, (0, self.getNumVertices()))
vList = HIVVertices(len(indices))
vList.setVertices(self.getVertices(indices))
return vList
示例2: expandIntArray
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkList [as 别名]
def expandIntArray(v):
"""
Take a vector of integers and expand it into a vector with counts of the
corresponding integers. For example, with v = [1, 3, 2, 4], the expanded
vector is [0, 1, 1, 1, 2, 2, 3, 3, 3, 3].
"""
Parameter.checkClass(v, numpy.ndarray)
Parameter.checkList(v, Parameter.checkInt, [0, float("inf")])
w = numpy.zeros(numpy.sum(v), numpy.int)
currentInd = 0
for i in range(v.shape[0]):
w[currentInd : currentInd + v[i]] = i
currentInd += v[i]
return w
示例3: categoricalToIndicator
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkList [as 别名]
def categoricalToIndicator(self, X, indices):
"""
Convert a set of categorical variables to indicator ones.
"""
Parameter.checkList(indices, Parameter.checkIndex, (0, X.shape[1]))
X2 = numpy.zeros((X.shape[0], 0))
for i in range(X.shape[1]):
if i in indices:
categories = numpy.unique(X[:, i])
Z = numpy.zeros((X.shape[0], categories.shape[0]))
for j in range(categories.shape[0]):
Z[:, j] = X[:, i] == categories[j]
X2 = numpy.c_[X2, Z]
else:
X2 = numpy.c_[X2, X[:, i]]
return X2