- Timestamp:
- 07/11/15 13:37:32 (9 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12077,12112,12116-12117,12131,12173,12458,12599,12613,12631,12672,12684,12690,12692
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Analysis.Statistics.Views/3.3/ChartAnalysisView.cs
r12009 r12725 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading; 25 26 using System.Threading.Tasks; 26 27 using System.Windows.Forms; … … 52 53 private bool valuesAdded = false; 53 54 private bool suppressUpdates = false; 55 private SemaphoreSlim sem = new SemaphoreSlim(1, 1); 54 56 55 57 public ChartAnalysisView() { … … 108 110 109 111 void Content_RowsChanged(object sender, EventArgs e) { 110 RebuildDataTableAsync(); 112 if (suppressUpdates) return; 113 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_RowsChanged, sender, e); 114 else { 115 RebuildDataTableAsync(); 116 } 111 117 } 112 118 113 119 void Content_ColumnsChanged(object sender, EventArgs e) { 114 RebuildDataTableAsync(); 120 if (suppressUpdates) return; 121 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_ColumnsChanged, sender, e); 122 else { 123 UpdateDataTableComboBox(); 124 RebuildDataTableAsync(); 125 } 115 126 } 116 127 117 128 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) { 118 UpdateComboboxes(); 119 RebuildDataTableAsync(); 129 if (suppressUpdates) return; 130 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IRun>>)Content_CollectionReset, sender, e); 131 else { 132 UpdateComboboxes(); 133 RebuildDataTableAsync(); 134 } 120 135 } 121 136 122 137 private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 123 suppressUpdates = Content.UpdateOfRunsInProgress; 124 125 if (!suppressUpdates && !valuesAdded) { 126 RebuildDataTableAsync(); 127 } 128 if (valuesAdded) { 129 valuesAdded = false; 138 if (InvokeRequired) Invoke((Action<object, EventArgs>)Content_UpdateOfRunsInProgressChanged, sender, e); 139 else { 140 suppressUpdates = Content.UpdateOfRunsInProgress; 141 142 if (!suppressUpdates && !valuesAdded) { 143 UpdateDataTableComboBox(); 144 RebuildDataTableAsync(); 145 } 146 if (valuesAdded) { 147 valuesAdded = false; 148 } 130 149 } 131 150 } … … 149 168 150 169 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 170 if (suppressUpdates) return; 151 171 RebuildDataTableAsync(); 152 172 } … … 246 266 247 267 private void RebuildDataTableAsync() { 248 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values...");249 250 268 string resultName = (string)dataTableComboBox.SelectedItem; 269 if (string.IsNullOrEmpty(resultName)) return; 270 251 271 string rowName = (string)dataRowComboBox.SelectedItem; 252 272 253 var task = Task.Factory.StartNew(() => RebuildDataTable(resultName, rowName)); 273 var task = Task.Factory.StartNew(() => { 274 sem.Wait(); 275 progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Calculating values..."); 276 RebuildDataTable(resultName, rowName); 277 }); 254 278 255 279 task.ContinueWith((t) => { 256 280 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 257 281 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 282 sem.Release(); 258 283 }, TaskContinuationOptions.OnlyOnFaulted); 259 284 260 285 task.ContinueWith((t) => { 261 286 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 287 sem.Release(); 262 288 }, TaskContinuationOptions.OnlyOnRanToCompletion); 263 289 } … … 289 315 double percentile25 = values.Percentile(0.25); 290 316 double percentile75 = values.Percentile(0.75); 291 double lowerAvg = values. OrderBy(x => x).Take((int)(values.Count() * 0.25)).Average();292 double upperAvg = values. OrderByDescending(x => x).Take((int)(values.Count() * 0.25)).Average();293 double firstAvg = values. Take((int)(values.Count() * 0.25)).Average();294 double lastAvg = values. Skip((int)(values.Count() * 0.75)).Average();317 double lowerAvg = values.Count() > 4 ? values.OrderBy(x => x).Take((int)(values.Count() * 0.25)).Average() : double.NaN; 318 double upperAvg = values.Count() > 4 ? values.OrderByDescending(x => x).Take((int)(values.Count() * 0.25)).Average() : double.NaN; 319 double firstAvg = values.Count() > 4 ? values.Take((int)(values.Count() * 0.25)).Average() : double.NaN; 320 double lastAvg = values.Count() > 4 ? values.Skip((int)(values.Count() * 0.75)).Average() : double.NaN; 295 321 double slope, intercept, r; 296 322 llsFitting.Calculate(values, out slope, out intercept);
Note: See TracChangeset
for help on using the changeset viewer.