class ModelTests(unittest.TestCase):
    def setUp(self):
        self.model = LinearMRF(3, 2)

    def test_unary_feature_shape(self):
        img = np.array([1, 0, 0, 1, 0, 1])
        result = self.model.get_unary_features(img)
        self.assertEqual(result.shape, (6, 2))

    def test_pairwise_feature_shape(self):
        result = self.model.get_pairwise_features()
        self.assertEqual(result.shape, (7, 4))
Пример #2
0
class ModelTests(unittest.TestCase):
    def setUp(self):
        self.model = LinearMRF(3, 2)

    def test_unary_feature_shape(self):
        img = np.array([1, 0, 0, 1, 0, 1])
        result = self.model.get_unary_features(img)
        self.assertEqual(result.shape, (6, 2))

    def test_unary_feature_data(self):
        img = np.array([1, 0, 0, 1, 0, 1])
        result = self.model.get_unary_features(img)
        expected = np.array([[0, 1], [1, 0], [1, 0], [0, 1], [1, 0], [0, 1]])
        np.testing.assert_array_equal(result, expected)

    def test_pairwise_feature_shape(self):
        result = self.model.get_pairwise_features()
        self.assertEqual(result.shape, (7, 4))

    def test_pairwise_feature_data(self):
        result = self.model.get_pairwise_features()
        np.testing.assert_array_equal(result, [[1, 0, 0, 1]] * 7)