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


Python Analyzer.getFunctionNames方法代码示例

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


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

示例1: MainWindow

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

#.........这里部分代码省略.........

    def removeResult(self):
        layout = self.solutionSelector.layout()
        for i in xrange(layout.count() - 1, -1, -1):
            item = layout.itemAt(i)
            if not item.widget().isChecked():  # and self.analyzer.resultNames[i] != Analyzer.__PARETO__:
                item.widget().setVisible(False)
                layout.removeItem(item)
                self.analyzer.removeResultDirectory(self.analyzer.resultDirectories[i])
        layout.update()

        settings = QSettings()
        settings.setValue(MainWindow.__PREF_DIR__, QVariant(self.analyzer.resultDirectories))

    def solutionSelected(self):
        selection = self.functionWidget.currentItem()
        if selection is None:
            return
        self.showSolution(str(selection.text()))

    def showSolution(self, functionName):
        self.currentSolution = self.analyzer.getResultsForFunction(functionName)
        self.metrics.clear()
        self._showSolution()

    def addSolutionForSelection(self, name):
        solution = QCheckBox(name)
        solution.setChecked(True)
        solution.stateChanged.connect(self._showSolution)
        self.solutionSelector.layout().addWidget(solution)
        self.solutionSelector.layout().update()

    def _updateSolutionSelection(self):
        self.clearWidget(self.solutionSelector)

        for directory in self.analyzer.resultDirectories:
            self.addSolutionForSelection(self.analyzer.getResultName(directory))

    def _showSolution(self):
        sol = self.currentSolution
        if sol is None:
            return

        if len(sol.variableImplementation) == 0 and self.showVariablesRadio.isEnabled():
            self.showVariablesRadio.setEnabled(False)
            if self.showVariablesRadio.isChecked():
                self.showSolutionsRadio.setChecked(True)
        else:
            self.showVariablesRadio.setEnabled(True)

        if len(sol.functionImplementation) == 0 and self.showSolutionsRadio.isEnabled():
            self.showSolutionsRadio.setEnabled(False)
            if self.showSolutionsRadio.isChecked():
                self.showVariablesRadio.setChecked(True)
        else:
            self.showSolutionsRadio.setEnabled(True)

        if self.showSolutionsRadio.isChecked():
            self.generationSlider.setMaximum(
                max([sol.getFunctionSolution(impl).count() for impl in sol.functionImplementation])
            )
        else:
            self.generationSlider.setMaximum(
                max([sol.getVariableSolution(impl).count() for impl in sol.variableImplementation])
            )
        self._exportCurrentImage()

    def clearWidget(self, widget):
        layout = widget.layout()
        for i in xrange(layout.count() - 1, -1, -1):
            layout.removeItem(layout.itemAt(i))

    def updateUI(self):
        self.statusBar().showMessage("Updating solutions...")

        selectedRow = self.functionWidget.currentRow()
        self.functionWidget.clear()
        names = [] + self.analyzer.getFunctionNames()
        names.sort()
        for name in names:
            item = QListWidgetItem()
            item.setText(name)
            self.functionWidget.addItem(item)

        if self.functionWidget.count() > 0:
            self.functionWidget.setCurrentRow(
                selectedRow if selectedRow >= 0 and selectedRow < self.functionWidget.count() else 0
            )
        self.statusBar().showMessage("Updated!", 5000)

    def _loadInitialData(self):
        self.updateUI()
        self.statusBar().showMessage("Ready!", 5000)

    def closeEvent(self, event):
        self.statusBar().showMessage("Closing...")
        settings = QSettings()
        settings.setValue(MainWindow.__PREF_GEOM__, self.saveGeometry())
        settings.setValue(MainWindow.__PREF_STATE__, self.saveState())
        self.plot.clear()
开发者ID:wkoder,项目名称:mooi,代码行数:104,代码来源:UI.py

示例2: Analyzer

# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import getFunctionNames [as 别名]
parser = argparse.ArgumentParser(description="Analyze Multi-Objective Optimization algorithm results against true Pareto fronts")
parser.add_argument("--name", "-n", help="name of the selected results")
parser.add_argument("--results", "-r", metavar="RESULT", nargs="+", help="results directory of an algorithm")
parser.add_argument("--functions", "-f", metavar="FUNCTION", nargs="*", help="function to test")
parser.add_argument("--pareto", "-p", help="true Pareto front directory")
args = parser.parse_args()

analyzer = Analyzer()
analyzer.setResultDirectories(args.results)
pareto = args.pareto
if pareto is None:
    pareto = os.path.dirname(__file__) + "/../resources/" + Analyzer.__PARETO__
