- Timestamp:
- 08/29/18 09:44:07 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement
- Property svn:mergeinfo changed
/trunk merged: 16059,16063,16071,16084-16086
- Property svn:mergeinfo changed
-
branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis merged: 16059,16063,16084
- Property svn:mergeinfo changed
-
branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs
r16057 r16092 116 116 117 117 public ModifiableDataset ToModifiable() { 118 var values = new List<IList>(); 119 foreach (var v in variableNames) { 120 if (VariableHasType<double>(v)) { 121 values.Add(new List<double>((IList<double>)variableValues[v])); 122 } else if (VariableHasType<string>(v)) { 123 values.Add(new List<string>((IList<string>)variableValues[v])); 124 } else if (VariableHasType<DateTime>(v)) { 125 values.Add(new List<DateTime>((IList<DateTime>)variableValues[v])); 126 } else { 127 throw new ArgumentException("Unknown variable type."); 128 } 129 } 130 return new ModifiableDataset(variableNames, values); 118 return new ModifiableDataset(variableNames, variableNames.Select(v => variableValues[v]), true); 131 119 } 132 120 … … 141 129 } 142 130 143 protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { } 131 144 132 145 133 #region Backwards compatible code, remove with 3.5 … … 318 306 #region IStringConvertibleMatrix Members 319 307 [Storable] 320 pr otectedint rows;308 private int rows; 321 309 public int Rows { 322 310 get { return rows; } 311 protected set { rows = value; } 323 312 } 324 313 int IStringConvertibleMatrix.Rows { -
branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r16057 r16092 163 163 164 164 var variables = dataset.VariableNames.Where(variable => dataset.VariableHasType<double>(variable) || dataset.VariableHasType<string>(variable)); 165 var inputVariables = new CheckedItemList<StringValue>(variables.Select(x => new StringValue(x) ));165 var inputVariables = new CheckedItemList<StringValue>(variables.Select(x => new StringValue(x).AsReadOnly())); 166 166 foreach (StringValue x in inputVariables) 167 167 inputVariables.SetItemCheckedState(x, allowedInputVariables.Contains(x.Value)); -
branches/2839_HiveProjectManagement/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
r16057 r16092 47 47 public ModifiableDataset() { } 48 48 49 public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues) : 50 base(variableNames, variableValues, cloneValues: false) { } 51 49 public ModifiableDataset(IEnumerable<string> variableNames, IEnumerable<IList> variableValues, bool cloneValues = false) : 50 base(variableNames, variableValues, cloneValues) { } 51 52 public Dataset ToDataset() { 53 return new Dataset(variableNames, variableNames.Select(v => variableValues[v])); 54 } 52 55 public void ReplaceRow(int row, IEnumerable<object> values) { 53 56 var list = values.ToList(); … … 91 94 variableValues[variableNames[i]].Add(list[i]); 92 95 } 93 rows++;96 Rows++; 94 97 OnRowsChanged(); 95 98 OnReset(); … … 98 101 // adds a new variable to the dataset 99 102 public void AddVariable(string variableName, IList values) { 103 InsertVariable(variableName, Columns, values); 104 } 105 106 107 public void InsertVariable(string variableName, int position, IList values) { 100 108 if (variableValues.ContainsKey(variableName)) 101 109 throw new ArgumentException(string.Format("Variable {0} is already present in the dataset.", variableName)); 102 110 103 if (values == null || values.Count == 0) 104 throw new ArgumentException("Cannot add variable with no values."); 111 if (position < 0 || position > Columns) 112 throw new ArgumentException(string.Format("Incorrect position {0} specified. The position must be between 0 and {1}.", position, Columns)); 113 114 if (values == null) 115 throw new ArgumentNullException("values", "Values must not be null. At least an empty list of values has to be provided."); 116 117 if (values.Count != Rows) 118 throw new ArgumentException(string.Format("{0} values are provided, but {1} rows are present in the dataset.", values.Count, Rows)); 105 119 106 120 if (!IsAllowedType(values)) 107 121 throw new ArgumentException(string.Format("Unsupported type {0} for variable {1}.", GetElementType(values), variableName)); 108 122 123 variableNames.Insert(position, variableName); 109 124 variableValues[variableName] = values; 110 variableNames.Add(variableName);111 125 112 126 OnColumnsChanged(); … … 129 143 foreach (var list in variableValues.Values) 130 144 list.RemoveAt(row); 131 rows--;145 Rows--; 132 146 OnRowsChanged(); 133 147 OnReset();
Note: See TracChangeset
for help on using the changeset viewer.