当前位置: 首页>>代码示例>>Python>>正文


Python Parameter.checkBoolean方法代码示例

本文整理汇总了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
开发者ID:charanpald,项目名称:sandbox,代码行数:9,代码来源:TreeRankForest.py

示例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
开发者ID:charanpald,项目名称:sandbox,代码行数:5,代码来源:RankNode.py

示例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
开发者ID:charanpald,项目名称:sandbox,代码行数:5,代码来源:RankNode.py

示例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
开发者ID:charanpald,项目名称:sandbox,代码行数:68,代码来源:GraphStatistics.py


注:本文中的sandbox.util.Parameter.Parameter.checkBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。