Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/14 13:24:38 (10 years ago)
Author:
sbreuer
Message:
  • disable toolstrip menu items that are not possible for strings if only string columns are selectd
  • refactor interpolation
Location:
branches/DataPreprocessing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10590 r10621  
    126126          }
    127127          interpolationToolStripMenuItem.Enabled = !(e.RowIndex == 0 || e.RowIndex == Content.Rows);
     128          var columnIndices = new HashSet<int>();
     129          for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
     130            columnIndices.Add(dataGridView.SelectedCells[i].ColumnIndex);
     131          }
     132          averageToolStripMenuItem.Enabled = medianToolStripMenuItem.Enabled = randomToolStripMenuItem.Enabled = interpolationToolStripMenuItem.Enabled = !Content.DataGridLogic.AreAllStringColumns(columnIndices);
    128133          contextMenuCell.Show(MousePosition);
    129134        }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs

    r10616 r10621  
    124124      remove { preprocessingData.Changed -= value; }
    125125    }
     126
     127    public bool AreAllStringColumns(IEnumerable<int> columnIndices) {
     128      return columnIndices.All(x => preprocessingData.IsType<string>(x));
     129    }
    126130  }
    127131}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs

    r10615 r10621  
    100100      preprocessingData.InTransaction(() => {
    101101        foreach (var column in cells) {
    102           if (preprocessingData.IsType<double>(column.Key)) {
    103             int countValues = preprocessingData.GetValues<double>(column.Key).Count();
    104             foreach (int index in column.Value) {
    105               // dont replace first or last values
    106               if (index > 0 && index < countValues) {
    107                 int prevIndex = indexOfPrevPresentValue(column.Key, index);
    108                 int nextIndex = indexOfNextPresentValue(column.Key, index);
    109 
    110                 // no neighbours found
    111                 if (prevIndex < 0 && nextIndex >= countValues) {
    112                   continue;
    113                 }
     102          int countValues = 0;
     103          if (preprocessingData.IsType<double>(column.Key)) {
     104            countValues = preprocessingData.GetValues<double>(column.Key).Count();
     105          } else if (preprocessingData.IsType<DateTime>(column.Key)) {
     106            countValues = preprocessingData.GetValues<DateTime>(column.Key).Count();
     107          }
     108
     109          foreach (int index in column.Value) {
     110            // dont replace first or last values
     111            if (index > 0 && index < countValues) {
     112              int prevIndex = indexOfPrevPresentValue(column.Key, index);
     113              int nextIndex = indexOfNextPresentValue(column.Key, index);
     114
     115              // no neighbours found
     116              if (prevIndex < 0 && nextIndex >= countValues) {
     117                continue;
     118              }
     119
     120              int valuesToInterpolate = nextIndex - prevIndex;
     121
     122              if (preprocessingData.IsType<double>(column.Key)) {
    114123                double prev = preprocessingData.GetCell<double>(column.Key, prevIndex);
    115124                double next = preprocessingData.GetCell<double>(column.Key, nextIndex);
    116 
    117                 int valuesToInterpolate = nextIndex - prevIndex;
    118 
    119125                double interpolationStep = (next - prev) / valuesToInterpolate;
    120126
     
    123129                  preprocessingData.SetCell<double>(column.Key, i, interpolated);
    124130                }
    125               }
    126             }
    127           } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    128             int countValues = preprocessingData.GetValues<DateTime>(column.Key).Count();
    129             foreach (int index in column.Value) {
    130               // dont replace first or last values
    131               if (index > 0 && index < countValues) {
    132                 int prevIndex = indexOfPrevPresentValue(column.Key, index);
    133                 int nextIndex = indexOfNextPresentValue(column.Key, index);
    134 
    135                 // no neighbours found
    136                 if (prevIndex < 0 && nextIndex >= countValues) {
    137                   continue;
    138                 }
     131              } else if (preprocessingData.IsType<DateTime>(column.Key)) {
    139132                DateTime prev = preprocessingData.GetCell<DateTime>(column.Key, prevIndex);
    140133                DateTime next = preprocessingData.GetCell<DateTime>(column.Key, nextIndex);
    141 
    142                 int valuesToInterpolate = nextIndex - prevIndex;
    143 
    144134                double interpolationStep = (next - prev).TotalSeconds / valuesToInterpolate;
    145135
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridLogic.cs

    r10616 r10621  
    3333    bool Validate(string value, out string errorMessage, int columnIndex);
    3434
     35    bool AreAllStringColumns(IEnumerable<int> columnIndices);
     36
    3537    event DataPreprocessingChangedEventHandler Changed;
    3638  }
Note: See TracChangeset for help on using the changeset viewer.