Changeset 17929
- Timestamp:
- 04/06/21 13:35:19 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs
r17922 r17929 58 58 } 59 59 60 private st ring GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) {60 private static string GenerateHeader(ISymbolicExpressionTree symbolicExpressionTree) { 61 61 StringBuilder strBuilder = new StringBuilder(); 62 62 … … 102 102 } 103 103 104 private st ring GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) {104 private static string GenerateNecessaryImports(int mathLibCounter, int statisticLibCounter) { 105 105 StringBuilder strBuilder = new StringBuilder(); 106 106 if (mathLibCounter > 0 || statisticLibCounter > 0) { … … 115 115 } 116 116 117 private st ring GenerateIfThenElseSource(int evaluateIfCounter) {117 private static string GenerateIfThenElseSource(int evaluateIfCounter) { 118 118 StringBuilder strBuilder = new StringBuilder(); 119 119 if (evaluateIfCounter > 0) { … … 128 128 } 129 129 130 private st ring GenerateModelEvaluationFunction(ISet<string> variables) {130 private static string GenerateModelEvaluationFunction(ISet<string> variables) { 131 131 StringBuilder strBuilder = new StringBuilder(); 132 132 strBuilder.Append("def evaluate("); … … 142 142 } 143 143 144 private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {144 private static void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 145 145 ISymbol symbol = node.Symbol; 146 146 if (symbol is ProgramRootSymbol) … … 208 208 } 209 209 210 private st ring 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 = ",") { 213 213 strBuilder.Append($"{prefixSymbol}{openingSymbol}"); 214 214 foreach (var child in node.Subtrees) { … … 220 220 } 221 221 222 private void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {222 private static void FormatVariableTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 223 223 var varNode = node as VariableTreeNode; 224 224 var formattedVariable = VariableName2Identifier(varNode.VariableName); … … 227 227 } 228 228 229 private void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {229 private static void FormatConstantTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 230 230 var constNode = node as ConstantTreeNode; 231 231 strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 232 232 } 233 233 234 private void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) {234 private static void FormatPower(ISymbolicExpressionTreeNode node, StringBuilder strBuilder, string exponent) { 235 235 strBuilder.Append("math.pow("); 236 236 FormatRecursively(node.GetSubtree(0), strBuilder); … … 238 238 } 239 239 240 private void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {240 private static void FormatRoot(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 241 241 strBuilder.Append("math.pow("); 242 242 FormatRecursively(node.GetSubtree(0), strBuilder); … … 246 246 } 247 247 248 private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {248 private static void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 249 249 if (node.SubtreeCount == 1) { 250 250 strBuilder.Append("-"); … … 256 256 } 257 257 258 private void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {258 private static void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 259 259 strBuilder.Append("("); 260 260 if (node.SubtreeCount == 1) { … … 273 273 } 274 274 275 private void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {275 private static void FormatAnalyticQuotient(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 276 276 strBuilder.Append("("); 277 277 FormatRecursively(node.GetSubtree(0), strBuilder);
Note: See TracChangeset
for help on using the changeset viewer.