Author: luc
Date: Sat Jan 12 13:35:10 2008
New Revision: 611489
URL: http://svn.apache.org/viewvc?rev=611489&view=rev
Log:
UnivariateStatistic classes should be Serializable
since they are used as fields of the Serializable DescriptiveStatistics class
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
Modified:
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java?rev=611489&r1=611488&r2=611489&view=diff
==============================================================================
---
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java
(original)
+++
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/UnivariateStatistic.java
Sat Jan 12 13:35:10 2008
@@ -16,6 +16,8 @@
*/
package org.apache.commons.math.stat.descriptive;
+import java.io.Serializable;
+
/**
* Base evaluation interface implemented by all statistics.
* <p>
@@ -25,7 +27,7 @@
*
* @version $Revision$ $Date$
*/
-public interface UnivariateStatistic {
+public interface UnivariateStatistic extends Serializable {
/**
* Returns the result of evaluating the statistic over the input array.
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java?rev=611489&r1=611488&r2=611489&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/DescriptiveStatisticsTest.java
Sat Jan 12 13:35:10 2008
@@ -81,7 +81,9 @@
/**
* A new way to compute the mean
*/
- class deepMean implements UnivariateStatistic {
+ static class deepMean implements UnivariateStatistic {
+ private static final long serialVersionUID = 9108665370122541953L;
+
public double evaluate(double[] values, int begin, int length) {
return 42;
}
@@ -94,8 +96,9 @@
/**
* Test percentile implementation - wraps a Percentile
*/
- class goodPercentile implements UnivariateStatistic {
- Percentile percentile = new Percentile();
+ static class goodPercentile implements UnivariateStatistic {
+ private static final long serialVersionUID = 801005145532790795L;
+ private Percentile percentile = new Percentile();
public void setQuantile(double quantile) {
percentile.setQuantile(quantile);
}
@@ -103,7 +106,7 @@
return percentile.evaluate(values, begin, length);
}
public double evaluate(double[] values) {
- return evaluate(values);
+ return percentile.evaluate(values);
}
}
@@ -111,7 +114,7 @@
* Test percentile subclass - another "new math" impl
* Always returns currently set quantile
*/
- class subPercentile extends Percentile {
+ static class subPercentile extends Percentile {
public double evaluate(double[] values, int begin, int length) {
return getQuantile();
}
@@ -124,13 +127,14 @@
/**
* "Bad" test percentile implementation - no setQuantile
*/
- class badPercentile implements UnivariateStatistic {
- Percentile percentile = new Percentile();
+ static class badPercentile implements UnivariateStatistic {
+ private static final long serialVersionUID = -707437653388052183L;
+ private Percentile percentile = new Percentile();
public double evaluate(double[] values, int begin, int length) {
return percentile.evaluate(values, begin, length);
}
public double evaluate(double[] values) {
- return evaluate(values);
+ return percentile.evaluate(values);
}
}
}
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java?rev=611489&r1=611488&r2=611489&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/MixedListUnivariateImplTest.java
Sat Jan 12 13:35:10 2008
@@ -52,18 +52,9 @@
super(name);
transformers = new TransformerMap();
- transformers.putTransformer(Foo.class, new NumberTransformer() {
- public double transform(Object o) {
- return Double.parseDouble(((Foo) o).heresFoo());
- }
- });
-
- transformers.putTransformer(Bar.class, new NumberTransformer() {
- public double transform(Object o) {
- return Double.parseDouble(((Bar) o).heresBar());
- }
+ transformers.putTransformer(Foo.class, new FooTransformer());
- });
+ transformers.putTransformer(Bar.class, new BarTransformer());
}
@@ -196,9 +187,24 @@
}
}
+ public static final class FooTransformer implements NumberTransformer {
+ private static final long serialVersionUID = -4252248129291326127L;
+ public double transform(Object o) {
+ return Double.parseDouble(((Foo) o).heresFoo());
+ }
+ }
+
public static final class Bar {
public String heresBar() {
return "12.0";
}
}
+
+ public static final class BarTransformer implements NumberTransformer {
+ private static final long serialVersionUID = -1768345377764262043L;
+ public double transform(Object o) {
+ return Double.parseDouble(((Bar) o).heresBar());
+ }
+ }
+
}
Modified:
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java?rev=611489&r1=611488&r2=611489&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
(original)
+++
commons/proper/math/trunk/src/test/org/apache/commons/math/stat/descriptive/SummaryStatisticsTest.java
Sat Jan 12 13:35:10 2008
@@ -75,7 +75,8 @@
* Bogus mean implementation to test setter injection.
* Returns the sum instead of the mean.
*/
- class sumMean implements StorelessUnivariateStatistic {
+ static class sumMean implements StorelessUnivariateStatistic {
+ private static final long serialVersionUID = 6492471391340853423L;
private double sum = 0;
private long n = 0;
public double evaluate(double[] values, int begin, int length) {