Changeset 13760 for trunk/sources
- Timestamp:
- 04/14/16 13:33:02 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r13539 r13760 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 111 111 } 112 112 113 public ModifiableDataset ToModifiable() { 114 var values = new List<IList>(); 115 foreach (var v in variableNames) { 116 if (VariableHasType<double>(v)) { 117 values.Add(((List<double>)variableValues[v]).ToList()); 118 } else if (VariableHasType<string>(v)) { 119 values.Add(((List<string>)variableValues[v]).ToList()); 120 } else if (VariableHasType<DateTime>(v)) { 121 values.Add(((List<DateTime>)variableValues[v]).ToList()); 122 } else { 123 throw new ArgumentException("Unknown variable type."); 124 } 125 } 126 return new ModifiableDataset(variableNames, values); 127 } 128 113 129 protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { } 114 130 -
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
r13040 r13760 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. … … 56 56 public ModifiableDataset() : base() { } 57 57 58 public ModifiableDataset(Dataset dataset) : base(dataset) { }59 58 public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) : base(variableNames, variableValues) { } 60 59 … … 74 73 } 75 74 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; 76 85 } 77 86
Note: See TracChangeset
for help on using the changeset viewer.