Skip to content

Commit

Permalink
Add some 3D tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkofod committed Jan 18, 2019
1 parent 4dbf644 commit 3fa7f96
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion HARK/tests/test_discrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def setUp(self):
self.Vref2D = np.array([1.0, 1.0, 1.0])
self.Pref2D = np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]])

# self.Vs3D = np.array([[0.0, 1.0, 4.0], [1.0, 2.0, 0.0], [3.0, 0.0, 2.0]])
self.Vs3D = np.array([[0.0, 1.0, 4.0], [1.0, 2.0, 0.0], [3.0, 0.0, 2.0]])
self.Vref3D = np.array([[3.0, 2.0, 4.0]])
self.Pref3D = np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]])
# maxV = self.Vs3D.max()
# self.Vref3D = maxV + np.log(np.sum(np.exp(self.Vs3D-maxV),axis=0))
# self.Pref3D = np.log(np.sum(np.exp(self.Vs3D-maxV),axis=0))
Expand All @@ -44,3 +46,25 @@ def test_noShock2DIndividual(self):
P = interpolation.calcChoiceProbs(self.Vs2D, sigma)
self.assertTrue((V == self.Vref2D).all())
self.assertTrue((P == self.Pref2D).all())

def test_noShock3DBothEqualValue(self):
# Test the value functions and policies of the 3D case
sigma = 0.0
V, P = interpolation.calcLogSumChoiceProbs(self.Vs3D, sigma)
self.assertTrue((V == self.Vref3D).all)
self.assertTrue((P == self.Pref3D).all)

def test_noShock3DBoth(self):
# Test the value functions and policies of the 3D case
sigma = 0.0
V, P = interpolation.calcLogSumChoiceProbs(self.Vs3D, sigma)
self.assertTrue((V == self.Vref3D).all)
self.assertTrue((P == self.Pref3D).all)

def test_noShock3DIndividual(self):
# Test the value functions and policies of the 3D case
sigma = 0.0
V = interpolation.calcLogSum(self.Vs3D, sigma)
P = interpolation.calcChoiceProbs(self.Vs3D, sigma)
self.assertTrue((V == self.Vref3D).all())
self.assertTrue((P == self.Pref3D).all())

0 comments on commit 3fa7f96

Please sign in to comment.