@Test public void testHashCodeAndEquals() { ParameterLimitsTransform other = new DoubleRangeLimitTransform(A, B); assertEquals(other, RANGE_LIMITS); assertEquals(other.hashCode(), RANGE_LIMITS.hashCode()); other = new DoubleRangeLimitTransform(A - 1, B); assertFalse(other.equals(RANGE_LIMITS)); other = new DoubleRangeLimitTransform(A, B + 1); assertFalse(other.equals(RANGE_LIMITS)); }
protected void assertInverseGradient(ParameterLimitsTransform transform, double fitParam) { double eps = 1e-5; double g = transform.inverseTransformGradient(fitParam); double fdg; double down = transform.inverseTransform(fitParam - eps); double up = transform.inverseTransform(fitParam + eps); fdg = (up - down) / 2 / eps; assertEquals(g, fdg, 1e-6); }
protected void assertGradient(ParameterLimitsTransform transform, double modelParam) { double eps = 1e-5; double g = transform.transformGradient(modelParam); double fdg; try { double down = transform.transform(modelParam - eps); double up = transform.transform(modelParam + eps); fdg = (up - down) / 2 / eps; } catch (IllegalArgumentException e) { double fp = transform.transform(modelParam); try { double up = transform.transform(modelParam + eps); fdg = (up - fp) / eps; } catch (IllegalArgumentException e2) { double down = transform.transform(modelParam - eps); fdg = (fp - down) / eps; } } assertEquals(g, fdg, 1e-6); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOutOfRange4() { RANGE_LIMITS.transformGradient(1.01); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOutOfRange1() { RANGE_LIMITS.transform(-3); }
protected void assertGradientRoundTrip(ParameterLimitsTransform transform, double modelParam) { double g = transform.transformGradient(modelParam); double fp = transform.transform(modelParam); double gInv = transform.inverseTransformGradient(fp); assertEquals(g, 1.0 / gInv, 1e-8); }
// reverse protected void assertReverseRoundTrip(ParameterLimitsTransform transform, double fitParam) { double mp = transform.inverseTransform(fitParam); double fp = transform.transform(mp); assertEquals(fitParam, fp, 1e-8); }
protected void assertRoundTrip(ParameterLimitsTransform transform, double modelParam) { double fp = transform.transform(modelParam); double mp = transform.inverseTransform(fp); assertEquals(modelParam, mp, 1e-8); }