You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2015/11/03 12:06:46 UTC

[1/6] [math] Updated parent pom and plugins versions to latest available.

Repository: commons-math
Updated Branches:
  refs/heads/MATH_3_X ee7b3a582 -> b6c2d697a


Updated parent pom and plugins versions to latest available.

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

Branch: refs/heads/MATH_3_X
Commit: da77465fc150c5a3fe6c4d5eb86b80676df41c9d
Parents: ee7b3a5
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 11:16:49 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 11:16:49 2015 +0100

----------------------------------------------------------------------
 pom.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/da77465f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 194d7a4..9a14a1b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
   <parent>
     <groupId>org.apache.commons</groupId>
     <artifactId>commons-parent</artifactId>
-    <version>37</version>
+    <version>39</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.commons</groupId>
@@ -390,13 +390,13 @@
     <commons.encoding>UTF-8</commons.encoding>
     <maven.compiler.source>1.5</maven.compiler.source>
     <maven.compiler.target>1.5</maven.compiler.target>
-    <math.pmd.version>2.7.1</math.pmd.version>
-    <math.findbugs.version>3.0.1</math.findbugs.version>
-    <math.checkstyle.version>2.15</math.checkstyle.version>
-    <math.clirr.version>2.6.1</math.clirr.version>
+    <math.pmd.version>3.5</math.pmd.version>
+    <math.findbugs.version>3.0.2</math.findbugs.version>
+    <math.checkstyle.version>2.17</math.checkstyle.version>
+    <math.clirr.version>2.7</math.clirr.version>
 
     <!-- Temporary fix to support Java 8 -->
-    <commons.jacoco.version>0.7.4.201502262128</commons.jacoco.version>
+    <commons.jacoco.version>0.7.5.201505241946</commons.jacoco.version>
     <commons.jacoco.classRatio>0.96</commons.jacoco.classRatio>
     <commons.jacoco.instructionRatio>0.8</commons.jacoco.instructionRatio>
     <commons.jacoco.methodRatio>0.8</commons.jacoco.methodRatio>


[6/6] [math] Roll back clirr plugin version to 2.6.1 as 2.7 triggered an exception.

Posted by lu...@apache.org.
Roll back clirr plugin version to 2.6.1 as 2.7 triggered an exception.

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

Branch: refs/heads/MATH_3_X
Commit: b6c2d697abc48bc99a94577841a1ea5cbafa9dea
Parents: 04454fc
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 12:06:26 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 12:06:26 2015 +0100

----------------------------------------------------------------------
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/b6c2d697/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9a14a1b..32f8a09 100644
--- a/pom.xml
+++ b/pom.xml
@@ -393,7 +393,7 @@
     <math.pmd.version>3.5</math.pmd.version>
     <math.findbugs.version>3.0.2</math.findbugs.version>
     <math.checkstyle.version>2.17</math.checkstyle.version>
-    <math.clirr.version>2.7</math.clirr.version>
+    <math.clirr.version>2.6.1</math.clirr.version>
 
     <!-- Temporary fix to support Java 8 -->
     <commons.jacoco.version>0.7.5.201505241946</commons.jacoco.version>


[2/6] [math] Removed useless object.

Posted by lu...@apache.org.
Removed useless object.

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

Branch: refs/heads/MATH_3_X
Commit: 8c2aa686b920b2ff1493f41bfcd118998c4c7a0e
Parents: da77465
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 11:17:34 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 11:17:34 2015 +0100

----------------------------------------------------------------------
 src/main/java/org/apache/commons/math3/dfp/DfpMath.java | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/8c2aa686/src/main/java/org/apache/commons/math3/dfp/DfpMath.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/dfp/DfpMath.java b/src/main/java/org/apache/commons/math3/dfp/DfpMath.java
