Changeset 17828 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
- Timestamp:
- 02/01/21 14:37:18 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17560 r17828 34 34 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C")); 35 35 36 public override bool CanConvertType(Type t) => 37 ConvertableType.IsAssignableFrom(t); 38 36 39 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 37 40 … … 180 183 if(it != null) { 181 184 if(it.MoveNext() && it.Current is double) { 182 CreateMatrix(dict, out IList<string> rowNames, out double[][] mat);185 CreateMatrix(dict, out IList<string> columnNames, out double[][] mat); 183 186 return new DoubleMatrixJsonItem() { 184 187 Name = Dataset, 185 188 Value = mat, 186 RowNames = rowNames,189 ColumnNames = columnNames, 187 190 Minimum = double.MinValue, 188 191 Maximum = double.MaxValue 189 192 }; 190 193 } else if(it.Current is int) { 191 CreateMatrix(dict, out IList<string> rowNames, out int[][] mat);194 CreateMatrix(dict, out IList<string> columnNames, out int[][] mat); 192 195 return new IntMatrixJsonItem() { 193 196 Name = Dataset, 194 197 Value = mat, 195 RowNames = rowNames,198 ColumnNames = columnNames, 196 199 Minimum = int.MinValue, 197 200 Maximum = int.MaxValue 198 201 }; 199 202 } else if (it.Current is bool) { 200 CreateMatrix(dict, out IList<string> rowNames, out bool[][] mat);203 CreateMatrix(dict, out IList<string> columnNames, out bool[][] mat); 201 204 return new BoolMatrixJsonItem() { 202 205 Name = Dataset, 203 206 Value = mat, 204 RowNames = rowNames207 ColumnNames = columnNames 205 208 }; 206 209 } … … 210 213 } 211 214 212 private void CreateMatrix<T>(Dictionary<string, IList> dict, out IList<string> rowNames, out T[][] matrix) {215 private void CreateMatrix<T>(Dictionary<string, IList> dict, out IList<string> columnNames, out T[][] matrix) { 213 216 int cols = dict.Count, rows = 0, c = 0; 214 rowNames = new List<string>();217 columnNames = new List<string>(); 215 218 matrix = new T[cols][]; 216 219 foreach (var x in dict) { 217 220 rows = Math.Max(rows, x.Value.Count); 218 rowNames.Add(x.Key);221 columnNames.Add(x.Key); 219 222 220 223 matrix[c] = new T[rows]; 224 221 225 int r = 0; 222 223 foreach (var rowValue in x.Value) { 224 matrix[c][r] = (T)rowValue; 226 foreach (var callValue in x.Value) { 227 matrix[c][r] = (T)callValue; 225 228 ++r; 226 229 }
Note: See TracChangeset
for help on using the changeset viewer.