Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2913_MatlabScriptProblemInstanceProvider/HeuristicLab.Problems.Instances.DataAnalysis.Views/3.3/Regression/Matlab/MLDoubleArrayLoader.cs @ 15958

Last change on this file since 15958 was 15926, checked in by rhanghof, 7 years ago

#2913:

  • Added the support for importing different Matlab datatypes.
  • Added some classes and changed the import dialog for importing double arrays.
File size: 1.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading;
6using System.Threading.Tasks;
7using System.Windows.Forms;
8using HeuristicLab.Problems.DataAnalysis;
9using HeuristicLab.Problems.Instances.DataAnalysis.Regression.Matlab.Api;
10using HeuristicLab.Problems.Instances.DataAnalysis.Regression.Matlab.Api.Types;
11
12namespace HeuristicLab.Problems.Instances.DataAnalysis.Views.Regression.Matlab {
13  public partial class RegressionMatlabImportDialog {
14    private class MLDoubleArrayLoader : MLVariablesLoader {
15      public MLDoubleArrayLoader(RegressionMatlabImportDialog importDialog, CheckedListBox variablesListBox)
16        : base(importDialog, variablesListBox, MLDatatype.DoubleArray) {
17      }
18     
19      public override Dataset GetPreviewDataset(IMatlabConnector mlConnector, CancellationToken token) {
20        var doubleArrays = new List<MLDoubleArray>();       
21
22        foreach (MLVariableInfo item in _variablesListBox.CheckedItems.Cast< MLVariableInfo>().ToList()) {
23          if (token.IsCancellationRequested) {
24            return null;
25          }
26
27          if (item.Datatype == _mlDatatype) {
28            var val = mlConnector.GetDoubleArray(item.VarName);
29            if (val != null) {
30              doubleArrays.Add(val);
31            }
32          }
33        }
34        var merged = MLDoubleArray.Concat(doubleArrays);
35        return new Dataset(merged.DataHeader, merged.Data);
36      }
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.