Changeset 10621
- Timestamp:
- 03/19/14 13:24:38 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10590 r10621 126 126 } 127 127 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); 128 133 contextMenuCell.Show(MousePosition); 129 134 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs
r10616 r10621 124 124 remove { preprocessingData.Changed -= value; } 125 125 } 126 127 public bool AreAllStringColumns(IEnumerable<int> columnIndices) { 128 return columnIndices.All(x => preprocessingData.IsType<string>(x)); 129 } 126 130 } 127 131 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/ManipulationLogic.cs
r10615 r10621 100 100 preprocessingData.InTransaction(() => { 101 101 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)) { 114 123 double prev = preprocessingData.GetCell<double>(column.Key, prevIndex); 115 124 double next = preprocessingData.GetCell<double>(column.Key, nextIndex); 116 117 int valuesToInterpolate = nextIndex - prevIndex;118 119 125 double interpolationStep = (next - prev) / valuesToInterpolate; 120 126 … … 123 129 preprocessingData.SetCell<double>(column.Key, i, interpolated); 124 130 } 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)) { 139 132 DateTime prev = preprocessingData.GetCell<DateTime>(column.Key, prevIndex); 140 133 DateTime next = preprocessingData.GetCell<DateTime>(column.Key, nextIndex); 141 142 int valuesToInterpolate = nextIndex - prevIndex;143 144 134 double interpolationStep = (next - prev).TotalSeconds / valuesToInterpolate; 145 135 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridLogic.cs
r10616 r10621 33 33 bool Validate(string value, out string errorMessage, int columnIndex); 34 34 35 bool AreAllStringColumns(IEnumerable<int> columnIndices); 36 35 37 event DataPreprocessingChangedEventHandler Changed; 36 38 }
Note: See TracChangeset
for help on using the changeset viewer.