- Timestamp:
- 06/11/14 15:43:05 (10 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r10992 r11002 78 78 <Compile Include="Implementations\PreprocessingChartContent.cs" /> 79 79 <Compile Include="Implementations\PreprocessingData.cs" /> 80 <Compile Include="Implementations\DataGridLogic.cs" />81 80 <Compile Include="Implementations\PreprocessingDataTable.cs" /> 82 81 <Compile Include="Interfaces\IViewChartShortcut.cs" /> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/CorrelationMatrixContent.cs
r10982 r11002 50 50 public CorrelationMatrixContent(CorrelationMatrixContent original, Cloner cloner) 51 51 : base(original, cloner) { 52 Context = original.Context; 52 53 } 53 54 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataCompletenessChartContent.cs
r10999 r11002 5 5 namespace HeuristicLab.DataPreprocessing { 6 6 [Item("DataCompletenessChart", "Represents a datacompleteness chart.")] 7 public class DataCompletenessChartContent : Item, IViewChartShortcut {8 7 8 public class DataCompletenessChartContent : Item, IViewChartShortcut 9 { 9 10 public static new Image StaticItemImage { 10 11 get { return HeuristicLab.Common.Resources.VSImageLibrary.EditBrightnessContrast; } 11 12 } 12 13 14 private readonly SearchLogic searchLogic; 15 13 16 public IDataGridLogic DataGridLogic { get; private set; } 14 17 public ISearchLogic SearchLogic { get; private set; } 15 18 16 public DataCompletenessChartContent( DataGridLogic dataGridLogic, SearchLogic searchLogic) {17 DataGridLogic = dataGridLogic;18 SearchLogic = searchLogic;19 public DataCompletenessChartContent(SearchLogic searchLogic) 20 { 21 this.searchLogic = searchLogic; 19 22 } 20 23 21 24 public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner) 22 : base(content, cloner) {23 DataGridLogic = content.DataGridLogic;24 SearchLogic = content.SearchLogic;25 : base(content, cloner) 26 { 27 this.searchLogic = content.searchLogic; 25 28 } 26 29 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs
r10999 r11002 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.Globalization; 26 using System.Linq; 25 27 using HeuristicLab.Common; 26 28 using HeuristicLab.Core; 29 using HeuristicLab.Data; 27 30 28 31 namespace HeuristicLab.DataPreprocessing { … … 31 34 public class DataGridContent : Item, IViewShortcut, IDataGridContent { 32 35 36 public ITransactionalPreprocessingData PreProcessingData { get; private set; } 37 33 38 public static new Image StaticItemImage { 34 39 get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; } … … 36 41 37 42 public IManipulationLogic ManipulationLogic { get; private set; } 38 public IDataGridLogic DataGridLogic { get; private set; }39 43 public IFilterLogic FilterLogic { get; private set; } 44 45 private IEnumerable<string> rowNames; 40 46 41 47 public int Rows { 42 48 get { 43 return DataGridLogic.Rows;49 return PreProcessingData.Rows; 44 50 } 45 51 set { … … 50 56 public int Columns { 51 57 get { 52 return DataGridLogic.Columns;58 return PreProcessingData.Columns; 53 59 } 54 60 set { … … 59 65 public IEnumerable<string> ColumnNames { 60 66 get { 61 return DataGridLogic.ColumnNames;67 return PreProcessingData.VariableNames; 62 68 } 63 69 set { … … 68 74 public IEnumerable<string> RowNames { 69 75 get { 70 return DataGridLogic.RowNames;76 return rowNames; 71 77 } 72 78 set { … … 88 94 } 89 95 90 public DataGridContent(IDataGridLogic theDataGridLogic, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) { 91 DataGridLogic = theDataGridLogic; 96 97 private IDictionary<int, IList<int>> selection; 98 public IDictionary<int, IList<int>> Selection { 99 get { return PreProcessingData.Selection; } 100 set { PreProcessingData.Selection = value; } 101 } 102 103 104 public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) { 92 105 ManipulationLogic = theManipulationLogic; 93 106 FilterLogic = theFilterLogic; 107 PreProcessingData = preProcessingData; 108 createRowNames(); 94 109 } 95 110 … … 102 117 } 103 118 119 public void DeleteRow(IEnumerable<int> rows) { 120 PreProcessingData.DeleteRowsWithIndices(rows); 121 createRowNames(); 122 } 123 124 public bool Validate(string value, out string errorMessage, int columnIndex) { 125 return PreProcessingData.Validate(value, out errorMessage, columnIndex); 126 } 127 104 128 public string GetValue(int rowIndex, int columnIndex) { 105 return DataGridLogic.GetValue(columnIndex, rowIndex);129 return PreProcessingData.GetCellAsString(columnIndex, rowIndex); 106 130 } 107 131 108 132 public bool SetValue(string value, int rowIndex, int columnIndex) { 109 return DataGridLogic.SetValue(value, columnIndex, rowIndex); 133 return PreProcessingData.SetValue(value, columnIndex, rowIndex); 134 } 135 136 private void createRowNames() { 137 rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString()); 110 138 } 111 139 112 140 public event DataPreprocessingChangedEventHandler Changed { 113 add { DataGridLogic.Changed += value; }114 remove { DataGridLogic.Changed -= value; }141 add { PreProcessingData.Changed += value; } 142 remove { PreProcessingData.Changed -= value; } 115 143 } 116 144 … … 126 154 127 155 public event EventHandler ColumnsChanged; 128 129 156 public event EventHandler RowsChanged; 130 131 157 public event EventHandler ColumnNamesChanged; 132 133 158 public event EventHandler RowNamesChanged; 134 135 159 public event EventHandler SortableViewChanged; 136 137 160 public event EventHandler<EventArgs<int, int>> ItemChanged; 138 139 161 public event EventHandler Reset; 140 162 #endregion -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationContent.cs
r10970 r11002 31 31 private IManipulationLogic manipulationLogic; 32 32 private ISearchLogic searchLogic; 33 private IDataGridLogic dataGridLogic;34 33 private IFilterLogic filterLogic; 35 34 36 35 public IManipulationLogic ManipulationLogic { get { return manipulationLogic; } } 37 36 public ISearchLogic SearchLogic { get { return searchLogic; } } 38 public IDataGridLogic DataGridLogic { get { return dataGridLogic; } }39 37 public IFilterLogic FilterLogic { get { return filterLogic; } } 40 38 … … 43 41 } 44 42 45 public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, I DataGridLogic theDataGridLogic, IFilterLogic theFitlerLogic) {43 public ManipulationContent(IManipulationLogic theManipulationLogic, ISearchLogic theSearchLogic, IFilterLogic theFitlerLogic) { 46 44 manipulationLogic = theManipulationLogic; 47 45 searchLogic = theSearchLogic; 48 dataGridLogic = theDataGridLogic;49 46 filterLogic = theFitlerLogic; 50 47 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ManipulationLogic.cs
r10820 r11002 30 30 private IStatisticsLogic statisticsLogic; 31 31 private ISearchLogic searchLogic; 32 private IDataGridLogic dataGridLogic; 33 34 public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic, IDataGridLogic theDataGridLogic) { 32 33 public IEnumerable<string> VariableNames { 34 get { return preprocessingData.VariableNames; } 35 } 36 37 public ITransactionalPreprocessingData PreProcessingData { 38 get { return preprocessingData; } 39 } 40 41 public ManipulationLogic(ITransactionalPreprocessingData _prepocessingData, ISearchLogic theSearchLogic, IStatisticsLogic theStatisticsLogic) { 35 42 preprocessingData = _prepocessingData; 36 43 searchLogic = theSearchLogic; 37 44 statisticsLogic = theStatisticsLogic; 38 dataGridLogic = theDataGridLogic;39 45 } 40 46 … … 316 322 foreach (var column in cells) { 317 323 foreach (var rowIdx in column.Value) { 318 dataGridLogic.SetValue(value, column.Key, rowIdx);324 preprocessingData.SetValue(value, column.Key, rowIdx); 319 325 } 320 326 } … … 396 402 } 397 403 398 public event DataPreprocessingChangedEventHandler Changed { 399 add { dataGridLogic.Changed += value; } 400 remove { dataGridLogic.Changed -= value; } 401 } 404 public event DataPreprocessingChangedEventHandler Changed; 402 405 } 403 406 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs
r10994 r11002 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization; 25 26 using System.Linq; 26 27 using HeuristicLab.Common; … … 95 96 selection = new Dictionary<int, IList<int>>(); 96 97 98 Dataset dataset = problemData.Dataset; 97 99 variableNames = new List<string>(problemData.Dataset.VariableNames); 98 100 … … 100 102 variableValues = new List<IList>(); 101 103 foreach (var variableName in problemData.Dataset.VariableNames) { 102 if ( problemData.Dataset.IsType<double>(variableName)) {103 variableValues.Insert(columnIndex, problemData.Dataset.GetDoubleValues(variableName).ToList());104 } else if ( problemData.Dataset.IsType<string>(variableName)) {105 variableValues.Insert(columnIndex, CreateColumn<string>(problemData.Dataset, columnIndex, x => x));106 } else if ( problemData.Dataset.IsType<DateTime>(variableName)) {107 variableValues.Insert(columnIndex, CreateColumn<DateTime>(problemData.Dataset, columnIndex, x => DateTime.Parse(x)));104 if (dataset.IsType<double>(variableName)) { 105 variableValues.Insert(columnIndex, dataset.GetDoubleValues(variableName).ToList()); 106 } else if (dataset.IsType<string>(variableName)) { 107 variableValues.Insert(columnIndex, dataset.GetStringValues(variableName).ToList()); 108 } else if (dataset.IsType<DateTime>(variableName)) { 109 variableValues.Insert(columnIndex, dataset.GetDateTimeValues(variableName).ToList()); 108 110 } else { 109 111 throw new ArgumentException("The datatype of column " + variableName + " must be of type double, string or DateTime"); … … 180 182 public abstract void SetValues<T>(int columnIndex, IList<T> values); 181 183 184 public abstract bool SetValue(string value, int columnIndex, int rowIndex); 185 186 public abstract bool Validate(string value, out string errorMessage, int columnIndex); 187 188 public abstract bool AreAllStringColumns(IEnumerable<int> columnIndices); 189 190 public abstract void DeleteRowsWithIndices(IEnumerable<int> rows); 191 182 192 public abstract void InsertRow(int rowIndex); 183 193 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/SearchLogic.cs
r10978 r11002 31 31 private Dictionary<int, IList<int>> MissingValueIndicies { get; set; } 32 32 private Dictionary<int, IList> ValuesWithoutNaN { get; set; } 33 34 public IEnumerable<string> VariableNames { 35 get { return preprocessingData.VariableNames; } 36 } 37 38 public int Columns { 39 get { return preprocessingData.Columns; } 40 } 41 42 public int Rows { 43 get { return preprocessingData.Rows; } 44 } 33 45 34 46 public SearchLogic(ITransactionalPreprocessingData thePreprocessingData) { -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs
r10994 r11002 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Globalization; 26 using System.Linq; 25 27 using HeuristicLab.Common; 26 28 using HeuristicLab.Core; … … 159 161 if (!IsInTransaction) 160 162 OnChanged(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 163 } 164 165 public override bool SetValue(string value, int columnIndex, int rowIndex) { 166 bool valid = false; 167 if (IsType<double>(columnIndex)) { 168 double val; 169 valid = double.TryParse(value, out val); 170 SetValueIfValid(columnIndex, rowIndex, valid, val); 171 } else if (IsType<string>(columnIndex)) { 172 valid = value != null; 173 SetValueIfValid(columnIndex, rowIndex, valid, value); 174 } else if (IsType<DateTime>(columnIndex)) { 175 DateTime date; 176 valid = DateTime.TryParse(value, out date); 177 SetValueIfValid(columnIndex, rowIndex, valid, date); 178 } else { 179 throw new ArgumentException("column " + columnIndex + " contains a non supported type."); 180 } 181 182 if (!IsInTransaction) 183 OnChanged(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 184 185 return valid; 186 } 187 188 public override bool Validate(string value, out string errorMessage, int columnIndex){ 189 if (columnIndex < 0 || columnIndex > VariableNames.Count()) { 190 throw new ArgumentOutOfRangeException("column index is out of range"); 191 } 192 193 bool valid = false; 194 errorMessage = string.Empty; 195 if (IsType<double>(columnIndex)) { 196 double val; 197 valid = double.TryParse(value, out val); 198 if (!valid) { 199 errorMessage = "Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")"; 200 } 201 } else if (IsType<string>(columnIndex)) { 202 valid = value != null; 203 if (!valid) { 204 errorMessage = "Invalid Value (string must not be null)"; 205 } 206 } else if (IsType<DateTime>(columnIndex)) { 207 DateTime date; 208 valid = DateTime.TryParse(value, out date); 209 if (!valid) { 210 errorMessage = "Invalid Value (Valid Value Format: \"" + CultureInfo.CurrentCulture.DateTimeFormat + "\""; 211 } 212 } else { 213 throw new ArgumentException("column " + columnIndex + " contains a non supported type."); 214 } 215 216 return valid; 217 } 218 219 private void SetValueIfValid<T>(int columnIndex, int rowIndex, bool valid, T value) { 220 if (valid) 221 SetCell<T>(columnIndex, rowIndex, value); 222 } 223 224 public override bool AreAllStringColumns(IEnumerable<int> columnIndices) { 225 return columnIndices.All(x => IsType<string>(x)); 226 } 227 228 public override void DeleteRowsWithIndices(IEnumerable<int> rows) { 229 foreach (int rowIndex in rows) { 230 DeleteRow(rowIndex); 231 } 161 232 } 162 233 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IDataGridContent.cs
r10809 r11002 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using HeuristicLab.Data; 23 24 24 25 namespace HeuristicLab.DataPreprocessing { 25 26 public interface IDataGridContent : IStringConvertibleMatrix { 26 I DataGridLogic DataGridLogic{ get; }27 ITransactionalPreprocessingData PreProcessingData { get; } 27 28 IManipulationLogic ManipulationLogic { get; } 28 29 IFilterLogic FilterLogic { get; } 30 31 IDictionary<int, IList<int>> Selection { get; set; } 32 33 void DeleteRow(IEnumerable<int> rows); 34 bool Validate(string value, out string errorMessage, int columnIndex); 29 35 30 36 event DataPreprocessingChangedEventHandler Changed; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IDataGridLogic.cs
r10804 r11002 40 40 void DeleteRow(List<int> rows); 41 41 42 void SetSelection(IDictionary<int, IList<int>> selection); 43 IDictionary<int, IList<int>> GetSelection(); 42 IDictionary<int, IList<int>> Selection { get; set; } 44 43 void ClearSelection(); 45 44 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IFilterLogic.cs
r10930 r11002 23 23 using System.Collections.Generic; 24 24 using HeuristicLab.DataPreprocessing.Filter; 25 using HeuristicLab.DataPreprocessing.Interfaces; 25 26 namespace HeuristicLab.DataPreprocessing { 26 27 public interface IFilterLogic { … … 34 35 bool[] Preview(IList<IFilter> filters, bool isAndCombination); 35 36 void Apply(IList<IFilter> filters, bool isAndCombination); 36 I PreprocessingData PreprocessingData { get; }37 IFilteredPreprocessingData PreprocessingData { get; } 37 38 void Reset(); 38 39 bool IsFiltered { get; } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IManipulationLogic.cs
r10820 r11002 25 25 namespace HeuristicLab.DataPreprocessing { 26 26 public interface IManipulationLogic { 27 IEnumerable<string> VariableNames { get; } 28 ITransactionalPreprocessingData PreProcessingData { get; } 27 29 void ReOrderToIndices(IEnumerable<int> indices); 28 30 void ReOrderToIndices(IList<Tuple<int, int>> indices); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingData.cs
r10992 r11002 41 41 42 42 void SetValues<T>(int columnIndex, IList<T> values); 43 bool SetValue(string value, int columnIndex, int rowIndex); 43 44 44 45 void InsertRow(int rowIndex); 45 46 void DeleteRow(int rowIndex); 46 47 void DeleteRowsWithIndices(IEnumerable<int> rows); 47 48 void InsertColumn<T>(string variableName, int columnIndex); 48 49 49 50 void DeleteColumn(int columnIndex); 50 51 51 IntRange TrainingPartition { get; } 52 bool AreAllStringColumns(IEnumerable<int> columnIndices); 53 bool Validate(string value, out string errorMessage, int columnIndex); 54 55 IntRange TrainingPartition { get; } 52 56 IntRange TestPartition { get; } 53 57 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/ISearchLogic.cs
r10811 r11002 24 24 namespace HeuristicLab.DataPreprocessing { 25 25 public interface ISearchLogic { 26 27 int Rows { get; } 28 int Columns { get; } 29 IEnumerable<string> VariableNames { get; } 30 26 31 /// <summary> 27 32 /// Return the indices of the missing values where the key
Note: See TracChangeset
for help on using the changeset viewer.