本文整理汇总了Python中sandbox.util.Parameter.Parameter.checkBoolean方法的典型用法代码示例。如果您正苦于以下问题:Python Parameter.checkBoolean方法的具体用法?Python Parameter.checkBoolean怎么用?Python Parameter.checkBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sandbox.util.Parameter.Parameter
的用法示例。
在下文中一共展示了Parameter.checkBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setSampleReplace
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkBoolean [as 别名]
def setSampleReplace(self, sampleReplace):
"""
:param sampleReplace: A boolean to decide whether to sample with replacement.
:type sampleReplace: :class:`bool`
"""
Parameter.checkBoolean(sampleReplace)
self.sampleReplace = sampleReplace
示例2: setPure
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkBoolean [as 别名]
def setPure(self, pure):
Parameter.checkBoolean(pure)
self.pure = pure
示例3: setIsLeafNode
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkBoolean [as 别名]
def setIsLeafNode(self, leafNode):
Parameter.checkBoolean(leafNode)
self.leafNode = leafNode
示例4: scalarStatistics
# 需要导入模块: from sandbox.util.Parameter import Parameter [as 别名]
# 或者: from sandbox.util.Parameter.Parameter import checkBoolean [as 别名]
def scalarStatistics(self, graph, slowStats=True, treeStats=False):
"""
Find a series of statistics for the given input graph which can be represented
as scalar values. Return results as a vector.
"""
if graph.is_directed():
raise ValueError("Only works on undirected graphs")
#This method is a bit of a mess
Parameter.checkBoolean(slowStats)
Parameter.checkBoolean(treeStats)
statsArray = numpy.ones(self.numStats)*-1
statsArray[self.numVerticesIndex] = graph.vcount()
statsArray[self.numEdgesIndex] = graph.ecount()
statsArray[self.numDirEdgesIndex] = graph.as_directed().ecount()
statsArray[self.densityIndex] = graph.density()
logging.debug("Finding connected components")
subComponents = graph.components()
logging.debug("Done")
statsArray[self.numComponentsIndex] = len(subComponents)
nonSingletonSubComponents = [c for c in subComponents if len(c) > 1]
statsArray[self.numNonSingletonComponentsIndex] = len(nonSingletonSubComponents)
triOrMoreSubComponents = [c for c in subComponents if len(c) > 2]
statsArray[self.numTriOrMoreComponentsIndex] = len(triOrMoreSubComponents)
componentSizes = numpy.array([len(c) for c in subComponents])
inds = numpy.flipud(numpy.argsort(componentSizes))
logging.debug("Studying max component")
if len(subComponents) != 0:
maxCompGraph = graph.subgraph(subComponents[inds[0]])
statsArray[self.maxComponentSizeIndex] = len(subComponents[inds[0]])
if len(subComponents) >= 2:
statsArray[self.secondComponentSizeIndex] = len(subComponents[inds[1]])
statsArray[self.maxComponentEdgesIndex] = maxCompGraph.ecount()
statsArray[self.meanComponentSizeIndex] = componentSizes.mean()
statsArray[self.maxCompMeanDegreeIndex] = numpy.mean(maxCompGraph.degree(mode=igraph.OUT))
else:
statsArray[self.maxComponentSizeIndex] = 0
statsArray[self.maxComponentEdgesIndex] = 0
statsArray[self.meanComponentSizeIndex] = 0
statsArray[self.geodesicDistMaxCompIndex] = 0
if graph.vcount() != 0:
statsArray[self.meanDegreeIndex] = numpy.mean(graph.degree(mode=igraph.OUT))
else:
statsArray[self.meanDegreeIndex] = 0
if slowStats:
logging.debug("Computing diameter")
statsArray[self.diameterIndex] = graph.diameter()
#statsArray[self.effectiveDiameterIndex] = graph.effectiveDiameter(self.q, P=P)
#statsArray[self.powerLawIndex] = graph.fitPowerLaw()[0]
logging.debug("Computing geodesic distance")
statsArray[self.geodesicDistanceIndex] = graph.average_path_length()
if len(subComponents) != 0:
statsArray[self.geodesicDistMaxCompIndex] = graph.average_path_length(P=P, vertexInds=list(subComponents[inds[0]]))
return statsArray