@@ -0,0 +1,2111 @@
+from UpDownMethods import CORRECT, INCORRECT%0Aimport UpDownMethods as ud%0Aimport numpy as np%0Aimport matplotlib.pyplot as plt%0Aimport unittest%0A%0A%0A#%0A# Simulation parameters%0A#%0A%0Aresponses = %5BCORRECT, CORRECT, INCORRECT, INCORRECT, INCORRECT, INCORRECT,%0A             CORRECT, CORRECT, INCORRECT, INCORRECT, INCORRECT, CORRECT,%0A             CORRECT, CORRECT, CORRECT, CORRECT, INCORRECT, INCORRECT,%0A             INCORRECT, CORRECT, CORRECT, INCORRECT, INCORRECT, INCORRECT%5D%0A%0AinitalValue = 0.0%0AstepSize = 1.0%0Adown = 1%0Aup = 1%0A%0A%0A#%0A# Test code%0A#%0A%0Aclass TestSequenceFunctions(unittest.TestCase):%0A%0A    def setUp(self):%0A        self.results = ud.initiate_procedure()%0A        nextValue, self.results = ud.append_result(self.results, responses%5B0%5D,%0A                                                   down, up, stepSize,%0A                                                   initalValue)%0A        for resp in responses%5B1:%5D:%0A            nextValue, self.results = ud.append_result(self.results, resp,%0A                                                       down, up, stepSize,%0A                                                       nextValue)%0A%0A    def test_initiateResults(self):%0A        self.results = ud.initiate_procedure()%0A        self.assertIs(len(self.results), 0)%0A%0A    def test_calculateMidpoints(self):%0A        mids = ud.midpoints(self.results)%0A        mids = mids%5B%22Midpoint%22%5D%0A        mids = mids%5B%5B1, 3, 5%5D%5D.values   # Runs 2, 4, 6%0A        self.assertIsNone(np.testing.assert_array_equal(mids, %5B0.0, 1.5, -0.5%5D))%0A%0A    def test_plotResults(self):%0A        ud.plot_results(self.results)%0A        plt.savefig('test-fig4.png', bbox_inches='tight')%0A%0A    def test_runs(self):%0A        runs = ud.runs(self.results)%0A        self.assertIsNone(np.testing.assert_array_equal(%0A           runs%5B%22Start%22%5D.values, %5B1, 3, 7, 9, 12, 17, 20, 22%5D))%0A        self.assertIsNone(np.testing.assert_array_equal(%0A           runs%5B%22Finish%22%5D.values, %5B3, 7, 9, 12, 17, 20, 22, 24%5D))%0A%0A%0Aif __name__ == '__main__':%0A    # unittest.main()%0A    suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)%0A    unittest.TextTestRunner(verbosity=2).run(suite)%0A

Include Levitt figure 4 test