You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sebb <se...@gmail.com> on 2010/07/09 16:26:39 UTC

Re: svn commit: r962515 - in /commons/proper/math/trunk/src/main: java/org/apache/commons/math/analysis/polynomials/ java/org/apache/commons/math/exception/ java/org/apache/commons/math/random/ java/org/apache/commons/math/util/ resources/META-INF/lo

On 9 July 2010 14:15,  <er...@apache.org> wrote:
> Author: erans
> Date: Fri Jul  9 13:15:28 2010
> New Revision: 962515
>
> URL: http://svn.apache.org/viewvc?rev=962515&view=rev
> Log:
> MATH-361
>
> Modified:
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NotPositiveException.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NotStrictlyPositiveException.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/NumberIsTooLargeException.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/AbstractRandomGenerator.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/BitsStreamGenerator.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/RandomDataImpl.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/random/UncorrelatedRandomVectorGenerator.java
>    commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/LocalizedFormats.java
>    commons/proper/math/trunk/src/main/resources/META-INF/localization/LocalizedFormats_fr.properties
>
> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java?rev=962515&r1=962514&r2=962515&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java (original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/analysis/polynomials/PolynomialFunction.java Fri Jul  9 13:15:28 2010
> @@ -19,7 +19,7 @@ package org.apache.commons.math.analysis
>  import java.io.Serializable;
>  import java.util.Arrays;
>
> -import org.apache.commons.math.MathRuntimeException;
> +import org.apache.commons.math.exception.NotStrictlyPositiveException;
>  import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
>  import org.apache.commons.math.analysis.UnivariateRealFunction;
>  import org.apache.commons.math.util.LocalizedFormats;
> @@ -58,12 +58,13 @@ public class PolynomialFunction implemen
>      *
>      * @param c polynomial coefficients
>      * @throws NullPointerException if c is null
> -     * @throws IllegalArgumentException if c is empty
> +     * @throws NotStrictlyPositiveException if c is empty
>      */
>     public PolynomialFunction(double c[]) {
>         super();
>         if (c.length < 1) {
> -            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
> +            throw new NotStrictlyPositiveException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY,
> +                                                   c.length);
>         }

Seems very odd to me to reject an empty array parameter with
"NotStrictlyPositiveException".

I would expect that to be reserved for numeric data passed as a
parameter or as an array entry.

IllegalArgument seems much clearer to me; alternatively one could
perhaps create an EmptyArrayNotAllowedException, if this is a common
requirement.

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


Re: svn commit: r962515 - in /commons/proper/math/trunk/src/main: java/org/apache/commons/math/analysis/polynomials/ java/org/apache/commons/math/exception/ java/org/apache/commons/math/random/ java/org/apache/commons/math/util/ resources/META-INF/lo

Posted by sebb <se...@gmail.com>.
On 9 July 2010 18:35, Gilles Sadowski <gi...@harfang.homelinux.org> wrote:
>> >     public PolynomialFunction(double c[]) {
>> >         super();
>> >         if (c.length < 1) {
>> > -            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
>> > +            throw new NotStrictlyPositiveException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY,
>> > +                                                   c.length);
>> >         }
>>
>> Seems very odd to me to reject an empty array parameter with
>> "NotStrictlyPositiveException".
>
> It just means that a 0 length is not allowed.

Or it could potentially mean that one of the array entries was 0.

The point is that the cause of the problem is not at all obvious from
the exception class name.

IMO it's less helpful than IAE.

>> I would expect that to be reserved for numeric data passed as a
>> parameter or as an array entry.
>>
>> IllegalArgument seems much clearer to me;
>
> "NotStrictlyPositiveException" is a subclass of "IllegalArgumentException".

Irrelevant, since what is confusing here is the classname of the exception.

>> alternatively one could
>> perhaps create an EmptyArrayNotAllowedException, if this is a common
>> requirement.
>
> Could be too.
>
>
> 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: svn commit: r962515 - in /commons/proper/math/trunk/src/main: java/org/apache/commons/math/analysis/polynomials/ java/org/apache/commons/math/exception/ java/org/apache/commons/math/random/ java/org/apache/commons/math/util/ resources/META-INF/lo

Posted by Gilles Sadowski <gi...@harfang.homelinux.org>.
> >     public PolynomialFunction(double c[]) {
> >         super();
> >         if (c.length < 1) {
> > -            throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
> > +            throw new NotStrictlyPositiveException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY,
> > +                                                   c.length);
> >         }
> 
> Seems very odd to me to reject an empty array parameter with
> "NotStrictlyPositiveException".

It just means that a 0 length is not allowed.

> I would expect that to be reserved for numeric data passed as a
> parameter or as an array entry.
> 
> IllegalArgument seems much clearer to me;

"NotStrictlyPositiveException" is a subclass of "IllegalArgumentException".

> alternatively one could
> perhaps create an EmptyArrayNotAllowedException, if this is a common
> requirement.

Could be too.


Gilles

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