Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10843


Ignore:
Timestamp:
05/14/14 11:36:10 (11 years ago)
Author:
rstoll
Message:
  • Fixed or combination filter, default value was set to true and thus all rows where filtered (regardless of the actual filter)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs

    r10802 r10843  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using HeuristicLab.DataPreprocessing.Filter;
    23 using System.Collections.Generic;
    24 using System;
    25 using System.Linq;
    2625using HeuristicLab.DataPreprocessing.Interfaces;
    2726namespace HeuristicLab.DataPreprocessing {
     
    3029    private IFilteredPreprocessingData preprocessingData;
    3130
    32     public FilterLogic(IFilteredPreprocessingData preprocessingData)
    33     {
     31    public FilterLogic(IFilteredPreprocessingData preprocessingData) {
    3432      this.preprocessingData = preprocessingData;
    3533    }
    3634
    37     public bool[] Preview(IList<IFilter> filters, bool isAndCombination)
    38     {
    39        IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>();
    4035
    41        if (activeFilters.Count == 0) {
     36
     37    public bool[] Preview(IList<IFilter> filters, bool isAndCombination) {
     38      IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>();
     39
     40      if (activeFilters.Count == 0) {
    4241        return new bool[preprocessingData.Rows];
    43        }
     42      }
    4443
    45        bool[] result = TrueBoolArray(preprocessingData.Rows);
     44      bool[] result = CreateBoolArray(preprocessingData.Rows, isAndCombination);
    4645
    47          foreach (IFilter filter in activeFilters)
    48          {
    49            bool[] filterResult = filter.Check();
    50            for (int row = 0; row < result.Length; ++row)
    51            {
    52              result[row] = Result(result[row], filterResult[row], isAndCombination);
    53            }
    54          }
     46      foreach (IFilter filter in activeFilters) {
     47        bool[] filterResult = filter.Check();
     48        for (int row = 0; row < result.Length; ++row) {
     49          result[row] = Result(result[row], filterResult[row], isAndCombination);
     50        }
     51      }
    5552
    56         preprocessingData.SetFilter(result);
    57        
    58         return result;
     53      preprocessingData.SetFilter(result);
     54
     55      return result;
    5956    }
    6057
    61     public bool[] TrueBoolArray(int rows) {
    62       return Enumerable.Repeat<bool>(true, rows).ToArray();
     58    public bool[] CreateBoolArray(int rows, bool value) {
     59      return Enumerable.Repeat<bool>(value, rows).ToArray();
    6360    }
    6461
    65     public bool Result(bool current, bool addition, bool isAndCombination) { 
     62    public bool Result(bool current, bool addition, bool isAndCombination) {
    6663      return isAndCombination ? current && addition : current || addition;
    6764    }
    6865
    69     public void Apply(IList<IFilter> filters, bool isAndCombination)
    70     {
    71         preprocessingData.SetFilter(Preview(filters, isAndCombination));
    72         preprocessingData.PersistFilter();
     66    public void Apply(IList<IFilter> filters, bool isAndCombination) {
     67      preprocessingData.SetFilter(Preview(filters, isAndCombination));
     68      preprocessingData.PersistFilter();
    7369    }
    7470
     
    7773    }
    7874
    79     public IPreprocessingData PreprocessingData
    80     {
     75    public IPreprocessingData PreprocessingData {
    8176      get { return preprocessingData; }
    8277    }
Note: See TracChangeset for help on using the changeset viewer.