You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/09/19 20:37:08 UTC

[commons-rng] branch master updated: Explicit factory method name

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-rng.git


The following commit(s) were added to refs/heads/master by this push:
     new 2cd0ddc0 Explicit factory method name
2cd0ddc0 is described below

commit 2cd0ddc04c1a523d8ce9bea420084642776c84e6
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Mon Sep 19 21:02:28 2022 +0100

    Explicit factory method name
    
    Reuse of the method with the annotation @MethodSource(value =
    {"testSamplesFrequencies"}) led to a JUnit runtime error on JDK 17 with
    commons-parent 54.
---
 .../FastLoadedDiceRollerDiscreteSamplerTest.java           | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/FastLoadedDiceRollerDiscreteSamplerTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/FastLoadedDiceRollerDiscreteSamplerTest.java
index 27350dc9..2ccf43c4 100644
--- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/FastLoadedDiceRollerDiscreteSamplerTest.java
+++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/FastLoadedDiceRollerDiscreteSamplerTest.java
@@ -351,6 +351,18 @@ class FastLoadedDiceRollerDiscreteSamplerTest {
         Assertions.assertFalse(chiSquareTest.chiSquareTest(expected, observed, 0.001));
     }
 
+    /**
+     * Return a stream of expected frequencies for a discrete distribution where the frequencies
+     * can be converted to a {@code double} without loss of precision.
+     *
+     * @return the stream of expected frequencies
+     */
+    static Stream<long[]> testSamplesWeightsMatchesFrequencies() {
+        // Reuse the same frequencies.
+        // Those that cannot be converted to a double are ignored by the test.
+        return testSamplesFrequencies();
+    }
+
     /**
      * Check the distribution of samples when the frequencies can be converted to weights without
      * loss of precision.
@@ -358,7 +370,7 @@ class FastLoadedDiceRollerDiscreteSamplerTest {
      * @param frequencies Expected frequencies.
      */
     @ParameterizedTest
-    @MethodSource(value = {"testSamplesFrequencies"})
+    @MethodSource
     void testSamplesWeightsMatchesFrequencies(long[] frequencies) {
         final double[] weights = new double[frequencies.length];
         for (int i = 0; i < frequencies.length; i++) {