Commits

Lars Yencken committed ec8df08

Add another test of wraparound for mdp.

Comments (0)

Files changed (1)

     def setUp(self):
         pass
 
-    #def test_single_row(self):
-        #reward = np.array([0.0,0.0,0.0,8.0])
-        #reward.reshape((1, 4))
-        #value = mdp.value_iteration(reward, gamma=0.5, eps=1e-5)
-        #expected = np.array([1.0, 2.0, 4.0, 8.0])
-        #expected.reshape((1, 4))
-        #assert abs(value - expected).mean() < 1e-5
-
     def test_square(self):
         reward = np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]])
         expected = np.array(
         value = mdp.value_iteration(reward, torus=True, gamma=0.5, eps=1e-5)
         assert abs(value - expected).mean() < 1e-5, str(value)
 
+    def test_wraparound_2(self):
+        reward = np.array([[1, 0, 0], [0, 0, 0], [0, 0, 0]])
+        expected = np.array([[4, 2, 2], [2, 1, 1], [2, 1, 1]],
+                dtype=np.float32) / 3.0
+        value = mdp.value_iteration(reward, torus=True, gamma=0.5, eps=1e-5)
+        assert abs(value - expected).mean() < 1e-5, str(value)
+
 def suite():
     return unittest.TestSuite([
             unittest.makeSuite(MDPPlaneTest),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.