Skip to content

Commit

Permalink
Catch hipparchus MathRuntimeException in PearsonCorrelationTest#evaluate
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Nov 12, 2023
1 parent aa2166e commit 174c2dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6074,6 +6074,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
return Errors.printMessage(S.PearsonCorrelationTest, "vctnln3", F.List(arg2, F.C2, F.C1),
engine);
}
try {
RealMatrix m = new Array2DRowRealMatrix(dimension1, dimension2);
m.setColumn(0, vector1);
m.setColumn(1, vector2);
Expand Down Expand Up @@ -6103,6 +6104,9 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
// return F.NIL;
// }
return testData(vector1, vector2, test);
} catch (MathRuntimeException miae) {
return Errors.printMessage(S.PearsonCorrelationTest, miae, engine);
}
}
// The argument `1` at position `2` should be a vector of real numbers with length greater
// than `3`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ public void testPDF() {
}

public void testPearsonCorrelationTest() {
check("PearsonCorrelationTest({0,0},{0,0}, \"PValue\")", //
"PearsonCorrelationTest({0,0},{0,0},PValue)");
// example from https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
check("PearsonCorrelationTest({1, 2, 3, 5, 8}, {0.11, 0.12, 0.13, 0.15, 0.18}, \"TestData\")", //
"{1.0,0.0}");
Expand Down

0 comments on commit 174c2dd

Please sign in to comment.