Changeset 10819 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingTransformator.cs
- Timestamp:
- 05/07/14 15:18:41 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingTransformator.cs
r10814 r10819 33 33 } 34 34 35 public bool ApplyTransformations(IEnumerable<ITransformation> transformations ) {36 bool success = true;35 public bool ApplyTransformations(IEnumerable<ITransformation> transformations, out string errorMsg) { 36 bool success; 37 37 38 preprocessingData.InTransaction(() => { 38 preprocessingData.BeginTransaction(DataPreprocessingChangedEventType.Transformation); 39 try { 39 40 var doubleTransformations = transformations.OfType<Transformation<double>>().ToList(); 40 ApplyDoubleTranformations(doubleTransformations, out success );41 } , DataPreprocessingChangedEventType.Transformation);42 43 if (!success) {44 preprocessingData.Undo();41 ApplyDoubleTranformations(doubleTransformations, out success, out errorMsg); 42 } finally { 43 preprocessingData.EndTransaction(); 44 //if (!success) 45 //preprocessingData.Undo(); 45 46 } 46 47 … … 48 49 } 49 50 50 private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success) { 51 private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success, out string errorMsg) { 52 errorMsg = string.Empty; 53 success = true; 51 54 foreach (var transformation in transformations) { 52 55 int colIndex = preprocessingData.GetColumnIndex(transformation.Column); 53 56 54 57 var originalData = preprocessingData.GetValues<double>(colIndex); 55 var transformedData = ApplyDoubleTransformation(transformation, originalData, out success); 56 if (!success) return; 57 58 string errorMsgPart; 59 bool successPart; 60 var transformedData = ApplyDoubleTransformation(transformation, originalData, out successPart, out errorMsgPart); 61 errorMsg += errorMsgPart + Environment.NewLine; 62 //if (!success) return; 63 if (!successPart) success = false; 58 64 preprocessingData.SetValues(colIndex, transformedData.ToList()); 59 65 preprocessingData.Transformations.Add(transformation); 60 66 } 61 success = true; 67 62 68 } 63 69 64 private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success) { 65 string errorMsg; 66 if (transformation.Check(data, out errorMsg)) { 67 success = true; 68 return transformation.Apply(data); 69 } 70 throw new NotImplementedException("Display Check Result"); 70 private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success, out string errorMsg) { 71 success = transformation.Check(data, out errorMsg); 72 return transformation.Apply(data); 71 73 } 72 74 }
Note: See TracChangeset
for help on using the changeset viewer.