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


Python Analyzer.computeMetrics方法代码示例

本文整理汇总了Python中Analyzer.Analyzer.computeMetrics方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.computeMetrics方法的具体用法?Python Analyzer.computeMetrics怎么用?Python Analyzer.computeMetrics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Analyzer.Analyzer的用法示例。


在下文中一共展示了Analyzer.computeMetrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: len

# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import computeMetrics [as 别名]
    if len(args.functions) == 0 or True in [analyzer.functionMatches(fn, functionName) for fn in args.functions]:
        functions.append(functionName.upper())
functions.sort()

resultDir = args.name
if resultDir[-1] == "/":
    resultDir = resultDir[:-1];
if os.path.exists(resultDir):
    newResultDir = "%s-%s" % (resultDir, time.strftime("%Y%m%d-%H%M%S"))
    print "Backing up previous selection at '%s' to '%s'" % (resultDir, newResultDir)
    shutil.move(resultDir, newResultDir)

os.mkdir(resultDir)
for functionName in functions:
    print "Selecting best result for %s" % functionName
    analyzer.computeMetrics(functionName)
    bestIdx = analyzer.getCurrentBestResult()
    bestName = analyzer.resultNames[bestIdx]
    bestDir = analyzer.resultDirectories[bestIdx]
    print "    The best is %s" % bestName
    
    filesCopied = 0
    for filename in dircache.listdir(bestDir):
        filename = str(bestDir + "/" + filename)
        if not Utils.isSolutionFile(filename) or not Utils.isFunctionFile(filename):
            continue
        
        fnId = Utils.getFunctionName(filename).lower()
        genPos = max(-1, fnId.rfind("."), fnId.rfind("-"), fnId.rfind("_"))
        if genPos >= 0:
            fnId = fnId[:genPos]
开发者ID:wkoder,项目名称:mooi,代码行数:33,代码来源:select.py

示例2: LatexReporter

# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import computeMetrics [as 别名]

#.........这里部分代码省略.........
        #latex.append("            \\begin{adjustwidth}{-0.2\\textwidth}{}")
        #latex.append("            \\resizebox{1.4\\textwidth}{!}{\\input{%s}}" % filename)
        latex.append("            \\resizebox{\\textwidth}{!}{\\input{%s}}" % filename)
        #latex.append("            \\end{adjustwidth}")
        latex.append("            {%s}" % caption)
        latex.append("        \\end{center}")
        return "\n".join(latex)
    
    def _getFiguresLatex(self, filenames, captions, presentation, overallCaption="", label=""):
        n = len(filenames)
        latex = []
        if presentation or n == 1:
            for i in xrange(n):
                latex.append(self._getFigureLatex(filenames[i], captions[i], presentation))
        else:
            latex.append("\\begin{figure}[!ht]")
            latex.append("    \\begin{center}")
            latex.append("    \\begin{minipage}{0.47\\textwidth}")
            for i in xrange(0, n, 2):
                latex.append(self._getCombinedFigureLatex(filenames[i], "(" + chr(ord("a") + i) + ") " + captions[i]))
            latex.append("    \\end{minipage}")
            latex.append("    \\hspace{5mm}")
            latex.append("    \\begin{minipage}{0.47\\textwidth}")
            for i in xrange(1, n, 2):
                latex.append(self._getCombinedFigureLatex(filenames[i], "(" + chr(ord("a") + i) + ") " + captions[i]))
            latex.append("    \\end{minipage}")
            latex.append("    \\end{center}")
            latex.append("    \\caption{\\label{%s} %s.}" % (label, overallCaption))
            latex.append("\\end{figure}")
    
        return "\n".join(latex)
    
    def _getFunctionLatex(self, functionName, reportDir, highlight, presentation):
        self.analyzer.computeMetrics(functionName)
        
        subdir = "" if len(self.identifier) == 0 else self.identifier + "/"
        imageDir = reportDir + Analyzer.__IMAGES_DIR__ + subdir
        if not os.path.exists(imageDir):
            os.makedirs(imageDir)
        
        if highlight is None:
            desc = "todos los algoritmos"
        else:
            desc = Utils.getResultNameLatex(highlight)
        caption = "ejecuci\\'{o}n de %s al resolver el problema %s (de acuerdo a %s)" % \
                (desc, Utils.getFunctionNameLatex(functionName), Utils.getMetricNameLatex("Delta P"))
        
        latex = []
        if presentation:
            bestImage = Analyzer.__IMAGES_DIR__ + functionName + "_best_fun.tex"
            self.analyzer.generateImages(functionName, [highlight], [reportDir + ":" + bestImage], 0, True)
            latex = [self._getFigureLatex(bestImage, "Mejor %s" % caption, presentation)]
            
            worstImage = Analyzer.__IMAGES_DIR__ + functionName + "_worst_fun.tex"
            self.analyzer.generateImages(functionName, [highlight], [reportDir + ":" + worstImage], 1, True)
            latex.append(self._getFigureLatex(worstImage, "Peor %s" % caption, presentation))
        else:
            images = []
            captions = []
            for i in xrange(len(self.analyzer.metrics.unaryMetricNames)):
                metricName = self.analyzer.metrics.unaryMetricNames[i]
                filename = Analyzer.__IMAGES_DIR__ + subdir + functionName + "_ind_" + metricName.replace(" ", "") + ".tex"
                self.analyzer.generateMetricImage(functionName, metricName, i, reportDir + ":" + filename, True)
                
                images.append(filename)
                captions.append("Indicador %s" % Utils.getMetricNameLatex(metricName))
开发者ID:wkoder,项目名称:mooi,代码行数:70,代码来源:LatexReporter.py


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