Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/18/17 14:19:29 (7 years ago)
Author:
pfleck
Message:

#2809: Removed SearchLogic

Location:
branches/DataPreprocessing Cleanup
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs

    r15110 r15269  
    5252
    5353    private void InitData() {
    54       IDictionary<int, IList<int>> missingValueIndices = Content.SearchLogic.GetMissingValueIndices();
    55 
    56       bool[,] valueMissing = new bool[Content.SearchLogic.Rows, Content.SearchLogic.Columns];
    57       foreach (var columnMissingValues in missingValueIndices) {
    58         var column = columnMissingValues.Key;
    59         foreach (var missingValueIndex in columnMissingValues.Value)
    60           valueMissing[missingValueIndex, column] = true;
     54      bool[,] valueMissing = new bool[Content.PreprocessingData.Rows, Content.PreprocessingData.Columns];
     55      for (int row = 0; row < Content.PreprocessingData.Rows; row++) {
     56        for (int column = 0; column < Content.PreprocessingData.Columns; column++)
     57          valueMissing[row, column] = Content.PreprocessingData.IsCellEmpty(column, row);
    6158      }
    6259
     
    7875      //custom x axis label
    7976      double from = 0.5;
    80       foreach (String columnName in Content.SearchLogic.VariableNames) {
     77      foreach (String columnName in Content.PreprocessingData.VariableNames) {
    8178        double to = from + 1;
    8279        chart.ChartAreas[0].AxisX.CustomLabels.Add(from, to, columnName);
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r15185 r15269  
    5050        var data = Content.Data;
    5151        var filterLogic = new FilterLogic(data);
    52         var searchLogic = new SearchLogic(data, filterLogic);
    53         var statisticsLogic = new StatisticsLogic(data, searchLogic);
    54         var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic);
     52        var statisticsLogic = new StatisticsLogic(data);
     53        var manipulationLogic = new ManipulationLogic(data, statisticsLogic);
    5554
    5655        var viewShortcuts = new ItemList<IViewShortcut> {
     
    6362          new MultiScatterPlotContent(data),
    6463          new CorrelationMatrixContent(Content),
    65           new DataCompletenessChartContent(searchLogic),
     64          new DataCompletenessChartContent(data),
    6665
    6766          new FilterContent(filterLogic),
    68           new ManipulationContent(manipulationLogic, searchLogic, filterLogic),
     67          new ManipulationContent(manipulationLogic, filterLogic),
    6968          new TransformationContent(data, filterLogic)
    7069        };
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/ManipulationView.cs

    r15110 r15269  
    127127
    128128    private void ReplaceMissingValues() {
    129       var allIndices = Content.SearchLogic.GetMissingValueIndices();
     129      var missingValuesIndices = new List<int>();
    130130      var columnIndex = cmbVariableNames.SelectedIndex;
    131       var columnIndices = new Dictionary<int, IList<int>>{
    132           {columnIndex,   allIndices[columnIndex]}
    133       };
     131      var columnIndices = new Dictionary<int, IList<int>> { { columnIndex, missingValuesIndices } };
     132
     133      for (int rowIndex = 0; rowIndex < Content.ManipulationLogic.PreProcessingData.Rows; rowIndex++)
     134        if (Content.ManipulationLogic.PreProcessingData.IsCellEmpty(columnIndex, rowIndex))
     135          missingValuesIndices.Add(rowIndex);
    134136
    135137      switch (cmbReplaceWith.SelectedIndex) {
     
    165167          sb.Append(Environment.NewLine);
    166168          sb.Append("Columns: ");
    167           sb.Append(Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
     169          sb.Append(Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
    168170          for (int i = 1; i < filteredColumns.Count; i++) {
    169             string columnName = Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
     171            string columnName = Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
    170172            sb.Append(", ");
    171173            sb.Append(columnName);
     
    196198          sb.Append(Environment.NewLine);
    197199          sb.Append("Columns: ");
    198           sb.Append(Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
     200          sb.Append(Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(0)));
    199201          for (int i = 1; i < filteredColumns.Count; i++) {
    200             string columnName = Content.SearchLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
     202            string columnName = Content.ManipulationLogic.VariableNames.ElementAt(filteredColumns.ElementAt(i));
    201203            sb.Append(", ");
    202204            sb.Append(columnName);
     
    250252      }
    251253      if (btnApply.Enabled) {
    252         var allIndices = Content.SearchLogic.GetMissingValueIndices();
    253         int count = allIndices[columnIndex].Count;
     254        int count = 0;
     255        for (int rowIndex = 0; rowIndex < Content.ManipulationLogic.PreProcessingData.Rows; rowIndex++)
     256          if (Content.ManipulationLogic.PreProcessingData.IsCellEmpty(columnIndex, rowIndex)) count++;
     257
    254258        int cellCount = Content.FilterLogic.PreprocessingData.Rows * Content.FilterLogic.PreprocessingData.Columns;
    255259        lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "")
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing.Views/3.4/ViewShortcutListView.cs

    r15110 r15269  
    4242    //Clone chart items
    4343    protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
    44       if (itemsListView.SelectedItems.Count == 1) {
    45         IViewShortcut item = itemsListView.SelectedItems[0].Tag as IViewShortcut;
    46         if (item != null) {
    47           try {
    48             item = (IViewShortcut)item.Clone();
    49             var view = MainFormManager.MainForm.ShowContent(item);
    50             if (view != null) {
    51               view.ReadOnly = ReadOnly;
    52               view.Locked = Locked;
    53             }
    54           } catch (NullReferenceException) {
    55             // cloning for preprocessing not done properly yet
    56           }
     44      if (itemsListView.SelectedItems.Count != 1) return;
     45      IViewShortcut item = itemsListView.SelectedItems[0].Tag as IViewShortcut;
     46      if (item == null) return;
     47      try {
     48        item = (IViewShortcut)item.Clone();
     49        var view = MainFormManager.MainForm.ShowContent(item);
     50        if (view != null) {
     51          view.ReadOnly = ReadOnly;
     52          view.Locked = Locked;
    5753        }
     54      } catch (NullReferenceException) {
     55        // cloning for preprocessing not done properly yet
    5856      }
    5957    }
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/DataCompletenessChartContent.cs

    r15110 r15269  
    3232    }
    3333
    34     public SearchLogic SearchLogic { get; private set; }
     34    public ITransactionalPreprocessingData PreprocessingData { get; private set; }
    3535
    36     public DataCompletenessChartContent(SearchLogic searchLogic) {
    37       SearchLogic = searchLogic;
     36    public DataCompletenessChartContent(ITransactionalPreprocessingData preprocessingData) {
     37      PreprocessingData = preprocessingData;
    3838    }
    3939
    4040    public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner)
    4141      : base(content, cloner) {
    42       SearchLogic = content.SearchLogic;
     42      PreprocessingData = content.PreprocessingData;
    4343    }
    4444
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Content/ManipulationContent.cs

    r15110 r15269  
    3333
    3434    public ManipulationLogic ManipulationLogic { get; private set; }
    35     public SearchLogic SearchLogic { get; private set; }
    3635    public FilterLogic FilterLogic { get; private set; }
    3736
    38     public ManipulationContent(ManipulationLogic manipulationLogic, SearchLogic searchLogic, FilterLogic filterLogic) {
     37    public ManipulationContent(ManipulationLogic manipulationLogic, FilterLogic filterLogic) {
    3938      ManipulationLogic = manipulationLogic;
    40       SearchLogic = searchLogic;
    4139      FilterLogic = filterLogic;
    4240    }
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs

    r15110 r15269  
    2828
    2929namespace HeuristicLab.DataPreprocessing {
    30   public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {
     30  public sealed class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {
    3131    private readonly ITransactionalPreprocessingData originalData;
    3232    private ITransactionalPreprocessingData filteredData;
     
    8383    }
    8484
    85     protected FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)
     85    private FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)
    8686      : base(original, cloner) {
    8787      originalData = original.originalData;
     
    9090    public override IDeepCloneable Clone(Cloner cloner) {
    9191      return new FilteredPreprocessingData(this, cloner);
     92    }
     93
     94    public bool IsCellEmpty(int columnIndex, int rowIndex) {
     95      return ActiveData.IsCellEmpty(columnIndex, rowIndex);
    9296    }
    9397
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs

    r15110 r15269  
    2828namespace HeuristicLab.DataPreprocessing {
    2929  public interface IPreprocessingData : INamedItem {
     30    bool IsCellEmpty(int columnIndex, int rowIndex);
    3031    T GetCell<T>(int columnIndex, int rowIndex);
    3132
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r15110 r15269  
    160160    }
    161161
     162    public static bool IsMissingValue(object value) {
     163      if (value is double) return double.IsNaN((double)value);
     164      if (value is string) return string.IsNullOrEmpty((string)value);
     165      if (value is DateTime) return ((DateTime)value).Equals(DateTime.MinValue);
     166      throw new ArgumentException();
     167    }
    162168
    163169    #region IPreprocessingData Members
     170    public abstract bool IsCellEmpty(int columnIndex, int rowIndex);
    164171    public abstract T GetCell<T>(int columnIndex, int rowIndex);
    165172
     
    173180
    174181    public abstract bool VariableHasType<T>(int columnIndex);
    175 
    176     [Obsolete("use the index based variant, is faster")]
    177     public abstract IList<T> GetValues<T>(string variableName, bool considerSelection);
    178182
    179183    public abstract IList<T> GetValues<T>(int columnIndex, bool considerSelection);
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Data/TransactionalPreprocessingData.cs

    r15110 r15269  
    8888
    8989    #region Overridden IPreprocessingData Members
     90    public override bool IsCellEmpty(int columnIndex, int rowIndex) {
     91      var value = variableValues[columnIndex][rowIndex];
     92      return IsMissingValue(value);
     93    }
     94
    9095    public override T GetCell<T>(int columnIndex, int rowIndex) {
    9196      return (T)variableValues[columnIndex][rowIndex];
     
    119124    public override bool VariableHasType<T>(int columnIndex) {
    120125      return columnIndex >= variableValues.Count || variableValues[columnIndex] is List<T>;
    121     }
    122 
    123     [Obsolete("use the index based variant, is faster")]
    124     public override IList<T> GetValues<T>(string variableName, bool considerSelection) {
    125       return GetValues<T>(GetColumnIndex(variableName), considerSelection);
    126126    }
    127127
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r15268 r15269  
    146146    <Compile Include="PreprocessingContext.cs" />
    147147    <Compile Include="Data\TransactionalPreprocessingData.cs" />
    148     <Compile Include="Logic\SearchLogic.cs" />
    149148    <Compile Include="Logic\StatisticsLogic.cs" />
    150149    <Compile Include="Data\ITransactionalPreprocessingData.cs" />
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/FilterLogic.cs

    r15110 r15269  
    7373    }
    7474
    75     public bool Result(bool current, bool addition, bool isAndCombination) {
     75    private bool Result(bool current, bool addition, bool isAndCombination) {
    7676      return isAndCombination ? current || addition : current && addition;
    7777    }
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/ManipulationLogic.cs

    r15110 r15269  
    3030    private readonly ITransactionalPreprocessingData preprocessingData;
    3131    private readonly StatisticsLogic statisticsLogic;
    32     private readonly SearchLogic searchLogic;
    3332
    3433    public IEnumerable<string> VariableNames {
     
    4039    }
    4140
    42     public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, SearchLogic theSearchLogic, StatisticsLogic theStatisticsLogic) {
     41    public ManipulationLogic(ITransactionalPreprocessingData preprocessingData, StatisticsLogic theStatisticsLogic) {
    4342      this.preprocessingData = preprocessingData;
    44       searchLogic = theSearchLogic;
    4543      statisticsLogic = theStatisticsLogic;
    4644    }
     
    187185    private int indexOfPrevPresentValue(int columnIndex, int start) {
    188186      int offset = start - 1;
    189       while (offset >= 0 && searchLogic.IsMissingValue(columnIndex, offset)) {
     187      while (offset >= 0 && preprocessingData.IsCellEmpty(columnIndex, offset)) {
    190188        offset--;
    191189      }
     
    196194    private int indexOfNextPresentValue(int columnIndex, int start) {
    197195      int offset = start + 1;
    198       while (offset < preprocessingData.Rows && searchLogic.IsMissingValue(columnIndex, offset)) {
     196      while (offset < preprocessingData.Rows && preprocessingData.IsCellEmpty(columnIndex, offset)) {
    199197        offset++;
    200198      }
  • branches/DataPreprocessing Cleanup/HeuristicLab.DataPreprocessing/3.4/Logic/StatisticsLogic.cs

    r15110 r15269  
    2828  public class StatisticsLogic {
    2929    private readonly ITransactionalPreprocessingData preprocessingData;
    30     private readonly SearchLogic searchLogic;
    31 
    32     public StatisticsLogic(ITransactionalPreprocessingData thePreprocessingData, SearchLogic theSearchLogic) {
    33       preprocessingData = thePreprocessingData;
    34       searchLogic = theSearchLogic;
     30
     31    public StatisticsLogic(ITransactionalPreprocessingData preprocessingData) {
     32      this.preprocessingData = preprocessingData;
    3533    }
    3634
    3735    public int GetColumnCount() {
    38       return searchLogic.Columns;
     36      return preprocessingData.Columns;
    3937    }
    4038
    4139    public int GetRowCount() {
    42       return searchLogic.Rows;
     40      return preprocessingData.Rows;
    4341    }
    4442
     
    4644      int count = 0;
    4745
    48       for (int i = 0; i < searchLogic.Columns; ++i) {
     46      for (int i = 0; i < preprocessingData.Columns; ++i) {
    4947        if (preprocessingData.VariableHasType<double>(i)) {
    5048          ++count;
     
    5553
    5654    public int GetNominalColumnCount() {
    57       return searchLogic.Columns - GetNumericColumnCount();
     55      return preprocessingData.Columns - GetNumericColumnCount();
    5856    }
    5957
    6058    public int GetMissingValueCount() {
    6159      int count = 0;
    62       for (int i = 0; i < searchLogic.Columns; ++i) {
     60      for (int i = 0; i < preprocessingData.Columns; ++i) {
    6361        count += GetMissingValueCount(i);
    6462      }
     
    6765
    6866    public int GetMissingValueCount(int columnIndex) {
    69       return searchLogic.GetMissingValueIndices(columnIndex).Count();
     67      return Enumerable.Range(0, preprocessingData.Rows).Count(rowIndex => preprocessingData.IsCellEmpty(columnIndex, rowIndex));
     68    }
     69
     70    public int GetRowMissingValueCount(int rowIndex) {
     71      var columnIndexes = Enumerable.Range(0, preprocessingData.Columns);
     72      return columnIndexes.Count(columnIndex => !preprocessingData.IsCellEmpty(columnIndex, rowIndex));
     73    }
     74
     75    private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) {
     76      return preprocessingData.GetValues<T>(columnIndex, considerSelection).Where(x => !PreprocessingData.IsMissingValue(x)).ToList();
    7077    }
    7178
     
    185192    }
    186193
    187     public int GetRowMissingValueCount(int rowIndex) {
    188       int count = 0;
    189       for (int i = 0; i < preprocessingData.Columns; ++i) {
    190         if (searchLogic.IsMissingValue(i, rowIndex)) {
    191           ++count;
    192         }
    193       }
    194       return count;
    195     }
    196 
    197     public string GetVariableName(int columnIndex) {
    198       return preprocessingData.GetVariableName(columnIndex);
    199     }
     194
    200195
    201196    public bool VariableHasType<T>(int columnIndex) {
     
    218213    }
    219214
    220     private IEnumerable<T> GetValuesWithoutNaN<T>(int columnIndex, bool considerSelection = false) {
    221       return searchLogic.GetValuesWithoutNaN<T>(columnIndex, considerSelection);
    222     }
    223215
    224216    private DateTime GetSecondsAsDateTime(double seconds) {
Note: See TracChangeset for help on using the changeset viewer.