MATH-1594: Remove "Serializable".
This commit is contained in:
parent
c67bf75076
commit
151b015ea7
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.math4.legacy.distribution;
|
package org.apache.commons.math4.legacy.distribution;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.apache.commons.statistics.distribution.DiscreteDistribution;
|
import org.apache.commons.statistics.distribution.DiscreteDistribution;
|
||||||
import org.apache.commons.math4.legacy.exception.MathInternalError;
|
import org.apache.commons.math4.legacy.exception.MathInternalError;
|
||||||
import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException;
|
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.
|
* from distribution to distribution.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractIntegerDistribution implements DiscreteDistribution, Serializable {
|
public abstract class AbstractIntegerDistribution
|
||||||
/** Serializable version identifier */
|
implements DiscreteDistribution {
|
||||||
private static final long serialVersionUID = 20160318L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.math4.legacy.distribution;
|
package org.apache.commons.math4.legacy.distribution;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.apache.commons.statistics.distribution.ContinuousDistribution;
|
import org.apache.commons.statistics.distribution.ContinuousDistribution;
|
||||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||||
import org.apache.commons.math4.legacy.analysis.solvers.UnivariateSolverUtils;
|
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
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractRealDistribution
|
public abstract class AbstractRealDistribution
|
||||||
implements ContinuousDistribution,
|
implements ContinuousDistribution {
|
||||||
Serializable {
|
|
||||||
/** Default absolute accuracy for inverse cumulative computation. */
|
/** Default absolute accuracy for inverse cumulative computation. */
|
||||||
public static final double SOLVER_DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
|
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
|
* For a random variable {@code X} whose values are distributed according
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.math4.legacy.distribution;
|
package org.apache.commons.math4.legacy.distribution;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -50,9 +49,7 @@ import org.apache.commons.math4.legacy.core.Pair;
|
||||||
* @param <T> type of the elements in the sample space.
|
* @param <T> type of the elements in the sample space.
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public class EnumeratedDistribution<T> implements Serializable {
|
public class EnumeratedDistribution<T> {
|
||||||
/** Serializable UID. */
|
|
||||||
private static final long serialVersionUID = 20160319L;
|
|
||||||
/**
|
/**
|
||||||
* List of random variable values.
|
* List of random variable values.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -42,8 +42,6 @@ import org.apache.commons.math4.legacy.core.Pair;
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
||||||
/** Serializable UID. */
|
|
||||||
private static final long serialVersionUID = 20130308L;
|
|
||||||
/**
|
/**
|
||||||
* {@link EnumeratedDistribution} instance (using the {@link Integer} wrapper)
|
* {@link EnumeratedDistribution} instance (using the {@link Integer} wrapper)
|
||||||
* used to generate the pmf.
|
* used to generate the pmf.
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import org.apache.commons.statistics.distribution.ContinuousDistribution;
|
import org.apache.commons.statistics.distribution.ContinuousDistribution;
|
||||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||||
|
@ -44,11 +43,7 @@ import org.apache.commons.math4.legacy.core.Pair;
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public class EnumeratedRealDistribution
|
public class EnumeratedRealDistribution
|
||||||
implements ContinuousDistribution,
|
implements ContinuousDistribution {
|
||||||
Serializable {
|
|
||||||
/** Serializable UID. */
|
|
||||||
private static final long serialVersionUID = 20160311L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnumeratedDistribution} (using the {@link Double} wrapper)
|
* {@link EnumeratedDistribution} (using the {@link Double} wrapper)
|
||||||
* used to generate the pmf.
|
* used to generate the pmf.
|
||||||
|
|
|
@ -345,19 +345,6 @@ public final class EmpiricalDistributionTest extends RealDistributionAbstractTes
|
||||||
new EmpiricalDistribution().load(x);
|
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)
|
@Test(expected=NullArgumentException.class)
|
||||||
public void testLoadNullDoubleArray() {
|
public void testLoadNullDoubleArray() {
|
||||||
new EmpiricalDistribution().load((double[]) null);
|
new EmpiricalDistribution().load((double[]) null);
|
||||||
|
|
|
@ -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 -----------
|
//------------------ Getters / Setters for test instance data -----------
|
||||||
/**
|
/**
|
||||||
* @return Returns the cumulativeTestPoints.
|
* @return Returns the cumulativeTestPoints.
|
||||||
|
|
Loading…
Reference in New Issue