Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/14/16 13:33:02 (8 years ago)
Author:
bburlacu
Message:

#2593: Add ToModifiable method to the Dataset class. Add ReplaceColumn method to the ModifiableDataset.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Dataset.cs

    r13539 r13760  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    111111    }
    112112
     113    public ModifiableDataset ToModifiable() {
     114      var values = new List<IList>();
     115      foreach (var v in variableNames) {
     116        if (VariableHasType<double>(v)) {
     117          values.Add(((List<double>)variableValues[v]).ToList());
     118        } else if (VariableHasType<string>(v)) {
     119          values.Add(((List<string>)variableValues[v]).ToList());
     120        } else if (VariableHasType<DateTime>(v)) {
     121          values.Add(((List<DateTime>)variableValues[v]).ToList());
     122        } else {
     123          throw new ArgumentException("Unknown variable type.");
     124        }
     125      }
     126      return new ModifiableDataset(variableNames, values);
     127    }
     128
    113129    protected Dataset(Dataset dataset) : this(dataset.variableNames, dataset.variableValues.Values) { }
    114130
Note: See TracChangeset for help on using the changeset viewer.