commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [2/3] [math] Fixed findbugs warnings.
Date Tue, 03 Nov 2015 12:19:49 GMT
Fixed findbugs warnings.

The warnings were related to compareTo implementations not handling -0.0
or NaN properly (cf
<http://findbugs.sourceforge.net/bugDescriptions.html#CO_COMPARETO_INCORRECT_FLOATING>).

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/be8563a6
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/be8563a6
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/be8563a6

Branch: refs/heads/MATH_3_X
Commit: be8563a6c567cf521090239587e8f7034f69f72a
Parents: 9672399
Author: Luc Maisonobe <luc@apache.org>
Authored: Tue Nov 3 12:21:08 2015 +0100
Committer: Luc Maisonobe <luc@apache.org>
Committed: Tue Nov 3 12:21:08 2015 +0100

----------------------------------------------------------------------
 .../commons/math3/fitting/GaussianCurveFitter.java   | 15 +++++++++------
 .../apache/commons/math3/fitting/GaussianFitter.java | 15 +++++++++------
 .../math3/optimization/fitting/GaussianFitter.java   | 15 +++++++++------
 3 files changed, 27 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/be8563a6/src/main/java/org/apache/commons/math3/fitting/GaussianCurveFitter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/fitting/GaussianCurveFitter.java b/src/main/java/org/apache/commons/math3/fitting/GaussianCurveFitter.java
index 64e0bda..9a4617b 100644
--- a/src/main/java/org/apache/commons/math3/fitting/GaussianCurveFitter.java
+++ b/src/main/java/org/apache/commons/math3/fitting/GaussianCurveFitter.java
@@ -260,22 +260,25 @@ public class GaussianCurveFitter extends AbstractCurveFitter {
                     if (p2 == null) {
                         return 1;
                     }
-                    if (p1.getX() < p2.getX()) {
+                    final int cmpX = Double.compare(p1.getX(), p2.getX());
+                    if (cmpX < 0) {
                         return -1;
                     }
-                    if (p1.getX() > p2.getX()) {
+                    if (cmpX > 0) {
                         return 1;
                     }
-                    if (p1.getY() < p2.getY()) {
+                    final int cmpY = Double.compare(p1.getY(), p2.getY());
+                    if (cmpY < 0) {
                         return -1;
                     }
-                    if (p1.getY() > p2.getY()) {
+                    if (cmpY > 0) {
                         return 1;
                     }
-                    if (p1.getWeight() < p2.getWeight()) {
+                    final int cmpW = Double.compare(p1.getWeight(), p2.getWeight());
+                    if (cmpW < 0) {
                         return -1;
                     }
-                    if (p1.getWeight() > p2.getWeight()) {
+                    if (cmpW > 0) {
                         return 1;
                     }
                     return 0;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/be8563a6/src/main/java/org/apache/commons/math3/fitting/GaussianFitter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/fitting/GaussianFitter.java b/src/main/java/org/apache/commons/math3/fitting/GaussianFitter.java
index 3946540..87c515b 100644
--- a/src/main/java/org/apache/commons/math3/fitting/GaussianFitter.java
+++ b/src/main/java/org/apache/commons/math3/fitting/GaussianFitter.java
@@ -194,22 +194,25 @@ public class GaussianFitter extends CurveFitter<Gaussian.Parametric>
{
                     if (p2 == null) {
                         return 1;
                     }
-                    if (p1.getX() < p2.getX()) {
+                    final int cmpX = Double.compare(p1.getX(), p2.getX());
+                    if (cmpX < 0) {
                         return -1;
                     }
-                    if (p1.getX() > p2.getX()) {
+                    if (cmpX > 0) {
                         return 1;
                     }
-                    if (p1.getY() < p2.getY()) {
+                    final int cmpY = Double.compare(p1.getY(), p2.getY());
+                    if (cmpY < 0) {
                         return -1;
                     }
-                    if (p1.getY() > p2.getY()) {
+                    if (cmpY > 0) {
                         return 1;
                     }
-                    if (p1.getWeight() < p2.getWeight()) {
+                    final int cmpW = Double.compare(p1.getWeight(), p2.getWeight());
+                    if (cmpW < 0) {
                         return -1;
                     }
-                    if (p1.getWeight() > p2.getWeight()) {
+                    if (cmpW > 0) {
                         return 1;
                     }
                     return 0;

http://git-wip-us.apache.org/repos/asf/commons-math/blob/be8563a6/src/main/java/org/apache/commons/math3/optimization/fitting/GaussianFitter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/optimization/fitting/GaussianFitter.java
b/src/main/java/org/apache/commons/math3/optimization/fitting/GaussianFitter.java
index 1676496..b1bfe7d 100644
--- a/src/main/java/org/apache/commons/math3/optimization/fitting/GaussianFitter.java
+++ b/src/main/java/org/apache/commons/math3/optimization/fitting/GaussianFitter.java
@@ -195,22 +195,25 @@ public class GaussianFitter extends CurveFitter<Gaussian.Parametric>
{
                     if (p2 == null) {
                         return 1;
                     }
-                    if (p1.getX() < p2.getX()) {
+                    final int cmpX = Double.compare(p1.getX(), p2.getX());
+                    if (cmpX < 0) {
                         return -1;
                     }
-                    if (p1.getX() > p2.getX()) {
+                    if (cmpX > 0) {
                         return 1;
                     }
-                    if (p1.getY() < p2.getY()) {
+                    final int cmpY = Double.compare(p1.getY(), p2.getY());
+                    if (cmpY < 0) {
                         return -1;
                     }
-                    if (p1.getY() > p2.getY()) {
+                    if (cmpY > 0) {
                         return 1;
                     }
-                    if (p1.getWeight() < p2.getWeight()) {
+                    final int cmpW = Double.compare(p1.getWeight(), p2.getWeight());
+                    if (cmpW < 0) {
                         return -1;
                     }
-                    if (p1.getWeight() > p2.getWeight()) {
+                    if (cmpW > 0) {
                         return 1;
                     }
                     return 0;


Mime
View raw message