package cs437.som.learningrate;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class ExponentialDecayLearningRateFunctionTest {
    private static final double MAXIMUM_DIFFERENCE = 0.0000000000000001;
    private static final int ITERATIONS = 1000;
    private static final double LEARNING_RATE = 1.0;

    @Test
    public void testLearningRate() throws Exception {
        ExponentialDecayLearningRateFunction edrf =
                new ExponentialDecayLearningRateFunction(LEARNING_RATE);
        edrf.setExpectedIterations(ITERATIONS);
        assertEquals(edrf.learningRate(0), LEARNING_RATE, MAXIMUM_DIFFERENCE);

        double last = edrf.learningRate(1);
        for (int i = 2; i < ITERATIONS; i += 10) {
            double current = edrf.learningRate(i);
            assertTrue(current < last, "Should consistently decay.");
            last = current;
        }

        assertEquals(edrf.learningRate(0), LEARNING_RATE,
                "Exponential decay should be equal with linear at start.");
        for (int i = 1; i < ITERATIONS; i++) {
            assertTrue(edrf.learningRate(i) < LEARNING_RATE - (i / ITERATIONS),
                    "Exponential decay should be less than linear.");
        }
    }
}

@@ -26,16 +26,58 @@
 grate;%0A%0A
+import org.testng.annotations.BeforeTest;%0A
 import o
@@ -435,135 +435,110 @@
     
-@Test%0A    public void testLearningRate() throws Exception %7B%0A        ExponentialDecayLearningRateFunction edrf =%0A       
+private ExponentialDecayLearningRateFunction edrf;%0A%0A    @BeforeTest%0A    public void setUp() %7B%0A
         
  new
@@ -533,16 +533,22 @@
         
+edrf =
  new Exp
@@ -645,16 +645,87 @@
 TIONS);%0A
+    %7D%0A%0A    @Test%0A    public void testLearningRate() throws Exception %7B%0A
         
@@ -795,16 +795,62 @@
 RENCE);%0A
+    %7D%0A%0A    @Test%0A    public void testShape() %7B
 %0A       
@@ -1093,24 +1093,110 @@
 %0A        %7D%0A%0A
+        testLessThanLinear();%0A    %7D%0A%0A    @Test%0A    public void testLessThanLinear() %7B%0A
         asse

Split tests into seperate methods in ExponentialDecayLearningRateFunctionTest.