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/07/05 20:32:16 UTC

[2/2] [math] Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.

Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.

These can be useful to manage an OutOfRangeException without the need to
access the original x and y arrays.

Closes #9.

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

Branch: refs/heads/master
Commit: 3ac3ff62b862ee89effcf1a4889b04f32fd8dbb2
Parents: 088d0f9
Author: Luc Maisonobe <lu...@apache.org>
Authored: Sun Jul 5 10:21:53 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Sun Jul 5 10:21:53 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  5 +++
 .../BicubicInterpolatingFunction.java           | 32 ++++++++++++++++++++
 .../BicubicInterpolatingFunctionTest.java       | 14 +++++++--
 3 files changed, 49 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 83d03e1..63df40a 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,11 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="luc" type="add" due-to="Lorenzoexe">
+        Add getXmax(), getXmin(), getYmax(), getYmin() to bicubic interpolating function.
+        These can be useful to manage an OutOfRangeException without the need to access
+        the original x and y arrays.
+      </action>
       <action dev="luc" type="add" >
         Added mapping functions to MathArrays. These methods allow to map
         any univariate or bivariate functions to arrays.

http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
index b89a517..f1c10f8 100644
--- a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
+++ b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
@@ -185,6 +185,38 @@ public class BicubicInterpolatingFunction
     }
 
     /**
+     * Returns the minimum value of the first coordinate
+     * @return xval[0].
+     */
+    public double getXmin() {
+        return xval[0];
+    }
+
+    /**
+     * Returns the maximum value of the second coordinate
+     * @return xval[xval.length - 1].
+     */
+    public double getXmax() {
+        return xval[xval.length - 1];
+    }
+
+    /**
+     * Returns the minimum value of the second coordinate
+     * @return yval[0].
+     */
+    public double getYmin() {
+        return yval[0];
+    }
+
+    /**
+     * Returns the maximum value of the second coordinate
+     * @return yval[yval.length - 1].
+     */
+    public double getYmax() {
+        return yval[yval.length - 1];
+    }
+
+    /**
      * @param c Coordinate.
      * @param val Coordinate samples.
      * @return the index in {@code val} corresponding to the interval

http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
index 0ec77aa..b54c750 100644
--- a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
@@ -160,7 +160,12 @@ public final class BicubicInterpolatingFunctionTest {
         try {
             bcf.value(x, y);
             Assert.fail("OutOfRangeException expected");
-        } catch (OutOfRangeException expected) {}
+        } catch (OutOfRangeException expected) {
+            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
+            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
+            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
+            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
+        }
 
         x = xMin;
         y = yMax + small;
@@ -169,7 +174,12 @@ public final class BicubicInterpolatingFunctionTest {
         try {
             bcf.value(x, y);
             Assert.fail("OutOfRangeException expected");
-        } catch (OutOfRangeException expected) {}
+        } catch (OutOfRangeException expected) {
+            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
+            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
+            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
+            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
+        }
     }
 
     /**


Re: [2/2] [math] Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Sun, 05 Jul 2015 22:31:27 +0200, Luc Maisonobe wrote:
> Le 05/07/2015 21:39, Gilles a écrit :
>> On Sun, 05 Jul 2015 18:32:16 -0000, luc@apache.org wrote:
>>> Add getXmax, getXmin, getYmax, getYmin to 
>>> BicubicInterpolatingFunction.
>>>
>>> These can be useful to manage an OutOfRangeException without the 
>>> need to
>>> access the original x and y arrays.
>>
>> IIRC, this "feature" has been requested before but eventually 
>> without a
>> convincing use-case. [In general, the user knows the valid range 
>> since
>> he called "interpolate".]
>
> User do not always keep the arrays. As the interpolator does jeep 
> them,
> we just have to ask it.

That might be the case but I'm talking of agreeing on the API!

Personally, and only if the feature is useful, I'd have considered
methods like:

public double[] getInterpolationRangeX() {
   return new double[] { xval[0], xval[xval.length - 1] };
}

>>
>>> Closes #9.
>>
>> Shouldn't we discuss API change on the ML?
>
> If we start discussing every single getter, we will grind to halt. We
> are already not responsive enough (and I put most of the blame on 
> myself).
>

Isn't that the one rule to abide by?

Git pull requests are not forwarded here anymore. And I find it 
respectful
towards the project's committers, who (try to) comply with the rules, 
that
they are not bypassed.

Please don't take me wrong; I do not mean that everyone should have 
voted
on every topic before a commit is performed; many (most) recent changes 
and
improvements have come about without any such discussions.
However, in this case, I feel that we start again to add "features" 
that
might just be bloat ("because we can").  To please an "anonymous" 
one-time
contributor?  I find it more productive to incite him/her to comply 
with
what we want the library to be (e.g. the method naming scheme) and 
possibly
change the pull request accordingly...

Or please let people say clearly here, that it is fine to commit 
anything
and let the burden of further modification to those who want to 
challenge
it after the fact; possibly leading to further overwrites but the 
proponents
of the preceding version, etc.
IIUC this would be a change of policy.  Please correct if I'm wrong 
(i.e.
the above has always been fine).


Regards,
Gilles


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


Re: [2/2] [math] Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.

Posted by Luc Maisonobe <lu...@spaceroots.org>.
Le 05/07/2015 21:39, Gilles a écrit :
> On Sun, 05 Jul 2015 18:32:16 -0000, luc@apache.org wrote:
>> Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.
>>
>> These can be useful to manage an OutOfRangeException without the need to
>> access the original x and y arrays.
> 
> IIRC, this "feature" has been requested before but eventually without a
> convincing use-case. [In general, the user knows the valid range since
> he called "interpolate".]

User do not always keep the arrays. As the interpolator does jeep them,
we just have to ask it.

> 
>> Closes #9.
> 
> Shouldn't we discuss API change on the ML?

If we start discussing every single getter, we will grind to halt. We
are already not responsive enough (and I put most of the blame on myself).

best regards,
Luc

> 
> 
> Regards,
> Gilles
> 
>> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/commons-math/commit/3ac3ff62
>> Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/3ac3ff62
>> Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/3ac3ff62
>>
>> Branch: refs/heads/master
>> Commit: 3ac3ff62b862ee89effcf1a4889b04f32fd8dbb2
>> Parents: 088d0f9
>> Author: Luc Maisonobe <lu...@apache.org>
>> Authored: Sun Jul 5 10:21:53 2015 +0200
>> Committer: Luc Maisonobe <lu...@apache.org>
>> Committed: Sun Jul 5 10:21:53 2015 +0200
>>
>>
>> ----------------------------------------------------------------------
>>  src/changes/changes.xml                         |  5 +++
>>  .../BicubicInterpolatingFunction.java           | 32
>> ++++++++++++++++++++
>>  .../BicubicInterpolatingFunctionTest.java       | 14 +++++++--
>>  3 files changed, 49 insertions(+), 2 deletions(-)
>>
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/changes/changes.xml
>>
>>
>> ----------------------------------------------------------------------
>> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
>> index 83d03e1..63df40a 100644
>> --- a/src/changes/changes.xml
>> +++ b/src/changes/changes.xml
>> @@ -54,6 +54,11 @@ If the output is not quite correct, check for
>> invisible trailing spaces!
>>      </release>
>>
>>      <release version="4.0" date="XXXX-XX-XX" description="">
>> +      <action dev="luc" type="add" due-to="Lorenzoexe">
>> +        Add getXmax(), getXmin(), getYmax(), getYmin() to bicubic
>> interpolating function.
>> +        These can be useful to manage an OutOfRangeException without
>> the need to access
>> +        the original x and y arrays.
>> +      </action>
>>        <action dev="luc" type="add" >
>>          Added mapping functions to MathArrays. These methods allow to
>> map
>>          any univariate or bivariate functions to arrays.
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
>>
>>
>> ----------------------------------------------------------------------
>> diff --git
>>
>> a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
>>
>>
>> b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
>>
>> index b89a517..f1c10f8 100644
>> ---
>>
>> a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
>>
>> +++
>>
>> b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
>>
>> @@ -185,6 +185,38 @@ public class BicubicInterpolatingFunction
>>      }
>>
>>      /**
>> +     * Returns the minimum value of the first coordinate
>> +     * @return xval[0].
>> +     */
>> +    public double getXmin() {
>> +        return xval[0];
>> +    }
>> +
>> +    /**
>> +     * Returns the maximum value of the second coordinate
>> +     * @return xval[xval.length - 1].
>> +     */
>> +    public double getXmax() {
>> +        return xval[xval.length - 1];
>> +    }
>> +
>> +    /**
>> +     * Returns the minimum value of the second coordinate
>> +     * @return yval[0].
>> +     */
>> +    public double getYmin() {
>> +        return yval[0];
>> +    }
>> +
>> +    /**
>> +     * Returns the maximum value of the second coordinate
>> +     * @return yval[yval.length - 1].
>> +     */
>> +    public double getYmax() {
>> +        return yval[yval.length - 1];
>> +    }
>> +
>> +    /**
>>       * @param c Coordinate.
>>       * @param val Coordinate samples.
>>       * @return the index in {@code val} corresponding to the interval
>>
>>
>> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
>>
>>
>> ----------------------------------------------------------------------
>> diff --git
>>
>> a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
>>
>>
>> b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
>>
>> index 0ec77aa..b54c750 100644
>> ---
>>
>> a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
>>
>> +++
>>
>> b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
>>
>> @@ -160,7 +160,12 @@ public final class
>> BicubicInterpolatingFunctionTest {
>>          try {
>>              bcf.value(x, y);
>>              Assert.fail("OutOfRangeException expected");
>> -        } catch (OutOfRangeException expected) {}
>> +        } catch (OutOfRangeException expected) {
>> +            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
>> +            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
>> +            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
>> +            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
>> +        }
>>
>>          x = xMin;
>>          y = yMax + small;
>> @@ -169,7 +174,12 @@ public final class
>> BicubicInterpolatingFunctionTest {
>>          try {
>>              bcf.value(x, y);
>>              Assert.fail("OutOfRangeException expected");
>> -        } catch (OutOfRangeException expected) {}
>> +        } catch (OutOfRangeException expected) {
>> +            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
>> +            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
>> +            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
>> +            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
>> +        }
>>      }
>>
>>      /**
> 
> 
> 


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


Re: [2/2] [math] Add getXmax, getXmin, getYmax, getYmin to BicubicInterpolatingFunction.

Posted by Gilles <gi...@harfang.homelinux.org>.
On Sun, 05 Jul 2015 18:32:16 -0000, luc@apache.org wrote:
> Add getXmax, getXmin, getYmax, getYmin to 
> BicubicInterpolatingFunction.
>
> These can be useful to manage an OutOfRangeException without the need 
> to
> access the original x and y arrays.

IIRC, this "feature" has been requested before but eventually without a
convincing use-case. [In general, the user knows the valid range since
he called "interpolate".]

> Closes #9.

Shouldn't we discuss API change on the ML?


Regards,
Gilles

> Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
> Commit: 
> http://git-wip-us.apache.org/repos/asf/commons-math/commit/3ac3ff62
> Tree: 
> http://git-wip-us.apache.org/repos/asf/commons-math/tree/3ac3ff62
> Diff: 
> http://git-wip-us.apache.org/repos/asf/commons-math/diff/3ac3ff62
>
> Branch: refs/heads/master
> Commit: 3ac3ff62b862ee89effcf1a4889b04f32fd8dbb2
> Parents: 088d0f9
> Author: Luc Maisonobe <lu...@apache.org>
> Authored: Sun Jul 5 10:21:53 2015 +0200
> Committer: Luc Maisonobe <lu...@apache.org>
> Committed: Sun Jul 5 10:21:53 2015 +0200
>
> 
> ----------------------------------------------------------------------
>  src/changes/changes.xml                         |  5 +++
>  .../BicubicInterpolatingFunction.java           | 32 
> ++++++++++++++++++++
>  .../BicubicInterpolatingFunctionTest.java       | 14 +++++++--
>  3 files changed, 49 insertions(+), 2 deletions(-)
> 
> ----------------------------------------------------------------------
>
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/changes/changes.xml
> 
> ----------------------------------------------------------------------
> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> index 83d03e1..63df40a 100644
> --- a/src/changes/changes.xml
> +++ b/src/changes/changes.xml
> @@ -54,6 +54,11 @@ If the output is not quite correct, check for
> invisible trailing spaces!
>      </release>
>
>      <release version="4.0" date="XXXX-XX-XX" description="">
> +      <action dev="luc" type="add" due-to="Lorenzoexe">
> +        Add getXmax(), getXmin(), getYmax(), getYmin() to bicubic
> interpolating function.
> +        These can be useful to manage an OutOfRangeException without
> the need to access
> +        the original x and y arrays.
> +      </action>
>        <action dev="luc" type="add" >
>          Added mapping functions to MathArrays. These methods allow 
> to map
>          any univariate or bivariate functions to arrays.
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
> 
> b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
> index b89a517..f1c10f8 100644
> ---
> 
> a/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
> +++
> 
> b/src/main/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunction.java
> @@ -185,6 +185,38 @@ public class BicubicInterpolatingFunction
>      }
>
>      /**
> +     * Returns the minimum value of the first coordinate
> +     * @return xval[0].
> +     */
> +    public double getXmin() {
> +        return xval[0];
> +    }
> +
> +    /**
> +     * Returns the maximum value of the second coordinate
> +     * @return xval[xval.length - 1].
> +     */
> +    public double getXmax() {
> +        return xval[xval.length - 1];
> +    }
> +
> +    /**
> +     * Returns the minimum value of the second coordinate
> +     * @return yval[0].
> +     */
> +    public double getYmin() {
> +        return yval[0];
> +    }
> +
> +    /**
> +     * Returns the maximum value of the second coordinate
> +     * @return yval[yval.length - 1].
> +     */
> +    public double getYmax() {
> +        return yval[yval.length - 1];
> +    }
> +
> +    /**
>       * @param c Coordinate.
>       * @param val Coordinate samples.
>       * @return the index in {@code val} corresponding to the 
> interval
>
> 
> http://git-wip-us.apache.org/repos/asf/commons-math/blob/3ac3ff62/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
> 
> ----------------------------------------------------------------------
> diff --git
> 
> a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
> 
> b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
> index 0ec77aa..b54c750 100644
> ---
> 
> a/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
> +++
> 
> b/src/test/java/org/apache/commons/math4/analysis/interpolation/BicubicInterpolatingFunctionTest.java
> @@ -160,7 +160,12 @@ public final class 
> BicubicInterpolatingFunctionTest {
>          try {
>              bcf.value(x, y);
>              Assert.fail("OutOfRangeException expected");
> -        } catch (OutOfRangeException expected) {}
> +        } catch (OutOfRangeException expected) {
> +            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
> +            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
> +            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
> +            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
> +        }
>
>          x = xMin;
>          y = yMax + small;
> @@ -169,7 +174,12 @@ public final class 
> BicubicInterpolatingFunctionTest {
>          try {
>              bcf.value(x, y);
>              Assert.fail("OutOfRangeException expected");
> -        } catch (OutOfRangeException expected) {}
> +        } catch (OutOfRangeException expected) {
> +            Assert.assertEquals(xMin, bcf.getXmin(), 1.0e-15);
> +            Assert.assertEquals(xMax, bcf.getXmax(), 1.0e-15);
> +            Assert.assertEquals(yMin, bcf.getYmin(), 1.0e-15);
> +            Assert.assertEquals(yMax, bcf.getYmax(), 1.0e-15);
> +        }
>      }
>
>      /**