index 3b19cb6..31ef88f 100644
--- a/src/main/java/org/apache/commons/math3/dfp/DfpMath.java
+++ b/src/main/java/org/apache/commons/math3/dfp/DfpMath.java
@@ -754,11 +754,6 @@ public class DfpMath {
 
         Dfp y;
         if (x.lessThan(pi.divide(4))) {
-            Dfp c[] = new Dfp[2];
-            c[0] = x;
-            c[1] = zero;
-
-            //y = sinInternal(c);
             y = sinInternal(split(x));
         } else {
             final Dfp c[] = new Dfp[2];


Re: [5/6] [math] Fixed findbugs warning.

Posted by luc <lu...@spaceroots.org>.
Le 2015-11-04 14:34, Gilles a écrit :
> On Wed, 04 Nov 2015 14:20:55 +0100, Gilles wrote:
>>>> [...]
>>>> But it was perhaps a bad design choice to have "PairNeuronDouble" 
>>>> implement
>>>> "Comparable".
>>>> I propose to use an explicit "Comparator" in order to fix the 
>>>> problem.
>>> 
>>> Good idea!
>>> I have done it and pushed it on both master and MATH_3_X branches.
>> 
>> I was working on that! :-(
> 
> And I've just overwritten (sorry!) your changes in "master" with
> something that would seem to be a little bit more efficient.
> 
> I've _not_ done so in the MATH_3_X branch.
> Will you do the "back-porting"?

Fine, I've done it.
I have also removed the geValue method since it was not needed anymore.

best regards,
Luc

> 
> Gilles
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Wed, 04 Nov 2015 14:20:55 +0100, Gilles wrote:
>>> [...]
>>> But it was perhaps a bad design choice to have "PairNeuronDouble" 
>>> implement
>>> "Comparable".
>>> I propose to use an explicit "Comparator" in order to fix the 
>>> problem.
>>
>> Good idea!
>> I have done it and pushed it on both master and MATH_3_X branches.
>
> I was working on that! :-(

And I've just overwritten (sorry!) your changes in "master" with
something that would seem to be a little bit more efficient.

I've _not_ done so in the MATH_3_X branch.
Will you do the "back-porting"?

Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Wed, 04 Nov 2015 14:14:53 +0100, luc wrote:
> Le 2015-11-04 13:44, Gilles a écrit :
>> On Tue, 03 Nov 2015 18:07:50 +0100, Luc Maisonobe wrote:
>>> Le 03/11/2015 15:33, Gilles a écrit :
>>>> On Tue, 03 Nov 2015 11:06:50 -0000, luc@apache.org wrote:
>>>>> Fixed findbugs warning.
>>>>> When defining compareTo, we should also define equals and 
>>>>> hashcode.
>>>>>
>>>>> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
>>>>> Commit:
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/commons-math/commit/04454fc0
>>>>> Tree: 
>>>>> http://git-wip-us.apache.org/repos/asf/commons-math/tree/04454fc0
>>>>> Diff: 
>>>>> http://git-wip-us.apache.org/repos/asf/commons-math/diff/04454fc0
>>>>> Branch: refs/heads/MATH_3_X
>>>>> Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
>>>>> Parents: b72d446
>>>>> Author: Luc Maisonobe <lu...@apache.org>
>>>>> Authored: Tue Nov 3 11:23:46 2015 +0100
>>>>> Committer: Luc Maisonobe <lu...@apache.org>
>>>>> Committed: Tue Nov 3 11:23:46 2015 +0100
>>>>>
>>>>>
>>>>> 
>>>>> ----------------------------------------------------------------------
>>>>>  .../commons/math3/ml/neuralnet/MapUtils.java    | 24
>>>>> +++++++++++++++++---
>>>>>  1 file changed, 21 insertions(+), 3 deletions(-)
>>>>>
>>>>> 
>>>>> ----------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> 
>>>>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>>>
>>>>>
>>>>> 
>>>>> ----------------------------------------------------------------------
>>>>> diff --git
>>>>> 
>>>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>>> 
>>>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>>> index 83036c2..6ef9327 100644
>>>>> --- 
>>>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>>> +++ 
>>>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>>> @@ -17,14 +17,15 @@
>>>>> package org.apache.commons.math3.ml.neuralnet;
>>>>> -import java.util.HashMap;
>>>>> +import java.util.ArrayList;
>>>>>  import java.util.Collection;
>>>>>  import java.util.Collections;
>>>>> +import java.util.HashMap;
>>>>>  import java.util.List;
>>>>> -import java.util.ArrayList;
>>>>> +
>>>>> +import org.apache.commons.math3.exception.NoDataException;
>>>>>  import org.apache.commons.math3.ml.distance.DistanceMeasure;
>>>>>  import 
>>>>> org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
>>>>> -import org.apache.commons.math3.exception.NoDataException;
>>>>>  import org.apache.commons.math3.util.Pair;
>>>>> /**
>>>>> @@ -320,5 +321,22 @@ public class MapUtils {
>>>>>          public int compareTo(PairNeuronDouble other) {
>>>>>              return Double.compare(this.value, other.value);
>>>>>          }
>>>>> +
>>>>> +        /** {@inheritDoc} */
>>>>> +        @Override
>>>>> +        public boolean equals(Object other) {
>>>>> +            if (!(other instanceof PairNeuronDouble)) {
>>>>> +                return false;
>>>>> +            }
>>>>> +            return Double.doubleToRawLongBits(value) ==
>>>>> +                   
>>>>> Double.doubleToRawLongBits(((PairNeuronDouble)
>>>>> other).value);
>>>>> +        }
>>>>> +
>>>>> +        /** {@inheritDoc} */
>>>>> +        @Override
>>>>> +        public int hashCode() {
>>>>> +            return Double.valueOf(value).hashCode();
>>>>> +        }
>>>>> +
>>>>>      }
>>>>>  }
>>>> I think that in general, it is not correct to assume pair equality
>>>> by only taking "value" into account.
>>>> I also think that the default implementation provided the correct
>>>> semantics (for the sole usage of sorting).
>>> Sure, but as the compareTo method did only use value, the equals 
>>> method
>>> should be consistent with it. Otherwise, you could have compareTo 
>>> return
>>> 0 when equals does not return true for example.
>> It is plain wrong (in general) to consider two objects equal just 
>> because they
>> have the same rank according to an ordering based on part of their 
>> properties.
>> [It's akin to saying e.g. that two books are the same, because they 
>> happen
>> to have the same price tag.]
>> But it was perhaps a bad design choice to have "PairNeuronDouble" 
>> implement
>> "Comparable".
>> I propose to use an explicit "Comparator" in order to fix the 
>> problem.
>
> Good idea!
> I have done it and pushed it on both master and MATH_3_X branches.

I was working on that! :-(

Gilles

> best regards,
> Luc



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by luc <lu...@spaceroots.org>.
Le 2015-11-04 13:44, Gilles a écrit :
> On Tue, 03 Nov 2015 18:07:50 +0100, Luc Maisonobe wrote:
>> Le 03/11/2015 15:33, Gilles a écrit :
>>> On Tue, 03 Nov 2015 11:06:50 -0000, luc@apache.org wrote:
>>>> Fixed findbugs warning.
>>>> 
>>>> When defining compareTo, we should also define equals and hashcode.
>>>> 
>>>> 
>>>> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
>>>> Commit:
>>>> http://git-wip-us.apache.org/repos/asf/commons-math/commit/04454fc0
>>>> Tree: 
>>>> http://git-wip-us.apache.org/repos/asf/commons-math/tree/04454fc0
>>>> Diff: 
>>>> http://git-wip-us.apache.org/repos/asf/commons-math/diff/04454fc0
>>>> 
>>>> Branch: refs/heads/MATH_3_X
>>>> Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
>>>> Parents: b72d446
>>>> Author: Luc Maisonobe <lu...@apache.org>
>>>> Authored: Tue Nov 3 11:23:46 2015 +0100
>>>> Committer: Luc Maisonobe <lu...@apache.org>
>>>> Committed: Tue Nov 3 11:23:46 2015 +0100
>>>> 
>>>> 
>>>> 
>>>> ----------------------------------------------------------------------
>>>>  .../commons/math3/ml/neuralnet/MapUtils.java    | 24
>>>> +++++++++++++++++---
>>>>  1 file changed, 21 insertions(+), 3 deletions(-)
>>>> 
>>>> 
>>>> ----------------------------------------------------------------------
>>>> 
>>>> 
>>>> 
>>>> 
>>>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>> 
>>>> 
>>>> 
>>>> ----------------------------------------------------------------------
>>>> diff --git
>>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>> index 83036c2..6ef9327 100644
>>>> --- 
>>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>> +++ 
>>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>> @@ -17,14 +17,15 @@
>>>> 
>>>>  package org.apache.commons.math3.ml.neuralnet;
>>>> 
>>>> -import java.util.HashMap;
>>>> +import java.util.ArrayList;
>>>>  import java.util.Collection;
>>>>  import java.util.Collections;
>>>> +import java.util.HashMap;
>>>>  import java.util.List;
>>>> -import java.util.ArrayList;
>>>> +
>>>> +import org.apache.commons.math3.exception.NoDataException;
>>>>  import org.apache.commons.math3.ml.distance.DistanceMeasure;
>>>>  import 
>>>> org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
>>>> -import org.apache.commons.math3.exception.NoDataException;
>>>>  import org.apache.commons.math3.util.Pair;
>>>> 
>>>>  /**
>>>> @@ -320,5 +321,22 @@ public class MapUtils {
>>>>          public int compareTo(PairNeuronDouble other) {
>>>>              return Double.compare(this.value, other.value);
>>>>          }
>>>> +
>>>> +        /** {@inheritDoc} */
>>>> +        @Override
>>>> +        public boolean equals(Object other) {
>>>> +            if (!(other instanceof PairNeuronDouble)) {
>>>> +                return false;
>>>> +            }
>>>> +            return Double.doubleToRawLongBits(value) ==
>>>> +                   Double.doubleToRawLongBits(((PairNeuronDouble)
>>>> other).value);
>>>> +        }
>>>> +
>>>> +        /** {@inheritDoc} */
>>>> +        @Override
>>>> +        public int hashCode() {
>>>> +            return Double.valueOf(value).hashCode();
>>>> +        }
>>>> +
>>>>      }
>>>>  }
>>> 
>>> I think that in general, it is not correct to assume pair equality
>>> by only taking "value" into account.
>>> I also think that the default implementation provided the correct
>>> semantics (for the sole usage of sorting).
>> 
>> Sure, but as the compareTo method did only use value, the equals 
>> method
>> should be consistent with it. Otherwise, you could have compareTo 
>> return
>> 0 when equals does not return true for example.
> 
> It is plain wrong (in general) to consider two objects equal just 
> because they
> have the same rank according to an ordering based on part of their 
> properties.
> [It's akin to saying e.g. that two books are the same, because they 
> happen
> to have the same price tag.]
> 
> But it was perhaps a bad design choice to have "PairNeuronDouble" 
> implement
> "Comparable".
> I propose to use an explicit "Comparator" in order to fix the problem.

Good idea!
I have done it and pushed it on both master and MATH_3_X branches.

best regards,
Luc

> 
> Best,
> Gilles
> 
> 
>> best regards,
>> Luc
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Tue, 03 Nov 2015 18:07:50 +0100, Luc Maisonobe wrote:
> Le 03/11/2015 15:33, Gilles a écrit :
>> On Tue, 03 Nov 2015 11:06:50 -0000, luc@apache.org wrote:
>>> Fixed findbugs warning.
>>>
>>> When defining compareTo, we should also define equals and hashcode.
>>>
>>>
>>> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
>>> Commit:
>>> http://git-wip-us.apache.org/repos/asf/commons-math/commit/04454fc0
>>> Tree: 
>>> http://git-wip-us.apache.org/repos/asf/commons-math/tree/04454fc0
>>> Diff: 
>>> http://git-wip-us.apache.org/repos/asf/commons-math/diff/04454fc0
>>>
>>> Branch: refs/heads/MATH_3_X
>>> Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
>>> Parents: b72d446
>>> Author: Luc Maisonobe <lu...@apache.org>
>>> Authored: Tue Nov 3 11:23:46 2015 +0100
>>> Committer: Luc Maisonobe <lu...@apache.org>
>>> Committed: Tue Nov 3 11:23:46 2015 +0100
>>>
>>>
>>> 
>>> ----------------------------------------------------------------------
>>>  .../commons/math3/ml/neuralnet/MapUtils.java    | 24
>>> +++++++++++++++++---
>>>  1 file changed, 21 insertions(+), 3 deletions(-)
>>>
>>> 
>>> ----------------------------------------------------------------------
>>>
>>>
>>>
>>> 
>>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>>
>>>
>>> 
>>> ----------------------------------------------------------------------
>>> diff --git
>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>> index 83036c2..6ef9327 100644
>>> --- 
>>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>> +++ 
>>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>> @@ -17,14 +17,15 @@
>>>
>>>  package org.apache.commons.math3.ml.neuralnet;
>>>
>>> -import java.util.HashMap;
>>> +import java.util.ArrayList;
>>>  import java.util.Collection;
>>>  import java.util.Collections;
>>> +import java.util.HashMap;
>>>  import java.util.List;
>>> -import java.util.ArrayList;
>>> +
>>> +import org.apache.commons.math3.exception.NoDataException;
>>>  import org.apache.commons.math3.ml.distance.DistanceMeasure;
>>>  import 
>>> org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
>>> -import org.apache.commons.math3.exception.NoDataException;
>>>  import org.apache.commons.math3.util.Pair;
>>>
>>>  /**
>>> @@ -320,5 +321,22 @@ public class MapUtils {
>>>          public int compareTo(PairNeuronDouble other) {
>>>              return Double.compare(this.value, other.value);
>>>          }
>>> +
>>> +        /** {@inheritDoc} */
>>> +        @Override
>>> +        public boolean equals(Object other) {
>>> +            if (!(other instanceof PairNeuronDouble)) {
>>> +                return false;
>>> +            }
>>> +            return Double.doubleToRawLongBits(value) ==
>>> +                   Double.doubleToRawLongBits(((PairNeuronDouble)
>>> other).value);
>>> +        }
>>> +
>>> +        /** {@inheritDoc} */
>>> +        @Override
>>> +        public int hashCode() {
>>> +            return Double.valueOf(value).hashCode();
>>> +        }
>>> +
>>>      }
>>>  }
>>
>> I think that in general, it is not correct to assume pair equality
>> by only taking "value" into account.
>> I also think that the default implementation provided the correct
>> semantics (for the sole usage of sorting).
>
> Sure, but as the compareTo method did only use value, the equals 
> method
> should be consistent with it. Otherwise, you could have compareTo 
> return
> 0 when equals does not return true for example.

