Java Code Examples for org.apache.commons.math3.util.MathUtils#checkFinite()

The following examples show how to use org.apache.commons.math3.util.MathUtils#checkFinite() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CentroidOfConnectedComponentsDetectorTest.java    From thunderstorm with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDetectMoleculeCandidates2() {
    // seven molecules close together that needs watershed segmentation to resolve them
    String basePath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
    System.out.println(basePath);
    FloatProcessor fp = (FloatProcessor) IJ.openImage(basePath + "7peaksWaveletFiltered.tif").getProcessor().convertToFloat();
    CentroidOfConnectedComponentsDetector detector = new CentroidOfConnectedComponentsDetector("2", true);
    List<Point> detections = detector.detectMoleculeCandidates(fp);
    assertEquals(7, detections.size());
    for(Point p: detections){
        double x = p.getX().doubleValue();
        double y = p.getY().doubleValue();
        MathUtils.checkFinite(x);
        MathUtils.checkFinite(y);
        assertTrue("in range", x >=0 && x <= fp.getWidth());
        assertTrue("in range", y >=0 && y <= fp.getWidth());
    }
}
 
Example 2
Source File: ParamUtils.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Checks that the  input is not infinity nor NaN or throws an {@link IllegalArgumentException}
 * @param val value to check
 * @param message the text message that would be pass to the exception thrown
 * @return the same value
 * @throws IllegalArgumentException
 */
public static double isFinite(final double val, final String message) {
    try {
        MathUtils.checkFinite(val);
    } catch (final NotFiniteNumberException ne) {
        throw new IllegalArgumentException(message);
    }
    return val;
}
 
Example 3
Source File: ParamUtils.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Checks that the  input is not infinity nor NaN or throws an {@link IllegalArgumentException}
 * @param val value to check
 * @param message the text message that would be pass to the exception thrown
 * @return the same value
 * @throws IllegalArgumentException
 */
public static double isFinite(final double val, final String message) {
    try {
        MathUtils.checkFinite(val);
    } catch (final NotFiniteNumberException ne) {
        throw new IllegalArgumentException(message);
    }
    return val;
}
 
Example 4
Source File: ModifiedLoess.java    From thunderstorm with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 5
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 6
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 7
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 8
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 9
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 10
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 11
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}
 
Example 12
Source File: LoessInterpolator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Check that all elements of an array are finite real numbers.
 *
 * @param values Values array.
 * @throws org.apache.commons.math3.exception.NotFiniteNumberException
 * if one of the values is not a finite real number.
 */
private static void checkAllFiniteReal(final double[] values) {
    for (int i = 0; i < values.length; i++) {
        MathUtils.checkFinite(values[i]);
    }
}