Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_indifference_strategies_with_non_degenerate(self):
"""Test for the indifference strategies of potential supports"""
A = np.array([[2, 1], [0, 2]])
B = np.array([[2, 0], [1, 2]])
expected_indifference = [
(np.array([1, 0]), np.array([1, 0])),
(np.array([1, 0]), np.array([0, 1])),
(np.array([0, 1]), np.array([1, 0])),
(np.array([0, 1]), np.array([0, 1])),
(np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
]
obtained_indifference = [
out[:2]
for out in indifference_strategies(A, B, non_degenerate=True)
]
self.assertEqual(len(obtained_indifference), len(expected_indifference))
for obtained, expected in zip(
obtained_indifference, expected_indifference
):
self.assertTrue(
np.array_equal(obtained, expected),
msg="obtained: {} !=expected: {}".format(obtained, expected),
)
def test_indifference_strategies(self):
"""Test for the indifference strategies of potential supports"""
A = np.array([[2, 1], [0, 2]])
B = np.array([[2, 0], [1, 2]])
expected_indifference = [
(np.array([1, 0]), np.array([1, 0])),
(np.array([1, 0]), np.array([0, 1])),
(np.array([0, 1]), np.array([1, 0])),
(np.array([0, 1]), np.array([0, 1])),
(np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
]
obtained_indifference = [
out[:2] for out in indifference_strategies(A, B)
]
self.assertEqual(len(obtained_indifference), len(expected_indifference))
for obtained, expected in zip(
obtained_indifference, expected_indifference
):
self.assertTrue(
np.array_equal(obtained, expected),
msg="obtained: {} !=expected: {}".format(obtained, expected),
)
def test_indifference_strategies_with_high_tolerance(self):
"""Test for the indifference strategies of potential supports"""
A = np.array([[2, 1], [0, 2]])
B = np.array([[2, 0], [1, 2]])
expected_indifference = [
(np.array([1, 0]), np.array([1, 0])),
(np.array([1, 0]), np.array([0, 1])),
(np.array([0, 1]), np.array([1, 0])),
(np.array([0, 1]), np.array([0, 1])),
(np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
]
obtained_indifference = [
out[:2] for out in indifference_strategies(A, B, tol=10 ** -2)
]
self.assertEqual(len(obtained_indifference), len(expected_indifference))
for obtained, expected in zip(
obtained_indifference, expected_indifference
):
self.assertTrue(
np.array_equal(obtained, expected),
msg="obtained: {} !=expected: {}".format(obtained, expected),
)