- Timestamp:
- 06/26/17 09:45:36 (7 years ago)
- Location:
- branches/Async/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs
r12012 r15065 22 22 using System; 23 23 using System.Linq; 24 using System.Threading;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Problems.DataAnalysis; … … 39 38 } 40 39 41 private EventWaitHandle trigger = new AutoResetEvent(false);42 40 private Exception ex; 43 41 … … 65 63 66 64 alg.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 67 alg.Stopped += new EventHandler(cv_Stopped);68 65 69 66 alg.Prepare(); 70 67 alg.Start(); 71 trigger.WaitOne();72 68 if (ex != null) throw ex; 73 69 … … 78 74 ex = e.Value; 79 75 } 80 81 private void cv_Stopped(object sender, EventArgs e) {82 trigger.Set();83 }84 76 } 85 77 } -
branches/Async/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GradientBoostingTest.cs
r13157 r15065 1 1 using System; 2 2 using System.Linq; 3 using System.Threading;4 3 using HeuristicLab.Data; 5 using HeuristicLab.Optimization;6 4 using HeuristicLab.Problems.DataAnalysis; 7 5 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 182 180 #endregion 183 181 184 RunAlgorithm(gbt);182 gbt.Start(); 185 183 186 184 Console.WriteLine(gbt.ExecutionTime); … … 210 208 #endregion 211 209 212 RunAlgorithm(gbt);210 gbt.Start(); 213 211 214 212 Console.WriteLine(gbt.ExecutionTime); … … 238 236 #endregion 239 237 240 RunAlgorithm(gbt);238 gbt.Start(); 241 239 242 240 Console.WriteLine(gbt.ExecutionTime); 243 241 Assert.AreEqual(0.061954221604374943, ((DoubleValue)gbt.Results["Loss (train)"].Value).Value, 1E-6); 244 242 Assert.AreEqual(0.06316303473499961, ((DoubleValue)gbt.Results["Loss (test)"].Value).Value, 1E-6); 245 }246 247 // same as in SamplesUtil248 private void RunAlgorithm(IAlgorithm a) {249 var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);250 Exception ex = null;251 a.Stopped += (src, e) => { trigger.Set(); };252 a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); };253 a.Prepare();254 a.Start();255 trigger.WaitOne();256 257 Assert.AreEqual(ex, null);258 243 } 259 244 -
branches/Async/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/SupportVectorMachineTest.cs
r12012 r15065 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading;26 25 using HeuristicLab.Algorithms.DataAnalysis; 27 26 using HeuristicLab.Common; … … 50 49 } 51 50 52 private EventWaitHandle trigger = new AutoResetEvent(false);53 51 private Exception ex; 54 52 … … 71 69 72 70 cv.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred); 73 cv.Stopped += new EventHandler(cv_Stopped);74 71 75 72 cv.Prepare(); 76 73 cv.Start(); 77 trigger.WaitOne();78 74 if (ex != null) throw ex; 79 75 … … 102 98 ex = e.Value; 103 99 } 104 105 private void cv_Stopped(object sender, EventArgs e) {106 trigger.Set();107 }108 100 } 109 101 }
Note: See TracChangeset
for help on using the changeset viewer.