It is plain wrong (in general) to consider two objects equal just 
because they
have the same rank according to an ordering based on part of their 
properties.
[It's akin to saying e.g. that two books are the same, because they 
happen
to have the same price tag.]

But it was perhaps a bad design choice to have "PairNeuronDouble" 
implement
"Comparable".
I propose to use an explicit "Comparator" in order to fix the problem.

Best,
Gilles


> best regards,
> Luc


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by Luc Maisonobe <lu...@spaceroots.org>.
Le 03/11/2015 15:33, Gilles a écrit :
> On Tue, 03 Nov 2015 11:06:50 -0000, luc@apache.org wrote:
>> Fixed findbugs warning.
>>
>> When defining compareTo, we should also define equals and hashcode.
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/commons-math/commit/04454fc0
>> Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/04454fc0
>> Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/04454fc0
>>
>> Branch: refs/heads/MATH_3_X
>> Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
>> Parents: b72d446
>> Author: Luc Maisonobe <lu...@apache.org>
>> Authored: Tue Nov 3 11:23:46 2015 +0100
>> Committer: Luc Maisonobe <lu...@apache.org>
>> Committed: Tue Nov 3 11:23:46 2015 +0100
>>
>>
>> ----------------------------------------------------------------------
>>  .../commons/math3/ml/neuralnet/MapUtils.java    | 24
>> +++++++++++++++++---
>>  1 file changed, 21 insertions(+), 3 deletions(-)
>>
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>>
>>
>> ----------------------------------------------------------------------
>> diff --git
>> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>> index 83036c2..6ef9327 100644
>> --- a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>> +++ b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
>> @@ -17,14 +17,15 @@
>>
>>  package org.apache.commons.math3.ml.neuralnet;
>>
>> -import java.util.HashMap;
>> +import java.util.ArrayList;
>>  import java.util.Collection;
>>  import java.util.Collections;
>> +import java.util.HashMap;
>>  import java.util.List;
>> -import java.util.ArrayList;
>> +
>> +import org.apache.commons.math3.exception.NoDataException;
>>  import org.apache.commons.math3.ml.distance.DistanceMeasure;
>>  import org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
>> -import org.apache.commons.math3.exception.NoDataException;
>>  import org.apache.commons.math3.util.Pair;
>>
>>  /**
>> @@ -320,5 +321,22 @@ public class MapUtils {
>>          public int compareTo(PairNeuronDouble other) {
>>              return Double.compare(this.value, other.value);
>>          }
>> +
>> +        /** {@inheritDoc} */
>> +        @Override
>> +        public boolean equals(Object other) {
>> +            if (!(other instanceof PairNeuronDouble)) {
>> +                return false;
>> +            }
>> +            return Double.doubleToRawLongBits(value) ==
>> +                   Double.doubleToRawLongBits(((PairNeuronDouble)
>> other).value);
>> +        }
>> +
>> +        /** {@inheritDoc} */
>> +        @Override
>> +        public int hashCode() {
>> +            return Double.valueOf(value).hashCode();
>> +        }
>> +
>>      }
>>  }
> 
> I think that in general, it is not correct to assume pair equality
> by only taking "value" into account.
> I also think that the default implementation provided the correct
> semantics (for the sole usage of sorting).

