Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
r12511 r14029 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 37 37 [StorableConstructor] 38 38 private ModifiableDataset(bool deserializing) : base(deserializing) { } 39 private ModifiableDataset(ModifiableDataset original, Cloner cloner) : base(original, cloner) { } 39 40 private ModifiableDataset(ModifiableDataset original, Cloner cloner) : base(original, cloner) { 41 var variables = variableValues.Keys.ToList(); 42 foreach (var v in variables) { 43 var type = GetVariableType(v); 44 if (type == typeof(DateTime)) { 45 variableValues[v] = GetDateTimeValues(v).ToList(); 46 } else if (type == typeof(double)) { 47 variableValues[v] = GetDoubleValues(v).ToList(); 48 } else if (type == typeof(string)) { 49 variableValues[v] = GetStringValues(v).ToList(); 50 } else { 51 throw new ArgumentException("Unsupported type " + type + " for variable " + v); 52 } 53 } 54 } 40 55 public override IDeepCloneable Clone(Cloner cloner) { return new ModifiableDataset(this, cloner); } 41 56 public ModifiableDataset() : base() { } 42 57 43 public ModifiableDataset(Dataset dataset) : base(dataset) { }44 58 public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) : base(variableNames, variableValues) { } 45 59 … … 59 73 } 60 74 OnReset(); 75 } 76 77 public void ReplaceVariable(string variableName, IList 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; 61 85 } 62 86
Note: See TracChangeset
for help on using the changeset viewer.