Changeset 17929


Ignore:
Timestamp:
04/06/21 13:35:19 (4 months ago)
Author:
mkommend
Message:

#3105: Added static keyword to private methods to indicate an (most likely) side-effect free method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs

    r17922 r17929  
    5858    }
    5959
    60     private string GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) {
     60    private static string GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) {
    6161      StringBuilder strBuilder = new StringBuilder();
    6262
     
    102102    }
    103103
    104     private string GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) {
     104    private static string GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) {
    105105      StringBuilder strBuilder = new StringBuilder();
    106106      if (mathLibCounter > 0 || statisticLibCounter > 0) {
     
    115115    }
    116116
    117     private string GenerateIfThenElseSource(int evaluateIfCounter) {
     117    private static string GenerateIfThenElseSource(int evaluateIfCounter) {
    118118      StringBuilder strBuilder = new StringBuilder();
    119119      if (evaluateIfCounter > 0) {
     
    128128    }
    129129
    130     private string GenerateModelEvaluationFunction(ISet<string> variables) {
     130    private static string GenerateModelEvaluationFunction(ISet<string> variables) {
    131131      StringBuilder strBuilder = new StringBuilder();
    132132      strBuilder.Append("def evaluate(");
     
    142142    }
    143143
    144     private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     144    private static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    145145      ISymbol symbol = node.Symbol;
    146146      if (symbol is ProgramRootSymbol)
     
    208208    }
    209209
    210     private string VariableName2Identifier(string variableName) => variableName.Replace(" ", "_");
    211 
    212     private void FormatNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string prefixSymbol = "", string openingSymbol = "(", string closingSymbol = ")", string infixSymbol = ",") {
     210    private static string VariableName2Identifier(string variableName) => variableName.Replace(" ", "_");
     211
     212    private static void FormatNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string prefixSymbol = "", string openingSymbol = "(", string closingSymbol = ")", string infixSymbol = ",") {
    213213      strBuilder.Append($"{prefixSymbol}{openingSymbol}");
    214214      foreach (var child in node.Subtrees) {
     
    220220    }
    221221
    222     private void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     222    private static void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    223223      var varNode = node as VariableTreeNode;
    224224      var formattedVariable = VariableName2Identifier(varNode.VariableName);
     
    227227    }
    228228
    229     private void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     229    private static void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    230230      var constNode = node as ConstantTreeNode;
    231231      strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
    232232    }
    233233
    234     private void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) {
     234    private static void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) {
    235235      strBuilder.Append("math.pow(");
    236236      FormatRecursively(node.GetSubtree(0), strBuilder);
     
    238238    }
    239239
    240     private void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     240    private static void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    241241      strBuilder.Append("math.pow(");
    242242      FormatRecursively(node.GetSubtree(0), strBuilder);
     
    246246    }
    247247
    248     private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     248    private static void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    249249      if (node.SubtreeCount == 1) {
    250250        strBuilder.Append("-");
     
    256256    }
    257257
    258     private void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     258    private static void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    259259      strBuilder.Append("(");
    260260      if (node.SubtreeCount == 1) {
     
    273273    }
    274274
    275     private void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
     275    private static void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
    276276      strBuilder.Append("(");
    277277      FormatRecursively(node.GetSubtree(0), strBuilder);
Note: See TracChangeset for help on using the changeset viewer.