MATH-1594: Remove "Serializable".
This commit is contained in:
parent
43ebe7bc45
commit
eac2e8b627
|
@ -17,7 +17,6 @@
|
|||
package org.apache.commons.math4.legacy.analysis.differentiation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.numbers.core.Sum;
|
||||
import org.apache.commons.math4.legacy.core.Field;
|
||||
|
@ -59,11 +58,7 @@ import org.apache.commons.math4.legacy.core.MathArrays;
|
|||
* @see DSCompiler
|
||||
* @since 3.1
|
||||
*/
|
||||
public class DerivativeStructure implements RealFieldElement<DerivativeStructure>, Serializable {
|
||||
|
||||
/** Serializable UID. */
|
||||
private static final long serialVersionUID = 20120730L;
|
||||
|
||||
public class DerivativeStructure implements RealFieldElement<DerivativeStructure> {
|
||||
/** Compiler for the current dimensions. */
|
||||
private transient DSCompiler compiler;
|
||||
|
||||
|
@ -1205,54 +1200,4 @@ public class DerivativeStructure implements RealFieldElement<DerivativeStructure
|
|||
public int hashCode() {
|
||||
return 227 + 229 * getFreeParameters() + 233 * getOrder() + 239 * Arrays.hashCode(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the instance with a data transfer object for serialization.
|
||||
* @return data transfer object that will be serialized
|
||||
*/
|
||||
private Object writeReplace() {
|
||||
return new DataTransferObject(compiler.getFreeParameters(), compiler.getOrder(), data);
|
||||
}
|
||||
|
||||
/** Internal class used only for serialization. */
|
||||
private static class DataTransferObject implements Serializable {
|
||||
|
||||
/** Serializable UID. */
|
||||
private static final long serialVersionUID = 20120730L;
|
||||
|
||||
/** Number of variables.
|
||||
* @serial
|
||||
*/
|
||||
private final int variables;
|
||||
|
||||
/** Derivation order.
|
||||
* @serial
|
||||
*/
|
||||
private final int order;
|
||||
|
||||
/** Partial derivatives.
|
||||
* @serial
|
||||
*/
|
||||
private final double[] data;
|
||||
|
||||
/** Simple constructor.
|
||||
* @param variables number of variables
|
||||
* @param order derivation order
|
||||
* @param data partial derivatives
|
||||
*/
|
||||
DataTransferObject(final int variables, final int order, final double[] data) {
|
||||
this.variables = variables;
|
||||
this.order = order;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/** Replace the deserialized data transfer object with a {@link DerivativeStructure}.
|
||||
* @return replacement {@link DerivativeStructure}
|
||||
*/
|
||||
private Object readResolve() {
|
||||
return new DerivativeStructure(variables, order, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.differentiation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateFunction;
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateMatrixFunction;
|
||||
import org.apache.commons.math4.legacy.analysis.UnivariateVectorFunction;
|
||||
|
@ -69,12 +67,9 @@ import org.apache.commons.math4.core.jdkmath.JdkMath;
|
|||
* @since 3.1
|
||||
*/
|
||||
public class FiniteDifferencesDifferentiator
|
||||
implements UnivariateFunctionDifferentiator, UnivariateVectorFunctionDifferentiator,
|
||||
UnivariateMatrixFunctionDifferentiator, Serializable {
|
||||
|
||||
/** Serializable UID. */
|
||||
private static final long serialVersionUID = 20120917L;
|
||||
|
||||
implements UnivariateFunctionDifferentiator,
|
||||
UnivariateVectorFunctionDifferentiator,
|
||||
UnivariateMatrixFunctionDifferentiator {
|
||||
/** Number of points to use. */
|
||||
private final int nbPoints;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.differentiation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -40,11 +39,7 @@ import org.apache.commons.math4.core.jdkmath.JdkMath;
|
|||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public final class SparseGradient implements RealFieldElement<SparseGradient>, Serializable {
|
||||
|
||||
/** Serializable UID. */
|
||||
private static final long serialVersionUID = 20131025L;
|
||||
|
||||
public final class SparseGradient implements RealFieldElement<SparseGradient> {
|
||||
/** Value of the calculation. */
|
||||
private double value;
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.interpolation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunctionLagrangeForm;
|
||||
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunctionNewtonForm;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
|
@ -37,10 +35,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
|||
* @since 1.2
|
||||
*/
|
||||
public class DividedDifferenceInterpolator
|
||||
implements UnivariateInterpolator, Serializable {
|
||||
/** serializable version identifier. */
|
||||
private static final long serialVersionUID = 107049519551235069L;
|
||||
|
||||
implements UnivariateInterpolator {
|
||||
/**
|
||||
* Compute an interpolating function for the dataset.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.interpolation;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialSplineFunction;
|
||||
|
@ -47,7 +46,7 @@ import org.apache.commons.math4.legacy.core.MathArrays;
|
|||
* @since 2.0
|
||||
*/
|
||||
public class LoessInterpolator
|
||||
implements UnivariateInterpolator, Serializable {
|
||||
implements UnivariateInterpolator {
|
||||
/** Default value of the bandwidth parameter. */
|
||||
public static final double DEFAULT_BANDWIDTH = 0.3;
|
||||
/** Default value of the number of robustness iterations. */
|
||||
|
@ -57,8 +56,6 @@ public class LoessInterpolator
|
|||
* @since 2.1
|
||||
*/
|
||||
public static final double DEFAULT_ACCURACY = 1e-12;
|
||||
/** serializable version identifier. */
|
||||
private static final long serialVersionUID = 5204927143605193821L;
|
||||
/**
|
||||
* The bandwidth parameter: when computing the loess fit at
|
||||
* a particular point, this fraction of source points closest
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.interpolation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.polynomials.PolynomialFunctionLagrangeForm;
|
||||
import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
|
||||
import org.apache.commons.math4.legacy.exception.NonMonotonicSequenceException;
|
||||
|
@ -34,12 +32,7 @@ import org.apache.commons.math4.legacy.exception.NumberIsTooSmallException;
|
|||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public class NevilleInterpolator implements UnivariateInterpolator,
|
||||
Serializable {
|
||||
|
||||
/** serializable version identifier. */
|
||||
static final long serialVersionUID = 3003707660147873733L;
|
||||
|
||||
public class NevilleInterpolator implements UnivariateInterpolator {
|
||||
/**
|
||||
* Computes an interpolating function for the data set.
|
||||
*
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.analysis.polynomials;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.math4.legacy.analysis.ParametricUnivariateFunction;
|
||||
|
@ -34,11 +33,7 @@ import org.apache.commons.math4.core.jdkmath.JdkMath;
|
|||
* is used to evaluate the function.</p>
|
||||
*
|
||||
*/
|
||||
public class PolynomialFunction implements UnivariateDifferentiableFunction, Serializable {
|
||||
/**
|
||||
* Serialization identifier.
|
||||
*/
|
||||
private static final long serialVersionUID = -7726511984200295583L;
|
||||
public class PolynomialFunction implements UnivariateDifferentiableFunction {
|
||||
/**
|
||||
* The coefficients of the polynomial, ordered by degree -- i.e.,
|
||||
* coefficients[0] is the constant term and coefficients[n] is the
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
package org.apache.commons.math4.legacy.stat.descriptive.rank;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -53,7 +50,7 @@ import org.apache.commons.math4.legacy.stat.descriptive.StorelessUnivariateStati
|
|||
* {@link Percentile} should be used.</p>
|
||||
*/
|
||||
public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
||||
implements StorelessUnivariateStatistic, Serializable {
|
||||
implements StorelessUnivariateStatistic {
|
||||
|
||||
/**
|
||||
* The maximum array size used for psquare algorithm.
|
||||
|
@ -66,11 +63,6 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
*/
|
||||
private static final double DEFAULT_QUANTILE_DESIRED = 50d;
|
||||
|
||||
/**
|
||||
* Serial ID.
|
||||
*/
|
||||
private static final long serialVersionUID = 20150412L;
|
||||
|
||||
/**
|
||||
* A decimal formatter for print convenience.
|
||||
*/
|
||||
|
@ -311,12 +303,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
* Markers is an encapsulation of the five markers/buckets as indicated in
|
||||
* the original works.
|
||||
*/
|
||||
private static final class Markers implements PSquareMarkers, Serializable {
|
||||
/**
|
||||
* Serial version id.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final class Markers implements PSquareMarkers {
|
||||
/** Low marker index. */
|
||||
private static final int LOW = 2;
|
||||
|
||||
|
@ -524,25 +511,6 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets previous and next markers after default read is done.
|
||||
*
|
||||
* @param anInputStream the input stream to be deserialized
|
||||
* @throws ClassNotFoundException thrown when a desired class not found
|
||||
* @throws IOException thrown due to any io errors
|
||||
*/
|
||||
private void readObject(ObjectInputStream anInputStream)
|
||||
throws ClassNotFoundException, IOException {
|
||||
// always perform the default de-serialization first
|
||||
anInputStream.defaultReadObject();
|
||||
// Build links
|
||||
for (int i = 1; i < PSQUARE_CONSTANT; i++) {
|
||||
markerArray[i].previous(markerArray[i - 1]).next(markerArray[i + 1]).index(i);
|
||||
}
|
||||
markerArray[0].previous(markerArray[0]).next(markerArray[1]).index(0);
|
||||
markerArray[5].previous(markerArray[4]).next(markerArray[5]).index(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return marker height given index.
|
||||
*
|
||||
|
@ -591,13 +559,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
/**
|
||||
* The class modeling the attributes of the marker of the P-square algorithm.
|
||||
*/
|
||||
private static final class Marker implements Serializable {
|
||||
|
||||
/**
|
||||
* Serial Version ID.
|
||||
*/
|
||||
private static final long serialVersionUID = -3575879478288538431L;
|
||||
|
||||
private static final class Marker {
|
||||
/**
|
||||
* The marker index which is just a serial number for the marker in the
|
||||
* marker array of 5+1.
|
||||
|
@ -832,20 +794,6 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
desiredMarkerIncrement, desiredMarkerPosition, previous.index, next.index});
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Object to deserialize.
|
||||
*
|
||||
* @param anInstream Stream Object data
|
||||
* @throws IOException thrown for IO Errors
|
||||
* @throws ClassNotFoundException thrown for class not being found
|
||||
*/
|
||||
private void readObject(ObjectInputStream anInstream)
|
||||
throws ClassNotFoundException, IOException {
|
||||
anInstream.defaultReadObject();
|
||||
previous=next=this;
|
||||
linear = new LinearInterpolator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy this instance.
|
||||
*
|
||||
|
@ -877,12 +825,7 @@ public class PSquarePercentile extends AbstractStorelessUnivariateStatistic
|
|||
*
|
||||
* @param <E> type for fixed capacity list
|
||||
*/
|
||||
private static class FixedCapacityList<E> extends ArrayList<E> implements Serializable {
|
||||
|
||||
/**
|
||||
* Serialization Version Id.
|
||||
*/
|
||||
private static final long serialVersionUID = 2283952083075725479L;
|
||||
private static class FixedCapacityList<E> extends ArrayList<E> {
|
||||
/**
|
||||
* Capacity of the list.
|
||||
*/
|
||||
|
|
|
@ -1565,15 +1565,6 @@ public class DerivativeStructureTest extends ExtendedFieldElementAbstractTest<De
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
DerivativeStructure a = new DerivativeStructure(3, 2, 0, 1.3);
|
||||
DerivativeStructure b = (DerivativeStructure) TestUtils.serializeAndRecover(a);
|
||||
Assert.assertEquals(a.getFreeParameters(), b.getFreeParameters());
|
||||
Assert.assertEquals(a.getOrder(), b.getOrder());
|
||||
checkEquals(a, b, 1.0e-15);
|
||||
}
|
||||
|
||||
private void checkF0F1(DerivativeStructure ds, double value, double...derivatives) {
|
||||
|
||||
// check dimension
|
||||
|
|
|
@ -47,16 +47,6 @@ public class FiniteDifferencesDifferentiatorTest {
|
|||
new FiniteDifferencesDifferentiator(3, 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
FiniteDifferencesDifferentiator differentiator =
|
||||
new FiniteDifferencesDifferentiator(3, 1.0e-3);
|
||||
FiniteDifferencesDifferentiator recovered =
|
||||
(FiniteDifferencesDifferentiator) TestUtils.serializeAndRecover(differentiator);
|
||||
Assert.assertEquals(differentiator.getNbPoints(), recovered.getNbPoints());
|
||||
Assert.assertEquals(differentiator.getStepSize(), recovered.getStepSize(), 1.0e-15);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstant() {
|
||||
FiniteDifferencesDifferentiator differentiator =
|
||||
|
|
|
@ -1107,13 +1107,6 @@ public class SparseGradientTest extends ExtendedFieldElementAbstractTest<SparseG
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
SparseGradient a = SparseGradient.createVariable(0, 1.3);
|
||||
SparseGradient b = (SparseGradient) TestUtils.serializeAndRecover(a);
|
||||
Assert.assertEquals(a, b);
|
||||
}
|
||||
|
||||
private void checkF0F1(SparseGradient sg, double value, double...derivatives) {
|
||||
|
||||
// check value
|
||||
|
|
|
@ -216,12 +216,6 @@ public final class PolynomialFunctionTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerial() {
|
||||
PolynomialFunction p2 = new PolynomialFunction(new double[] { 3, 2, 1 });
|
||||
Assert.assertEquals(p2, TestUtils.serializeAndRecover(p2));
|
||||
}
|
||||
|
||||
/**
|
||||
* tests the firstDerivative function by comparison
|
||||
*
|
||||
|
|
|
@ -75,33 +75,6 @@ public abstract class StorelessUnivariateStatisticAbstractTest
|
|||
Assert.assertTrue(Double.isNaN(statistic.getResult()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerialization() {
|
||||
|
||||
StorelessUnivariateStatistic statistic =
|
||||
(StorelessUnivariateStatistic) getUnivariateStatistic();
|
||||
|
||||
TestUtils.checkSerializedEquality(statistic);
|
||||
|
||||
statistic.clear();
|
||||
|
||||
for (int i = 0; i < testArray.length; i++) {
|
||||
statistic.increment(testArray[i]);
|
||||
if(i % 5 == 0) {
|
||||
statistic = (StorelessUnivariateStatistic)TestUtils.serializeAndRecover(statistic);
|
||||
}
|
||||
}
|
||||
|
||||
TestUtils.checkSerializedEquality(statistic);
|
||||
|
||||
Assert.assertEquals(expectedValue(), statistic.getResult(), getTolerance());
|
||||
|
||||
statistic.clear();
|
||||
|
||||
checkClearValue(statistic);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsAndHashCode() {
|
||||
StorelessUnivariateStatistic statistic =
|
||||
|
@ -210,13 +183,6 @@ public abstract class StorelessUnivariateStatisticAbstractTest
|
|||
Assert.assertEquals(master, replica);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerial() {
|
||||
StorelessUnivariateStatistic s =
|
||||
(StorelessUnivariateStatistic) getUnivariateStatistic();
|
||||
Assert.assertEquals(s, TestUtils.serializeAndRecover(s));
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that evaluate(double[]) does not alter the internal state.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue