From 151b015ea733543fa8b06873d6bece3ed9d30052 Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Thu, 10 Jun 2021 17:41:48 +0200 Subject: [PATCH] MATH-1594: Remove "Serializable". --- .../AbstractIntegerDistribution.java | 8 ++------ .../AbstractRealDistribution.java | 7 +------ .../distribution/EnumeratedDistribution.java | 5 +---- .../EnumeratedIntegerDistribution.java | 2 -- .../EnumeratedRealDistribution.java | 7 +------ .../EmpiricalDistributionTest.java | 13 ------------ .../RealDistributionAbstractTest.java | 20 ------------------- 7 files changed, 5 insertions(+), 57 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistribution.java index 78e81c65e..f4a0402b5 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistribution.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractIntegerDistribution.java @@ -16,8 +16,6 @@ */ package org.apache.commons.math4.legacy.distribution; -import java.io.Serializable; - import org.apache.commons.statistics.distribution.DiscreteDistribution; import org.apache.commons.math4.legacy.exception.MathInternalError; import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException; @@ -35,10 +33,8 @@ import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath; * from distribution to distribution. * */ -public abstract class AbstractIntegerDistribution implements DiscreteDistribution, Serializable { - /** Serializable version identifier */ - private static final long serialVersionUID = 20160318L; - +public abstract class AbstractIntegerDistribution + implements DiscreteDistribution { /** * {@inheritDoc} * diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java index 23cb7be08..afedfae1e 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/AbstractRealDistribution.java @@ -16,8 +16,6 @@ */ package org.apache.commons.math4.legacy.distribution; -import java.io.Serializable; - import org.apache.commons.statistics.distribution.ContinuousDistribution; import org.apache.commons.math4.legacy.analysis.UnivariateFunction; import org.apache.commons.math4.legacy.analysis.solvers.UnivariateSolverUtils; @@ -47,12 +45,9 @@ import org.apache.commons.math4.legacy.core.jdkmath.AccurateMath; * @since 3.0 */ public abstract class AbstractRealDistribution - implements ContinuousDistribution, - Serializable { + implements ContinuousDistribution { /** Default absolute accuracy for inverse cumulative computation. */ public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6; - /** Serializable version identifier */ - private static final long serialVersionUID = 20160311L; /** * For a random variable {@code X} whose values are distributed according diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java index d7dc9d883..45bdade54 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedDistribution.java @@ -16,7 +16,6 @@ */ package org.apache.commons.math4.legacy.distribution; -import java.io.Serializable; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; @@ -50,9 +49,7 @@ import org.apache.commons.math4.legacy.core.Pair; * @param type of the elements in the sample space. * @since 3.2 */ -public class EnumeratedDistribution implements Serializable { - /** Serializable UID. */ - private static final long serialVersionUID = 20160319L; +public class EnumeratedDistribution { /** * List of random variable values. */ diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java index 52e0534bb..38a8f64c6 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedIntegerDistribution.java @@ -42,8 +42,6 @@ import org.apache.commons.math4.legacy.core.Pair; * @since 3.2 */ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution { - /** Serializable UID. */ - private static final long serialVersionUID = 20130308L; /** * {@link EnumeratedDistribution} instance (using the {@link Integer} wrapper) * used to generate the pmf. diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java index bf7126112..f90789477 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/distribution/EnumeratedRealDistribution.java @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.io.Serializable; import org.apache.commons.statistics.distribution.ContinuousDistribution; import org.apache.commons.math4.legacy.exception.DimensionMismatchException; @@ -44,11 +43,7 @@ import org.apache.commons.math4.legacy.core.Pair; * @since 3.2 */ public class EnumeratedRealDistribution - implements ContinuousDistribution, - Serializable { - /** Serializable UID. */ - private static final long serialVersionUID = 20160311L; - + implements ContinuousDistribution { /** * {@link EnumeratedDistribution} (using the {@link Double} wrapper) * used to generate the pmf. diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java index f64217fa3..5ebccc96d 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/EmpiricalDistributionTest.java @@ -345,19 +345,6 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes new EmpiricalDistribution().load(x); } - @Test - public void testSerialization() { - // Empty - EmpiricalDistribution dist = new EmpiricalDistribution(); - EmpiricalDistribution dist2 = (EmpiricalDistribution) TestUtils.serializeAndRecover(dist); - verifySame(dist, dist2); - - // Loaded - empiricalDistribution2.load(dataArray); - dist2 = (EmpiricalDistribution) TestUtils.serializeAndRecover(empiricalDistribution2); - verifySame(empiricalDistribution2, dist2); - } - @Test(expected=NullArgumentException.class) public void testLoadNullDoubleArray() { new EmpiricalDistribution().load((double[]) null); diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java index 13e122db5..61e2188f6 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/distribution/RealDistributionAbstractTest.java @@ -379,26 +379,6 @@ public abstract class RealDistributionAbstractTest { } } - @Test - public void testDistributionClone() - throws IOException, - ClassNotFoundException { - // Construct a distribution and initialize its internal random - // generator, using a fixed seed for deterministic results. - final long seed = 123; - RandomSource source = RandomSource.WELL_512_A; - ContinuousDistribution.Sampler origSampler = distribution.createSampler(RandomSource.create(source, seed)); - - // Clone the distribution. - final ContinuousDistribution cloned = deepClone(); - ContinuousDistribution.Sampler clonedSampler = cloned.createSampler(RandomSource.create(source, seed)); - - // Make sure they still produce the same samples. - Assert.assertEquals(origSampler.sample(), - clonedSampler.sample(), - 0d); - } - //------------------ Getters / Setters for test instance data ----------- /** * @return Returns the cumulativeTestPoints.