- Timestamp:
- 05/31/17 16:15:08 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r14864 r15013 74 74 throw new ArgumentException(message); 75 75 } 76 DatasetUtil.ValidateInputData(variableValues); // the validation call checks if every values IList is actually a list of the supported type77 76 rows = variableValues.First().Count; 78 77 this.variableNames = new List<string>(variableNames); … … 175 174 } 176 175 public IEnumerable<string> DoubleVariables { 177 get { return variableValues.Where(p => p.Value is List<double>).Select(p => p.Key); }176 get { return variableValues.Where(p => p.Value is IList<double>).Select(p => p.Key); } 178 177 } 179 178 180 179 public IEnumerable<string> StringVariables { 181 get { return variableValues.Where(p => p.Value is List<string>).Select(p => p.Key); }180 get { return variableValues.Where(p => p.Value is IList<string>).Select(p => p.Key); } 182 181 } 183 182 … … 194 193 public ReadOnlyCollection<double> GetReadOnlyDoubleValues(string variableName) { 195 194 var values = GetValues<double>(variableName); 196 return values.AsReadOnly();195 return new ReadOnlyCollection<double>(values); 197 196 } 198 197 public double GetDoubleValue(string variableName, int row) { … … 214 213 public ReadOnlyCollection<string> GetReadOnlyStringValues(string variableName) { 215 214 var values = GetValues<string>(variableName); 216 return values.AsReadOnly();215 return new ReadOnlyCollection<string>(values); 217 216 } 218 217 … … 221 220 return rows.Select(x => values[x]); 222 221 } 223 private List<T> GetValues<T>(string variableName) {222 private IList<T> GetValues<T>(string variableName) { 224 223 IList list; 225 224 if (!variableValues.TryGetValue(variableName, out list)) 226 225 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 227 List<T> values = list asList<T>;226 IList<T> values = list as IList<T>; 228 227 if (values == null) throw new ArgumentException("The variable " + variableName + " is not a " + typeof(T) + " variable."); 229 228 return values;
Note: See TracChangeset
for help on using the changeset viewer.