Sure, but as the compareTo method did only use value, the equals method
should be consistent with it. Otherwise, you could have compareTo return
0 when equals does not return true for example.

best regards,
Luc

> 
> 
> Regards,
> Gilles
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: [5/6] [math] Fixed findbugs warning.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Tue, 03 Nov 2015 11:06:50 -0000, luc@apache.org wrote:
> Fixed findbugs warning.
>
> When defining compareTo, we should also define equals and hashcode.
>
>
> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
> Commit: 
> http://git-wip-us.apache.org/repos/asf/commons-math/commit/04454fc0
> Tree: 
> http://git-wip-us.apache.org/repos/asf/commons-math/tree/04454fc0
> Diff: 
> http://git-wip-us.apache.org/repos/asf/commons-math/diff/04454fc0
>
> Branch: refs/heads/MATH_3_X
> Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
> Parents: b72d446
> Author: Luc Maisonobe <lu...@apache.org>
> Authored: Tue Nov 3 11:23:46 2015 +0100
> Committer: Luc Maisonobe <lu...@apache.org>
> Committed: Tue Nov 3 11:23:46 2015 +0100
>
> 
> ----------------------------------------------------------------------
>  .../commons/math3/ml/neuralnet/MapUtils.java    | 24 
> +++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> ----------------------------------------------------------------------
>
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
> 
> ----------------------------------------------------------------------
> diff --git
> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
> index 83036c2..6ef9327 100644
> --- 
> a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
> +++ 
> b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
> @@ -17,14 +17,15 @@
>
>  package org.apache.commons.math3.ml.neuralnet;
>
> -import java.util.HashMap;
> +import java.util.ArrayList;
>  import java.util.Collection;
>  import java.util.Collections;
> +import java.util.HashMap;
>  import java.util.List;
> -import java.util.ArrayList;
> +
> +import org.apache.commons.math3.exception.NoDataException;
>  import org.apache.commons.math3.ml.distance.DistanceMeasure;
>  import 
> org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
> -import org.apache.commons.math3.exception.NoDataException;
>  import org.apache.commons.math3.util.Pair;
>
>  /**
> @@ -320,5 +321,22 @@ public class MapUtils {
>          public int compareTo(PairNeuronDouble other) {
>              return Double.compare(this.value, other.value);
>          }
> +
> +        /** {@inheritDoc} */
> +        @Override
> +        public boolean equals(Object other) {
> +            if (!(other instanceof PairNeuronDouble)) {
> +                return false;
> +            }
> +            return Double.doubleToRawLongBits(value) ==
> +                   Double.doubleToRawLongBits(((PairNeuronDouble)
> other).value);
> +        }
> +
> +        /** {@inheritDoc} */
> +        @Override
> +        public int hashCode() {
> +            return Double.valueOf(value).hashCode();
> +        }
> +
>      }
>  }

