Author: luc
Date: Wed Jul 1 20:31:50 2009
New Revision: 790368
URL: http://svn.apache.org/viewvc?rev=790368&view=rev
Log:
fixed another set of warnings identified by recent findbugs versions
Modified:
commons/proper/math/trunk/findbugs-exclude-filter.xml
commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsIntegrator.java
commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java
commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/MinpackTest.java
Modified: commons/proper/math/trunk/findbugs-exclude-filter.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/findbugs-exclude-filter.xml?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/findbugs-exclude-filter.xml (original)
+++ commons/proper/math/trunk/findbugs-exclude-filter.xml Wed Jul 1 20:31:50 2009
@@ -203,6 +203,11 @@
<Method name="testNewNewtonSolverNull" params="" returns="void" />
<Bug pattern="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS" />
</Match>
+ <Match>
+ <Class name="org.apache.commons.math.stat.regression.OLSMultipleLinearRegressionTest"
/>
+ <Method name="cannotAddNullYSampleData" params="" returns="void" />
+ <Bug pattern="NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS" />
+ </Match>
<!-- IntDoublePair intentionally implements Comparable inconsistently with equals -->
<Match>
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsIntegrator.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsIntegrator.java?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsIntegrator.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/nonstiff/AdamsIntegrator.java
Wed Jul 1 20:31:50 2009
@@ -18,7 +18,6 @@
package org.apache.commons.math.ode.nonstiff;
import org.apache.commons.math.linear.Array2DRowRealMatrix;
-import org.apache.commons.math.linear.RealMatrix;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math.ode.IntegratorException;
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java
(original)
+++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java
Wed Jul 1 20:31:50 2009
@@ -19,6 +19,8 @@
import java.io.Serializable;
+import org.apache.commons.math.util.MathUtils;
+
/**
* <p>
* A StatisticalSummary that aggregates statistics from several data sets or
@@ -242,5 +244,35 @@
aggregateStatistics.addValue(value);
}
}
+
+ /**
+ * Returns true iff <code>object</code> is a
+ * <code>SummaryStatistics</code> instance and all statistics have the
+ * same values as this.
+ * @param object the object to test equality against.
+ * @return true if object equals this
+ */
+ @Override
+ public boolean equals(Object object) {
+ if (object == this) {
+ return true;
+ }
+ if (object instanceof AggregatingSummaryStatistics == false) {
+ return false;
+ }
+ AggregatingSummaryStatistics stat = (AggregatingSummaryStatistics)object;
+ return (super.equals(stat) &&
+ aggregateStatistics.equals(stat.aggregateStatistics));
+ }
+
+ /**
+ * Returns hash code based on values of statistics
+ * @return hash code
+ */
+ @Override
+ public int hashCode() {
+ return 123 + super.hashCode() + aggregateStatistics.hashCode();
+ }
+
}
}
Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
Wed Jul 1 20:31:50 2009
@@ -629,7 +629,7 @@
}
public void addPoint(double px, double py) {
- points.add(new PointModel(px, py));
+ points.add(new PointModel(this, px, py));
}
public int getM() {
@@ -680,45 +680,47 @@
return cy.getEstimate();
}
- private class PointModel extends WeightedMeasurement {
+ private static class PointModel extends WeightedMeasurement {
- public PointModel(double px, double py) {
+ public PointModel(Circle circle, double px, double py) {
super(1.0, 0.0);
this.px = px;
this.py = py;
+ this.circle = circle;
}
@Override
public double getPartial(EstimatedParameter parameter) {
- if (parameter == cx) {
- return getPartialDiX() - getPartialRadiusX();
- } else if (parameter == cy) {
- return getPartialDiY() - getPartialRadiusY();
+ if (parameter == circle.cx) {
+ return getPartialDiX() - circle.getPartialRadiusX();
+ } else if (parameter == circle.cy) {
+ return getPartialDiY() - circle.getPartialRadiusY();
}
return 0;
}
public double getCenterDistance() {
- double dx = px - cx.getEstimate();
- double dy = py - cy.getEstimate();
+ double dx = px - circle.cx.getEstimate();
+ double dy = py - circle.cy.getEstimate();
return Math.sqrt(dx * dx + dy * dy);
}
public double getPartialDiX() {
- return (cx.getEstimate() - px) / getCenterDistance();
+ return (circle.cx.getEstimate() - px) / getCenterDistance();
}
public double getPartialDiY() {
- return (cy.getEstimate() - py) / getCenterDistance();
+ return (circle.cy.getEstimate() - py) / getCenterDistance();
}
@Override
public double getTheoreticalValue() {
- return getCenterDistance() - getRadius();
+ return getCenterDistance() - circle.getRadius();
}
private double px;
private double py;
+ private transient final Circle circle;
private static final long serialVersionUID = 1L;
}
Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
Wed Jul 1 20:31:50 2009
@@ -674,7 +674,7 @@
}
public void addPoint(double px, double py) {
- points.add(new PointModel(px, py));
+ points.add(new PointModel(this, px, py));
}
public int getM() {
@@ -725,45 +725,47 @@
return cy.getEstimate();
}
- private class PointModel extends WeightedMeasurement {
+ private static class PointModel extends WeightedMeasurement {
- public PointModel(double px, double py) {
+ public PointModel(Circle circle, double px, double py) {
super(1.0, 0.0);
this.px = px;
this.py = py;
+ this.circle = circle;
}
@Override
public double getPartial(EstimatedParameter parameter) {
- if (parameter == cx) {
- return getPartialDiX() - getPartialRadiusX();
- } else if (parameter == cy) {
- return getPartialDiY() - getPartialRadiusY();
+ if (parameter == circle.cx) {
+ return getPartialDiX() - circle.getPartialRadiusX();
+ } else if (parameter == circle.cy) {
+ return getPartialDiY() - circle.getPartialRadiusY();
}
return 0;
}
public double getCenterDistance() {
- double dx = px - cx.getEstimate();
- double dy = py - cy.getEstimate();
+ double dx = px - circle.cx.getEstimate();
+ double dy = py - circle.cy.getEstimate();
return Math.sqrt(dx * dx + dy * dy);
}
public double getPartialDiX() {
- return (cx.getEstimate() - px) / getCenterDistance();
+ return (circle.cx.getEstimate() - px) / getCenterDistance();
}
public double getPartialDiY() {
- return (cy.getEstimate() - py) / getCenterDistance();
+ return (circle.cy.getEstimate() - py) / getCenterDistance();
}
@Override
public double getTheoreticalValue() {
- return getCenterDistance() - getRadius();
+ return getCenterDistance() - circle.getRadius();
}
private double px;
private double py;
+ private transient final Circle circle;
private static final long serialVersionUID = 1L;
}
@@ -790,7 +792,7 @@
}
public void addPoint(double x, double y, double w) {
- addMeasurement(new LocalMeasurement(x, y, w));
+ addMeasurement(new LocalMeasurement(this, x, y, w));
}
public double theoreticalValue(double x) {
@@ -807,25 +809,27 @@
}
}
- private class LocalMeasurement extends WeightedMeasurement {
+ private static class LocalMeasurement extends WeightedMeasurement {
private static final long serialVersionUID = 1555043155023729130L;
private final double x;
+ private transient final QuadraticProblem pb;
// constructor
- public LocalMeasurement(double x, double y, double w) {
+ public LocalMeasurement(QuadraticProblem pb, double x, double y, double w) {
super(w, y);
this.x = x;
+ this.pb = pb;
}
@Override
public double getTheoreticalValue() {
- return theoreticalValue(x);
+ return pb.theoreticalValue(x);
}
@Override
public double getPartial(EstimatedParameter parameter) {
- return partial(x, parameter);
+ return pb.partial(x, parameter);
}
}
Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/MinpackTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/MinpackTest.java?rev=790368&r1=790367&r2=790368&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/MinpackTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/estimation/MinpackTest.java
Wed Jul 1 20:31:50 2009
@@ -568,7 +568,7 @@
public WeightedMeasurement[] getMeasurements() {
WeightedMeasurement[] measurements = new WeightedMeasurement[m];
for (int i = 0; i < m; ++i) {
- measurements[i] = new MinpackMeasurement(i);
+ measurements[i] = new MinpackMeasurement(this, i);
}
return measurements;
}
@@ -585,11 +585,12 @@
protected abstract double[] getResiduals();
- private class MinpackMeasurement extends WeightedMeasurement {
+ private static class MinpackMeasurement extends WeightedMeasurement {
- public MinpackMeasurement(int index) {
+ public MinpackMeasurement(MinpackFunction f, int index) {
super(1.0, 0.0);
this.index = index;
+ this.f = f;
}
@Override
@@ -598,7 +599,7 @@
// each time we need only one element, but it is only for test
// purposes and is simpler to check.
// This implementation should NOT be taken as an example, it is ugly!
- return getResiduals()[index];
+ return f.getResiduals()[index];
}
@Override
@@ -607,15 +608,16 @@
// each time we need only one element, but it is only for test
// purposes and is simpler to check.
// This implementation should NOT be taken as an example, it is ugly!
- for (int j = 0; j < n; ++j) {
- if (parameter == parameters[j]) {
- return getJacobian()[index][j];
+ for (int j = 0; j < f.n; ++j) {
+ if (parameter == f.parameters[j]) {
+ return f.getJacobian()[index][j];
}
}
return 0;
}
private int index;
+ private transient final MinpackFunction f;
private static final long serialVersionUID = 1L;
}
|