From 5453ed3181d109a0e22a90fc1a107d18405e0859 Mon Sep 17 00:00:00 2001 From: QBatista Date: Wed, 23 Aug 2017 14:53:25 +0900 Subject: [PATCH] TEST: Add tests for vertex_enumeration.py --- .../tests/test_vertex_enumeration.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/quantecon/game_theory/tests/test_vertex_enumeration.py b/quantecon/game_theory/tests/test_vertex_enumeration.py index 0b9f4f262..d215ff123 100644 --- a/quantecon/game_theory/tests/test_vertex_enumeration.py +++ b/quantecon/game_theory/tests/test_vertex_enumeration.py @@ -6,7 +6,7 @@ """ import numpy as np from numpy.testing import assert_allclose, assert_array_equal -from nose.tools import eq_ +from nose.tools import eq_, raises from quantecon.game_theory import NormalFormGame, vertex_enumeration from quantecon.game_theory.vertex_enumeration import _BestResponsePolytope @@ -46,6 +46,14 @@ def test_vertex_enumeration(self): assert_allclose(action_computed, action) +@raises(TypeError) +def test_vertex_enumeration_invalid_g(): + bimatrix = [[(3, 3), (3, 2)], + [(2, 2), (5, 6)], + [(0, 3), (6, 1)]] + vertex_enumeration(bimatrix) + + class TestBestResponsePolytope: def setUp(self): # From von Stengel 2007 in Algorithmic Game Theory @@ -98,6 +106,15 @@ def test_best_response_polytope(self): assert_allclose(vertices_computed, self.vertices_P, atol=1e-15) +@raises(TypeError) +def test_best_response_polytope_invalid_player_instance(): + bimatrix = [[(3, 3), (3, 2)], + [(2, 2), (5, 6)], + [(0, 3), (6, 1)]] + g = NormalFormGame(bimatrix) + _BestResponsePolytope(g) + + if __name__ == '__main__': import sys import nose