I think that in general, it is not correct to assume pair equality
by only taking "value" into account.
I also think that the default implementation provided the correct
semantics (for the sole usage of sorting).


Regards,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[5/6] [math] Fixed findbugs warning.

Posted by lu...@apache.org.
Fixed findbugs warning.

When defining compareTo, we should also define equals and hashcode.


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

Branch: refs/heads/MATH_3_X
Commit: 04454fc0096d5d388e10c5b13024b2a947a4e923
Parents: b72d446
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 11:23:46 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 11:23:46 2015 +0100

----------------------------------------------------------------------
 .../commons/math3/ml/neuralnet/MapUtils.java    | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/04454fc0/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
index 83036c2..6ef9327 100644
--- a/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
+++ b/src/main/java/org/apache/commons/math3/ml/neuralnet/MapUtils.java
@@ -17,14 +17,15 @@
 
 package org.apache.commons.math3.ml.neuralnet;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
-import java.util.ArrayList;
+
+import org.apache.commons.math3.exception.NoDataException;
 import org.apache.commons.math3.ml.distance.DistanceMeasure;
 import org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D;
-import org.apache.commons.math3.exception.NoDataException;
 import org.apache.commons.math3.util.Pair;
 
 /**
@@ -320,5 +321,22 @@ public class MapUtils {
         public int compareTo(PairNeuronDouble other) {
             return Double.compare(this.value, other.value);
         }
+
+        /** {@inheritDoc} */
+        @Override
+        public boolean equals(Object other) {
+            if (!(other instanceof PairNeuronDouble)) {
+                return false;
+            }
+            return Double.doubleToRawLongBits(value) ==
+                   Double.doubleToRawLongBits(((PairNeuronDouble) other).value);
+        }
+
+        /** {@inheritDoc} */
+        @Override
+        public int hashCode() {
+            return Double.valueOf(value).hashCode();
+        }
+
     }
 }


