Free cookie consent management tool by TermsFeed Policy Generator

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

#2906 minor refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.