Hello Sébastien.

On Wed, Sep 12, 2012 at 04:43:39AM -0000, celes...@apache.org wrote:
> Author: celestin
> Date: Wed Sep 12 04:43:38 2012
> New Revision: 1383770
> 
> URL: http://svn.apache.org/viewvc?rev=1383770&view=rev
> Log:
> Removed LocalizedFormats.ENTRY previously introduced in r1383747, as 
> LocalizedFormats.INDEX will do nicely.
> 
> Modified:
>     
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/exception/util/LocalizedFormats.java
>     
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayFieldVector.java
>     
> commons/proper/math/trunk/src/main/resources/assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties
>     
> commons/proper/math/trunk/src/test/java/org/apache/commons/math3/exception/util/LocalizedFormatsTest.java
> 
> Modified: 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/exception/util/LocalizedFormats.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/exception/util/LocalizedFormats.java?rev=1383770&r1=1383769&r2=1383770&view=diff
> ==============================================================================
> --- 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/exception/util/LocalizedFormats.java
>  (original)
> +++ 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/exception/util/LocalizedFormats.java
>  Wed Sep 12 04:43:38 2012
> @@ -97,7 +97,6 @@ public enum LocalizedFormats implements 
>      EMPTY_SELECTED_ROW_INDEX_ARRAY("empty selected row index array"),
>      EMPTY_STRING_FOR_IMAGINARY_CHARACTER("empty string for imaginary 
> character"),
>      ENDPOINTS_NOT_AN_INTERVAL("endpoints do not specify an interval: [{0}, 
> {1}]"),
> -    ENTRY("entry {0}"),
>      EQUAL_VERTICES_IN_SIMPLEX("equal vertices {0} and {1} in simplex 
> configuration"),
>      EULER_ANGLES_SINGULARITY("Euler angles singularity"),
>      EVALUATION("evaluation"), /* keep */

Please discard my previous message...
Again one disability of mine (apart from not being an HTML parser): I
process messages sequentially. :-) Sorry.

But, there was something else:

> 
> Modified: 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayFieldVector.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayFieldVector.java?rev=1383770&r1=1383769&r2=1383770&view=diff
> ==============================================================================
> --- 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayFieldVector.java
>  (original)
> +++ 
> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayFieldVector.java
>  Wed Sep 12 04:43:38 2012
> @@ -560,7 +560,7 @@ public class ArrayFieldVector<T extends 
>              try {
>                  out[i] = one.divide(data[i]);
>              } catch (final MathArithmeticException e) {
> -                throw new MathArithmeticException(LocalizedFormats.ENTRY, i);
> +                throw new MathArithmeticException(LocalizedFormats.INDEX, i);
>              }
>          }

Do we really want to do this instead of checking a precondition (or do
nothin at that level)? I know that it would be preferrable to (also) report
the INDEX, but on the other hand, this kind of code becomes really ugly (in
the sense that there are more signs related to failure detection and
handling than to the "interesting stuff".

Moreover, you can an exception and completely discard the information it
might have contained! [In this case, the info might likely have been
"division by zero".]

Finally a more general point: In the "FieldElement" interface, there is
---
    /** Compute this &divide; a.
     * @param a element to add
     * @return a new element representing this &divide; a
     * @throws NullArgumentException if {@code a} is {@code null}.
     * @throws MathArithmeticException if {@code a} is zero
     */
    T divide(T a) throws NullArgumentException, MathArithmeticException;
---

This is another example of what I pointed to a few days ago: Documenting
MathArithmeticException is wrong because not all implementations behave that
way (e.g. "Complex"). [Alternatively, it can be construed that "Complex" is
not correctly implemented (cf. MATH-667).]

[There is also a typo in the description of param "a".]

Best regards,
Gilles

>          return new ArrayFieldVector<T>(field, out, false);
> @@ -573,7 +573,7 @@ public class ArrayFieldVector<T extends 
>              try {
>                  data[i] = one.divide(data[i]);
>              } catch (final MathArithmeticException e) {
> -                throw new MathArithmeticException(LocalizedFormats.ENTRY, i);
> +                throw new MathArithmeticException(LocalizedFormats.INDEX, i);
>              }
>          }
>          return this;
> @@ -623,7 +623,7 @@ public class ArrayFieldVector<T extends 
>                  try {
>                      out[i] = data[i].divide(v.getEntry(i));
>                  } catch (final MathArithmeticException e) {
> -                    throw new 
> MathArithmeticException(LocalizedFormats.ENTRY, i);
> +                    throw new 
> MathArithmeticException(LocalizedFormats.INDEX, i);
>                  }
>              }
>              return new ArrayFieldVector<T>(field, out, false);
> @@ -646,7 +646,7 @@ public class ArrayFieldVector<T extends 
>              try {
>                  out[i] = data[i].divide(v.data[i]);
>              } catch (final MathArithmeticException e) {
> -                throw new MathArithmeticException(LocalizedFormats.ENTRY, i);
> +                throw new MathArithmeticException(LocalizedFormats.INDEX, i);
>              }
>          }
>          return new ArrayFieldVector<T>(field, out, false);
> 
> Modified: 
> commons/proper/math/trunk/src/main/resources/assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties
> URL: 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/resources/assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties?rev=1383770&r1=1383769&r2=1383770&view=diff
> ==============================================================================
> --- 
> commons/proper/math/trunk/src/main/resources/assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties
>  (original)
> +++ 
> commons/proper/math/trunk/src/main/resources/assets/org/apache/commons/math3/exception/util/LocalizedFormats_fr.properties
>  Wed Sep 12 04:43:38 2012
> @@ -69,7 +69,6 @@ EMPTY_SELECTED_COLUMN_INDEX_ARRAY = tabl
>  EMPTY_SELECTED_ROW_INDEX_ARRAY = tableau des indices de lignes 
> s\u00e9lectionn\u00e9es vide
>  EMPTY_STRING_FOR_IMAGINARY_CHARACTER = cha\u00eene vide pour le caract\u00e8 
> imaginaire
>  ENDPOINTS_NOT_AN_INTERVAL = les bornes ne d\u00e9finissent pas un intervalle 
> : [{0}, {1}]
> -ENTRY = \u00e9l\u00e9ment {0}
>  EQUAL_VERTICES_IN_SIMPLEX = sommets {0} et {1} \u00e9gaux dans la 
> configuration du simplex
>  EULER_ANGLES_SINGULARITY = singularit\u00e9 d''angles d''Euler
>  EVALUATION = \u00e9valuation
> 
> Modified: 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math3/exception/util/LocalizedFormatsTest.java
> URL: 
> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/exception/util/LocalizedFormatsTest.java?rev=1383770&r1=1383769&r2=1383770&view=diff
> ==============================================================================
> --- 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math3/exception/util/LocalizedFormatsTest.java
>  (original)
> +++ 
> commons/proper/math/trunk/src/test/java/org/apache/commons/math3/exception/util/LocalizedFormatsTest.java
>  Wed Sep 12 04:43:38 2012
> @@ -36,7 +36,7 @@ public class LocalizedFormatsTest {
>  
>      @Test
>      public void testMessageNumber() {
> -        Assert.assertEquals(311, LocalizedFormats.values().length);
> +        Assert.assertEquals(310, LocalizedFormats.values().length);
>      }
>  
>      @Test
> 
> 

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

Reply via email to