- Timestamp:
- 06/28/21 10:35:19 (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis/3.4/DatasetExtensions.cs
r17911 r17999 96 96 } 97 97 98 public static IntervalCollection GetIntervals(this IDataset dataset) { 99 IntervalCollection intervalCollection = new IntervalCollection(); 100 foreach (var variable in dataset.DoubleVariables) { // intervals are only possible for double variables 101 var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable)); 102 intervalCollection.AddInterval(variable, variableInterval); 98 public static IntervalCollection GetVariableRanges(this IDataset dataset, bool ignoreNaNs = true) { 99 IntervalCollection variableRanges = new IntervalCollection(); 100 foreach (var variable in dataset.DoubleVariables) { // ranges can only be calculated for double variables 101 var values = dataset.GetDoubleValues(variable); 102 103 if (ignoreNaNs) { 104 values = values.Where(v => !double.IsNaN(v)); 105 106 if (!values.Any()) { //handle values with only NaNs explicitly 107 var emptyInterval = new Interval(double.NaN, double.NaN); 108 variableRanges.AddInterval(variable, emptyInterval); 109 continue; 110 } 111 } 112 113 var interval = Interval.GetInterval(values); 114 variableRanges.AddInterval(variable, interval); 103 115 } 104 116 105 return intervalCollection;117 return variableRanges; 106 118 } 107 119
Note: See TracChangeset
for help on using the changeset viewer.