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 2023/10/15 08:48:35 UTC
[commons-statistics] 02/02: Test product with non-finite values and zero/non-zero
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-statistics.git
commit c5d9488e777559d4356dddf5ef54187054bd591e
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sun Oct 15 09:48:24 2023 +0100
Test product with non-finite values and zero/non-zero
---
.../descriptive/BaseDoubleStatisticTest.java | 20 ++++++++++----------
.../commons/statistics/descriptive/ProductTest.java | 3 +++
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
index d57870f..a616db0 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java
@@ -345,16 +345,16 @@ abstract class BaseDoubleStatisticTest<S extends DoubleStatistic & DoubleStatist
final double b = Double.POSITIVE_INFINITY;
final double c = Double.NEGATIVE_INFINITY;
final double[][] nonFinite = {
- {a, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {b, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {c, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {a, a, 0, 0, 0, 0, 0, 0, 0, 0},
- {b, b, 0, 0, 0, 0, 0, 0, 0, 0},
- {c, c, 0, 0, 0, 0, 0, 0, 0, 0},
- {a, b, 0, 0, 0, 0, 0, 0, 0, 0},
- {a, c, 0, 0, 0, 0, 0, 0, 0, 0},
- {b, c, 0, 0, 0, 0, 0, 0, 0, 0},
- {a, b, c, 0, 0, 0, 0, 0, 0, 0},
+ {a, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {b, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {c, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {a, a, 1, 1, 1, 1, 1, 1, 1, 1},
+ {b, b, 1, 1, 1, 1, 1, 1, 1, 1},
+ {c, c, 1, 1, 1, 1, 1, 1, 1, 1},
+ {a, b, 1, 1, 1, 1, 1, 1, 1, 1},
+ {a, c, 1, 1, 1, 1, 1, 1, 1, 1},
+ {b, c, 1, 1, 1, 1, 1, 1, 1, 1},
+ {a, b, c, 1, 1, 1, 1, 1, 1, 1},
};
Stream.of(nonFinite).forEach(values -> {
final double[] sample = values.clone();
diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/ProductTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/ProductTest.java
index 78b6b93..c8ac527 100644
--- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/ProductTest.java
+++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/ProductTest.java
@@ -61,6 +61,9 @@ final class ProductTest extends BaseDoubleStatisticTest<Product> {
@Override
protected Stream<StatisticTestData> streamTestData() {
final Stream.Builder<StatisticTestData> builder = Stream.builder();
+ // inf * 0 = NaN
+ builder.accept(addCase(Double.POSITIVE_INFINITY, 0));
+ builder.accept(addCase(Double.NEGATIVE_INFINITY, 0));
// Python Numpy v1.25.1: numpy.product
builder.accept(addReference(24.0, DoubleTolerances.ulps(1), 1, 2, 3, 4));
builder.accept(addReference(3081078000.0, DoubleTolerances.ulps(1), 5, 9, 13, 14, 10, 12, 11, 15, 19));