Changeset 10540 for trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
- Timestamp:
- 03/05/14 15:08:11 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r9456 r10540 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Text; 25 26 using HeuristicLab.Collections; 26 27 using HeuristicLab.Common; … … 158 159 if (listeners != null) listeners(this, EventArgs.Empty); 159 160 } 161 162 protected virtual bool IsProblemDataCompatible(IDataAnalysisProblemData problemData, out string errorMessage) { 163 errorMessage = string.Empty; 164 if (problemData == null) throw new ArgumentNullException("problemData", "The provided problemData is null."); 165 166 //check allowed input variables 167 StringBuilder message = new StringBuilder(); 168 var variables = new HashSet<string>(problemData.InputVariables.Select(x => x.Value)); 169 foreach (var item in AllowedInputVariables) { 170 if (!variables.Contains(item)) 171 message.AppendLine("Input variable '" + item + "' is not present in the new problem data."); 172 } 173 174 if (message.Length != 0) { 175 errorMessage = message.ToString(); 176 return false; 177 } 178 return true; 179 180 } 181 182 public virtual void AdjustProblemDataProperties(IDataAnalysisProblemData problemData) { 183 DataAnalysisProblemData data = problemData as DataAnalysisProblemData; 184 if (data == null) throw new ArgumentException("The problem data is not a data analysis problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.", "problemData"); 185 186 string errorMessage; 187 if (!data.IsProblemDataCompatible(this, out errorMessage)) { 188 throw new InvalidOperationException(errorMessage); 189 } 190 191 foreach (var inputVariable in InputVariables) { 192 var variable = data.InputVariables.FirstOrDefault(i => i.Value == inputVariable.Value); 193 InputVariables.SetItemCheckedState(inputVariable, variable != null && data.InputVariables.ItemChecked(variable)); 194 } 195 196 TrainingPartition.Start = TrainingPartition.End = 0; 197 TestPartition.Start = 0; 198 TestPartition.End = Dataset.Rows; 199 } 160 200 } 161 201 }
Note: See TracChangeset
for help on using the changeset viewer.