From commits-return-72681-archive-asf-public=cust-asf.ponee.io@commons.apache.org Sun Apr 5 12:44:09 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5677C180638 for ; Sun, 5 Apr 2020 14:44:09 +0200 (CEST) Received: (qmail 69525 invoked by uid 500); 5 Apr 2020 12:44:06 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 68993 invoked by uid 99); 5 Apr 2020 12:44:05 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2020 12:44:05 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 5FBB481A15; Sun, 5 Apr 2020 12:44:05 +0000 (UTC) Date: Sun, 05 Apr 2020 12:44:09 +0000 To: "commits@commons.apache.org" Subject: [commons-numbers] 04/06: Increase coverage in TrigammaTest. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: aherbert@apache.org In-Reply-To: <158609064525.12606.6585162135697734800@gitbox.apache.org> References: <158609064525.12606.6585162135697734800@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: commons-numbers X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: b7cd42b24c3c1932f5e70c7718893f73f1db45dd X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20200405124405.5FBB481A15@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git commit b7cd42b24c3c1932f5e70c7718893f73f1db45dd Author: Alex Herbert AuthorDate: Sun Apr 5 13:00:50 2020 +0100 Increase coverage in TrigammaTest. This sets the allowed delta using the maximum of the relative error of 1e8 or absolute error of 1e8 as defined in the method javadoc. It adds additional data for values below the algorithm computation switch point (1e5). These would fail at 1e8 absolute error but pass at 1e8 relative error as the result is very big. --- .../org/apache/commons/numbers/gamma/TrigammaTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java index f14fe78..1a8012f 100644 --- a/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java +++ b/commons-numbers-gamma/src/test/java/org/apache/commons/numbers/gamma/TrigammaTest.java @@ -30,6 +30,14 @@ public class TrigammaTest { // // http://functions.wolfram.com/webMathematica/Evaluated.jsp?name=PolyGamma2&plottype=0&vars={%221%22,%22$i%22}&digits=20 double[] data = { + 0.0, Double.POSITIVE_INFINITY, + 1e-11, 1e22, + 1e-10, 1e20, + 1e-9, 1.0000000000000000016e18, + 1e-8, 1.0000000000000001645e16, + 1e-7, 1.0000000000000164493e14, + 1e-6, 1.0000000000016449317e12, + 1e-5, 1.0000000001644910026e10, 1e-4, 1.0000000164469368793e8, 1e-3, 1.0000016425331958690e6, 1e-2, 10001.621213528313220, @@ -45,7 +53,11 @@ public class TrigammaTest { 100, 0.010050166663333571395 }; for (int i = data.length - 2; i >= 0; i -= 2) { - Assertions.assertEquals(data[i + 1], Trigamma.value(data[i]), eps, String.format("trigamma %.0f", data[i])); + final double value = data[i]; + final double expected = data[i + 1]; + // Allowed error is 1e-8 relative or absolute error whichever is larger. + final double error = Math.max(expected * eps, eps); + Assertions.assertEquals(expected, Trigamma.value(value), error, () -> "trigamma " + value); } }