analyzer.setPareto(pareto)
functions = []
for functionName in analyzer.getFunctionNames():
    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
开发者ID:wkoder,项目名称:mooi,代码行数:32,代码来源:select.py

示例3: LatexReporter

# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import getFunctionNames [as 别名]
class LatexReporter(object):
    
    __TEMPLATE_REPORT_FILE__ = "report.tex"
    __TEMPLATE_REPORT_DIR__ = Utils.__RESOURCES_DIR__ + "report/"
    __TEMPLATE_PRESENTATION_FILE__ = "presentation.tex"
    __TEMPLATE_PRESENTATION_DIR__ = Utils.__RESOURCES_DIR__ + "presentation/"
    __TEMPLATE_VAR__ = "%RESULTS%"
    __DATA_FORMAT__ = "%.4f"

    def __init__(self):
        self.analyzer = Analyzer("latex")
        
    def getFunctionNames(self, includeNotSolved=False):
        return self.analyzer.getFunctionNames(includeNotSolved)
    
    def setResultDirectories(self, results):
        self.analyzer.setResultDirectories(results)
        
    def setPareto(self, pareto):
        self.analyzer.setPareto(pareto)
    
    def _getBest(self, data):
        n = len(data)
        best = [False] * n
        maxValue = max(data)
        for i in xrange(n):
            if abs(maxValue - data[i]) < Utils.__EPS__:
                best[i] = True
                
        return best
    
    def _getBlockLatex(self, name, description, data1, data2, best):
        n = len(data1)
        if description is None or (len(description) == 1 and description[0] is None):
            latex = ["            \\multicolumn{2}{|c||}{%s}" % name]
        else:
            latex = ["            \\multirow{%d}{*}{%s}" % (n, name)]
        for block in xrange(n):
            latexRow = []
            if description is not None and description[block] is not None:
                latexRow.append(description[block])
            for i in xrange(len(data1[block])):
                latexRow.append(self.analyzer.getFormattedValue(data1[block][i], None if data2 is None \
                                                       else data2[block][i], best[block][i] if best is not None else False))
            latex.append("                & " + " & ".join(latexRow) + " \\\\")
        latex.append("                \\hline")
        return "\n".join(latex)
    
    def _getTableStartLatex(self, nColumns, big, presentation):
        latex = []
        if presentation:
            latex.append("\\begin{frame}")
            latex.append("\\frametitle{\insertsubsection}")
            latex.append("\\vspace*{-0.2cm}")
            
        latex.append("\\begin{table}")
        latex.append("    \\tiny \\centering")
        sizeFactor = ""
        if big:
            if presentation:
                sizeFactor = "1.1"
                cmOff = "-0.5"
            else:
                sizeFactor = "1.5"
                cmOff = "-3"
            latex.append("    \\begin{adjustwidth}{%scm}{%scm}" % (cmOff, cmOff))
            
        latex.append("        \\begin{tabularx}{%s\\textwidth}{| c | c || %s |}" % (sizeFactor, " | ".join(["K"] * nColumns)))
        latex.append("        \\hline")
        
        return "\n".join(latex)
    
    def _getTableEndLatex(self, caption, label, big, presentation):
        latex = ["        \\end{tabularx}"]
        if big:
            latex.append("    \\end{adjustwidth}")
        if caption is not None and label is not None:
            latex.append("    \\caption{\\label{%s} %s}" % (label, caption))
        latex.append("\\end{table}")
        if presentation:
            latex.append("\\end{frame}")
        return "\n".join(latex)
    
    def _getUnaryMetricLatex(self, data, functionNames):
        nm = self.analyzer.metrics.nUnaryMetrics
        nr = self.analyzer.nResults - 1
        nf = len(functionNames)
        nc = 2 + 4*nr

        latex = ["\\begin{sidewaystable}"]
        latex.append("    \\tiny \\centering")
        latex.append("    \\begin{tabularx}{\\textwidth}{| l | l |%s} \\hline" % (" K |" * 4*nr))
        
        header = "        \\multirow{2}{*}{Problema} & \\multirow{2}{*}{Indicador}"
        for resultName in self.analyzer.resultNames:
            if resultName != Analyzer.__PARETO__:
                header += " & \\multicolumn{4}{c|}{%s}" % Utils.getResultNameLatex(resultName)
        latex.append(header + " \\\\ \\cline{3-%d}" % (nc))
        latex.append((" & %s\\\\" % ("& \\mu & \\sigma & min & max " * nr)))
        
#.........这里部分代码省略.........
开发者ID:wkoder,项目名称:mooi,代码行数:103,代码来源:LatexReporter.py


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