Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/18/17 11:25:43 (7 years ago)
Author:
mkommend
Message:

#2709: Refactored get variables for grouping (extracted method to another class).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs

    r14579 r14581  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Drawing;
    25 using System.Linq;
    2623using HeuristicLab.Common;
    2724using HeuristicLab.Core;
     
    3027  [Item("Histogram", "Represents the histogram grid.")]
    3128  public class HistogramContent : PreprocessingChartContent {
    32 
    3329    public static new Image StaticItemImage {
    3430      get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; }
    3531    }
    36 
    37     private const int MAX_DISTINCT_VALUES_FOR_GROUPING = 20;
    3832
    3933    public string GroupingVariableName { get; set; }
     
    5549    }
    5650
    57     public IEnumerable<string> GetVariableNamesForGrouping() {
    58       var variableNames = new List<string>();
    5951
    60       for (int i = 0; i < PreprocessingData.Columns; ++i) {
    61         int distinctValues = int.MaxValue;
    62         if (PreprocessingData.VariableHasType<double>(i))
    63           distinctValues = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
    64         else if (PreprocessingData.VariableHasType<string>(i))
    65           distinctValues = PreprocessingData.GetValues<string>(i).GroupBy(x => x).Count();
    66         else if (PreprocessingData.VariableHasType<DateTime>(i))
    67           distinctValues = PreprocessingData.GetValues<DateTime>(i).GroupBy(x => x).Count();
    68 
    69         if (distinctValues <= MAX_DISTINCT_VALUES_FOR_GROUPING)
    70           variableNames.Add(PreprocessingData.GetVariableName(i));
    71       }
    72       return variableNames;
    73     }
    7452  }
    7553}
Note: See TracChangeset for help on using the changeset viewer.