Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content
Files:
2 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}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14511 r14581  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Drawing;
     25using System.Linq;
    2426using HeuristicLab.Analysis;
    2527using HeuristicLab.Common;
     28using HeuristicLab.Common.Resources;
    2629using HeuristicLab.Core;
    2730using HeuristicLab.Data;
     
    3134  public class PreprocessingChartContent : Item, IViewShortcut {
    3235    public static new Image StaticItemImage {
    33       get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }
     36      get { return VSImageLibrary.PieChart; }
    3437    }
    3538
     
    3841      get {
    3942        if (variableItemList == null)
    40           variableItemList = CreateVariableItemList();
     43          variableItemList = CreateVariableItemList(PreprocessingData);
    4144        return this.variableItemList;
    4245      }
    43       //set { this.variableItemList = value; }
    4446    }
    4547
    4648    public IFilteredPreprocessingData PreprocessingData { get; private set; }
     49    public event DataPreprocessingChangedEventHandler Changed {
     50      add { PreprocessingData.Changed += value; }
     51      remove { PreprocessingData.Changed -= value; }
     52    }
    4753
    4854    public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) {
     
    6672    }
    6773
    68 
    69 
    70 
    71     public ICheckedItemList<StringValue> CreateVariableItemList() {
     74    private static ICheckedItemList<StringValue> CreateVariableItemList(IPreprocessingData preprocessingData) {
    7275      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
    73       foreach (string name in PreprocessingData.GetDoubleVariableNames()) {
     76      foreach (string name in preprocessingData.GetDoubleVariableNames()) {
    7477        var n = new StringValue(name);
    75         bool isInputTarget = PreprocessingData.InputVariables.Contains(name) || PreprocessingData.TargetVariable == name;
     78        bool isInputTarget = preprocessingData.InputVariables.Contains(name) || preprocessingData.TargetVariable == name;
    7679        itemList.Add(n, isInputTarget);
    7780      }
    7881      return new ReadOnlyCheckedItemList<StringValue>(itemList);
    7982    }
    80 
    81     public event DataPreprocessingChangedEventHandler Changed {
    82       add { PreprocessingData.Changed += value; }
    83       remove { PreprocessingData.Changed -= value; }
    84     }
    85 
    8683  }
    8784}
Note: See TracChangeset for help on using the changeset viewer.