Ignore:
Timestamp:
04/14/16 13:33:02 (6 years ago)
Author:
bburlacu
Message:

#2593: Add ToModifiable method to the Dataset class. Add ReplaceColumn method to the ModifiableDataset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs

    r13040 r13760  
    22
    33/* HeuristicLab
    4  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    55 *
    66 * This file is part of HeuristicLab.
     
    5656    public ModifiableDataset() : base() { }
    5757
    58     public ModifiableDataset(Dataset dataset) : base(dataset) { }
    5958    public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) : base(variableNames, variableValues) { }
    6059
     
    7473      }
    7574      OnReset();
     75    }
     76
     77    public void ReplaceColumn<T>(string variableName, List<T> values) {
     78      if (!variableValues.ContainsKey(variableName))
     79        throw new ArgumentException(string.Format("Variable {0} is not present in the dataset."), variableName);
     80      if (values.Count != variableValues[variableName].Count)
     81        throw new ArgumentException("The number of values must coincide with the number of dataset rows.");
     82      if (GetVariableType(variableName) != values[0].GetType())
     83        throw new ArgumentException("The type of the provided value does not match the variable type.");
     84      variableValues[variableName] = values;
    7685    }
    7786
Note: See TracChangeset for help on using the changeset viewer.