{"record":{"id":"a99aca30cd084c65","repo":"stanfordnlp/CoreNLP","slug":"logprior-getsigmasquaredm-is-undefined-for-any-pri","errorCode":null,"errorMessage":"LogPrior.getSigmaSquaredM is undefined for any prior but MULTIPLE_QUADRATIC","messagePattern":"LogPrior\\.getSigmaSquaredM is undefined for any prior but MULTIPLE_QUADRATIC","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/classify/LogPrior.java","lineNumber":143,"sourceCode":"      return otherPrior.getSigma();\n    } else {\n      return Math.sqrt(sigmaSq);\n    }\n  }\n\n  public double getSigmaSquared() {\n    if (type == LogPriorType.ADAPT) {\n      return otherPrior.getSigmaSquared();\n    } else {\n      return sigmaSq;\n    }\n  }\n\n  public double[] getSigmaSquaredM() {\n    if (type == LogPriorType.MULTIPLE_QUADRATIC) {\n      return sigmaSqM;\n    } else {\n      throw new RuntimeException(\"LogPrior.getSigmaSquaredM is undefined for any prior but MULTIPLE_QUADRATIC\" + this);\n    }\n  }\n\n\n  public double getEpsilon() {\n    if (type == LogPriorType.ADAPT) {\n      return otherPrior.getEpsilon();\n    } else {\n      return epsilon;\n    }\n  }\n\n  public void setSigma(double sigma) {\n    if (type == LogPriorType.ADAPT) { otherPrior.setSigma(sigma); }\n    else {\n//    this.sigma = sigma;\n      this.sigmaSq = sigma * sigma;\n      this.sigmaQu = sigmaSq * sigmaSq;","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/classify/LogPrior.java#L125-L161","documentation":"LogPrior.getSigmaSquaredM() returns the per-dimension sigma-squared vector, which is only maintained for the MULTIPLE_QUADRATIC prior. For any other prior type the field is uninitialized, so the method throws a RuntimeException rather than returning meaningless data. The message also includes the prior's toString.","triggerScenarios":"Calling getSigmaSquaredM() on a LogPrior whose type is NULL, QUADRATIC, HUBER, QUARTIC, COSH, or ADAPT instead of MULTIPLE_QUADRATIC — e.g., from sigmaSquaredOld() or user code inspecting the prior.","commonSituations":"Code written generically over priors assuming a sigma vector always exists; switching a training config from multiple-quadratic to huber/quadratic while diagnostics still read getSigmaSquaredM().","solutions":["Only call getSigmaSquaredM() when getPriorType() == LogPriorType.MULTIPLE_QUADRATIC","For simple priors use getSigma()/getEpsilon() accessors appropriate to the prior type","Wrap the call in a type check and use a different estimation for other priors"],"exampleFix":"// before\ndouble[] sig = prior.getSigmaSquaredM();\n// after\nif (prior.getPriorType() == LogPrior.LogPriorType.MULTIPLE_QUADRATIC) {\n  double[] sig = prior.getSigmaSquaredM();\n}","handlingStrategy":"type-guard","validationCode":"if (prior.getPriorType() != LogPrior.LogPriorType.MULTIPLE_QUADRATIC)\n  throw new IllegalStateException(\"getSigmaSquaredM requires MULTIPLE_QUADRATIC prior\");","typeGuard":"boolean supportsSigmaVector(LogPrior p) {\n  return p.getPriorType() == LogPrior.LogPriorType.MULTIPLE_QUADRATIC;\n}","tryCatchPattern":"try {\n  double[] s = prior.getSigmaSquaredM();\n} catch (RuntimeException e) {\n  // fall back to scalar sigma for simple priors\n  double sigma = prior.getSigma();\n}","preventionTips":["Check getPriorType() before calling vector-valued accessors","Keep prior-type-specific diagnostics in separate code paths","Document in your training harness which prior types support per-feature sigma"],"tags":["java","runtimeexception","unsupported-operation","prior"],"backgroundTag":"unsupported-operation","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"}