{"record":{"id":"a97275c0a0ed067d","repo":"stanfordnlp/CoreNLP","slug":"the-components-of-this-averagedataseries-do-not-ha","errorCode":null,"errorMessage":"The components of this AverageDataSeries do not have the same domains!","messagePattern":"The components of this AverageDataSeries do not have the same domains!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/stats/DataSeries.java","lineNumber":359,"sourceCode":"    public double get(int i) {\n      double y = 0.0;\n      for (DataSeries series : components)\n        y += series.get(i);\n      return y / components.length;\n    }\n\n    public int size() {\n      int size = Integer.MAX_VALUE;\n      for (DataSeries series : components)\n        size = Math.min(size, series.size());\n      return size;\n    }\n\n    public DataSeries domain() {\n      DataSeries domain = components[0].domain(); // could be null\n      for (DataSeries series : components)\n        if (series.domain() != domain)\n          throw new IllegalStateException(\"The components of this AverageDataSeries do not have the same domains!\");\n      return domain;\n    }\n\n    @Override\n    public String toString() { return name(); }\n\n  }\n\n}\n","sourceCodeStart":341,"sourceCodeEnd":369,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/stats/DataSeries.java#L341-L369","documentation":"AverageDataSeries.domain() requires all components to report the identical domain (same domain object). It takes components[0]'s domain and throws IllegalStateException if any other component's domain() returns a different reference, because averaging series over different x-points is undefined. Note the comparison uses reference inequality (!=), so components from independently constructed series with equal content may still fail.","triggerScenarios":"Constructing an AverageDataSeries from series whose domain() implementations return different domain objects; domain() is also called from the constructor, so simply building the AverageDataSeries can trigger it.","commonSituations":"Combining series loaded from different files or produced by different pipelines where each creates its own domain instance, even when the domains logically match.","solutions":["Ensure all component series share the same domain object (pass the same domain instance to each series).","Rebuild/normalize each component's data onto a common domain before averaging.","If domains are logically equal but distinct objects, pre-merge them into one canonical domain object and assign it to all components."],"exampleFix":"// before\nDataSeries d1 = makeDomain(xs);\nDataSeries d2 = makeDomain(xs); // equal but distinct object\nAverageDataSeries avg = new AverageDataSeries(new DataSeries[]{s1(d1), s2(d2)}); // throws\n// after\nDataSeries shared = makeDomain(xs);\nAverageDataSeries avg = new AverageDataSeries(new DataSeries[]{s1(shared), s2(shared)});","handlingStrategy":"validation","validationCode":"Object domain0 = components[0].domain();\nfor (DataSeries s : components) {\n  if (s.domain() != domain0) {\n    throw new IllegalStateException(\"Components must share the same domain object before averaging\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  avg = new AverageDataSeries(components);\n} catch (IllegalStateException e) {\n  DataSeries canonical = components[0].domain();\n  for (DataSeries s : components) s = rebindDomain(s, canonical); // rebuild on shared domain\n  avg = new AverageDataSeries(components);\n}","preventionTips":["Construct all component series from one shared domain object.","Normalize series onto a common domain before combining.","Remember domain comparison is by reference (==), not content equality."],"tags":["invalid-state","domain-mismatch","series"],"backgroundTag":"invalid-state-transition","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}