{"record":{"id":"b6981906ad0067e0","repo":"stanfordnlp/CoreNLP","slug":"input-array-with-0-columns","errorCode":null,"errorMessage":"Input array with 0 columns","messagePattern":"Input array with 0 columns","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/neural/ConvertModels.java","lineNumber":83,"sourceCode":"    return out;\n  }\n\n  public static List<List<List<Double>>> fromTensor(SimpleTensor in) {\n    List<List<List<Double>>> out = new ArrayList<>();\n\n    for (int i = 0; i < in.numSlices(); ++i) {\n      out.add(fromMatrix(in.getSlice(i)));\n    }\n\n    return out;\n  }\n\n  public static SimpleMatrix toMatrix(List<List<Double>> in) {\n    if (in.size() == 0) {\n      throw new IllegalArgumentException(\"Input array with 0 rows\");\n    }\n    if (in.get(0).size() == 0) {\n      throw new IllegalArgumentException(\"Input array with 0 columns\");\n    }\n    for (int i = 1; i < in.size(); ++i) {\n      if (in.get(i).size() != in.get(0).size()) {\n        throw new IllegalArgumentException(\"Input array with uneven columns\");\n      }\n    }\n\n    SimpleMatrix out = new SimpleMatrix(in.size(), in.get(0).size());\n    for (int i = 0; i < in.size(); ++i) {\n      List<Double> row = in.get(i);\n      for (int j = 0; j < row.size(); ++j) {\n        out.set(i, j, row.get(j));\n      }\n    }\n\n    return out;\n  }\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/neural/ConvertModels.java#L65-L101","documentation":"ConvertModels.toMatrix rejects input where the first row has zero columns (in.get(0).size()==0), throwing IllegalArgumentException('Input array with 0 columns'). A matrix with rows but no columns cannot be dimensioned.","triggerScenarios":"Calling toMatrix with a non-empty outer list whose first element is an empty List<Double>, e.g. antecedentMatrix/anaphorMatrix built from a model with no features per entry.","commonSituations":"Model files serialized with empty per-row vectors, or feature-extraction producing empty lists for every entry during model conversion.","solutions":["Ensure each inner list has at least one element before calling toMatrix","Check the upstream feature extraction for rows that produce zero features","Inspect the source model serialization for empty vectors"],"exampleFix":"// before\nSimpleMatrix m = ConvertModels.toMatrix(rows);\n// after\nif (rows.isEmpty() || rows.get(0).isEmpty()) { throw new IllegalStateException(\"row has 0 columns\"); }\nSimpleMatrix m = ConvertModels.toMatrix(rows);","handlingStrategy":"validation","validationCode":"if (rows == null || rows.isEmpty() || rows.get(0).isEmpty()) {\n  throw new IllegalArgumentException(\"toMatrix requires at least one column in row 0\");\n}","typeGuard":"static boolean hasColumns(java.util.List<java.util.List<Double>> rows) {\n  return rows != null && !rows.isEmpty() && rows.get(0) != null && !rows.get(0).isEmpty();\n}","tryCatchPattern":"try {\n  SimpleMatrix m = ConvertModels.toMatrix(rows);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"0 columns\")) {\n    throw new IllegalStateException(\"model rows have no features; check feature extraction\", e);\n  }\n  throw e;\n}","preventionTips":["Reject empty inner rows at feature-extraction time","Sanity-check the first row of any List<List<Double>> built from deserialized models","Log feature counts per entry to catch all-empty rows early"],"tags":["matrix","validation","neural","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}