Ignore:
Timestamp:
07/09/14 10:37:01 (8 years ago)
Author:
gkronber
Message:

#2206: made several changes / improvements to the data-preprocessing code while reviewing the code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/PreprocessingTransformator.cs

    r11068 r11156  
    4242
    4343    public bool ApplyTransformations(IEnumerable<ITransformation> transformations, bool preserveColumns, out string errorMsg) {
    44       bool success;
    45 
     44      bool success = false;
     45      errorMsg = string.Empty;
    4646      preprocessingData.BeginTransaction(DataPreprocessingChangedEventType.Transformation);
    4747
     
    6464          renamedColumns.Clear();
    6565        }
     66        // only accept changes if everything was successful
     67        if (!success) {
     68          preprocessingData.Undo();
     69        }
     70      }
     71      catch (Exception e) {
     72        preprocessingData.Undo();
     73        if (string.IsNullOrEmpty(errorMsg)) errorMsg = e.Message;
    6674      }
    6775      finally {
     
    103111    private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IList<double> data, out bool success, out string errorMsg) {
    104112      success = transformation.Check(data, out errorMsg);
    105       return transformation.Apply(data);
     113      // don't apply when the check fails
     114      if (success)
     115        return transformation.Apply(data);
     116      else
     117        return data;
    106118    }
    107119
Note: See TracChangeset for help on using the changeset viewer.