[4/6] [math] Avoid a false positive findbugs warning.

Posted by lu...@apache.org.
Avoid a false positive findbugs warning.

Findbugs is confused by constant 1.570796251296997 which is a
intentionally slightly offset from PI/2 as per Cody Waite arguments
reduction.


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

Branch: refs/heads/MATH_3_X
Commit: b72d44673c8b47ae771c2fa901a31bc2d21614d1
Parents: fae8d86
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 11:20:30 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 11:20:47 2015 +0100

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/b72d4467/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index 0216613..5a960ca 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -170,6 +170,14 @@
     <Bug pattern="CNT_ROUGH_CONSTANT_VALUE" />
   </Match>
 
+  <!-- Spurious: Findbugs confused by constant 1.570796251296997 which is a
+       intentionally slightly offset from PI/2 as per Cody Waite arguments reduction -->
+  <Match>
+    <Class name="org.apache.commons.math3.util.FastMath$CodyWaite" />
+    <Method name="&lt;init>" params="double" returns="void" />
+    <Bug pattern="CNT_ROUGH_CONSTANT_VALUE" />
+  </Match>
+
   <!-- the following expositions of internal representation are intentional and documented -->
   <Match>
     <Class name="org.apache.commons.math3.stat.regression.RegressionResults"/>


