Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15879


Ignore:
Timestamp:
03/30/18 15:46:05 (7 years ago)
Author:
pfleck
Message:

#2906 minor refactoring

Location:
branches/2906_Transformations
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationListView.cs

    r15865 r15879  
    105105
    106106      // TODO: do not move/remove already applied transformations
    107       // TODO: general disalow of movement?
     107      // TODO: general disallow of movement?
    108108      if (Content[selectedIndex].IsApplied) {
    109109        moveUpButton.Enabled = selectedIndex > 0 && Content[selectedIndex - 1].IsApplied;
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r15870 r15879  
    245245      var newDataset = DataAnalysisTransformationModel.Transform(Dataset, Transformations);
    246246
    247       var extendedInputs = ExtendInputVariables(AllowedInputVariables, Transformations);
     247      var extendedInputs = DataAnalysisTransformationModel.ExtendInputVariables(AllowedInputVariables, Transformations);
    248248      var checkedInputs = new CheckedItemList<StringValue>(newDataset.VariableNames.Select(x => new StringValue(x)));
    249249      foreach (var input in checkedInputs) checkedInputs.SetItemCheckedState(input, extendedInputs.Contains(input.Value));
     
    297297      return modifiableDataset;
    298298    }
    299 
    300     public static IEnumerable<string> ExtendInputVariables(IEnumerable<string> oldInputVariables, IEnumerable<IDataAnalysisTransformation> transformations) {
    301       var inputs = new HashSet<string>(oldInputVariables);
    302 
    303       foreach (var transformation in transformations) {
    304         if (inputs.Contains(transformation.OriginalVariable))
    305           inputs.Add(transformation.TransformedVariable);
    306       }
    307 
    308       return inputs;
    309     }
    310 
    311     public static IEnumerable<string> RemoveVirtualVariables(IEnumerable<string> variables, IEnumerable<IDataAnalysisTransformation> transformations) {
    312       var remainingVariables = new HashSet<string>(variables);
    313 
    314       var transformationsStack = new Stack<IDataAnalysisTransformation>(transformations);
    315 
    316       while (transformationsStack.Any()) {
    317         var transformation = transformationsStack.Pop();
    318 
    319 
    320         bool transformedVariablePending = transformationsStack.Any(x => x.OriginalVariable == transformation.TransformedVariable);
    321         if (!transformedVariablePending)
    322           remainingVariables.Remove(transformation.TransformedVariable);
    323       }
    324 
    325       return remainingVariables;
    326     }
    327299  }
    328300}
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisTransformation.cs

    r15870 r15879  
    2929  [Item("Transformation", "A transformation applied to a DataAnalysisProblemData")]
    3030  [StorableClass]
    31   public class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation {
     31  public sealed class DataAnalysisTransformation : ParameterizedNamedItem, IDataAnalysisTransformation {
    3232    #region Parameter Properties
    3333    private IFixedValueParameter<StringValue> OriginalVariableParameter {
     
    6666    }
    6767
    68     protected DataAnalysisTransformation(DataAnalysisTransformation original, Cloner cloner)
     68    private DataAnalysisTransformation(DataAnalysisTransformation original, Cloner cloner)
    6969      : base(original, cloner) {
    7070    }
     
    7575
    7676    [StorableConstructor]
    77     protected DataAnalysisTransformation(bool deserializing)
     77    private DataAnalysisTransformation(bool deserializing)
    7878      : base(deserializing) { }
    7979
  • branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/ITransformation.cs

    r15846 r15879  
    2828
    2929  public interface ITransformation<T> : ITransformation {
     30    /// <summary>
     31    /// Checks if the data is valid for the transformation.
     32    /// Calling <code>Apply</code> or <code>Configure</code> on invalid data will throw an exception.
     33    /// </summary>
     34    /// <param name="data"></param>
     35    /// <param name="errorMessage"></param>
     36    /// <returns></returns>
    3037    bool Check(IEnumerable<T> data, out string errorMessage);
    3138
     39    /// <summary>
     40    /// Configure the internal parameter of the transformation for the given data.
     41    /// </summary>
     42    /// <param name="data"></param>
    3243    void Configure(IEnumerable<T> data);
    3344
     45    /// <summary>
     46    /// Transforms the given data based on the transformation's external and internal parameters.
     47    /// </summary>
     48    /// <param name="data"></param>
     49    /// <returns></returns>
    3450    IEnumerable<T> Apply(IEnumerable<T> data);
     51    /// <summary>
     52    /// Inverse-transforms the given data based on the transformation's external and internal parameters.
     53    /// </summary>
     54    /// <param name="data"></param>
     55    /// <returns></returns>
     56    /// <remarks>If the data cannot be inverse transformed, i.e. if the original data was not in the domain of the transformation,
     57    /// the returned values can contain invalid values or <code>InverseApply</code> might throw an exception.</remarks>
    3558    IEnumerable<T> InverseApply(IEnumerable<T> data);
    3659  }
Note: See TracChangeset for help on using the changeset viewer.