[3/6] [math] Avoid a false positive findbugs warning.

Posted by lu...@apache.org.
Avoid a false positive findbugs warning.
    
The source code tests an angle using "angle > (FastMath.PI - 1.0e-10)".
As the compiler does the subtraction of the constants directly, findbugs
complains about a "Rough value of Math.PI found: 3.141592653489793".


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

Branch: refs/heads/MATH_3_X
Commit: fae8d86872ad332512f99c1edc75e7e35d7bcfbc
Parents: 8c2aa68
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Nov 3 11:18:59 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Nov 3 11:18:59 2015 +0100

----------------------------------------------------------------------
 findbugs-exclude-filter.xml | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/fae8d868/findbugs-exclude-filter.xml
----------------------------------------------------------------------
diff --git a/findbugs-exclude-filter.xml b/findbugs-exclude-filter.xml
index b971772..0216613 100644
--- a/findbugs-exclude-filter.xml
+++ b/findbugs-exclude-filter.xml
@@ -163,6 +163,13 @@
     <Bug pattern="DLS_DEAD_LOCAL_STORE" />
   </Match>
 
+  <!-- Spurious: Findbugs confused by FastMath.PI - 1.0e-10 -->
+  <Match>
+    <Class name="org.apache.commons.math3.geometry.euclidean.threed.Plane" />
+    <Method name="isSimilarTo" params="org.apache.commons.math3.geometry.euclidean.threed.Plane" returns="boolean" />
+    <Bug pattern="CNT_ROUGH_CONSTANT_VALUE" />
+  </Match>
+
   <!-- the following expositions of internal representation are intentional and documented -->
   <Match>
     <Class name="org.apache.commons.math3.stat.regression.RegressionResults"/>