Beispiel #1
0
    def test_get_transform_matrix_no_data(self):
        uut = InteractiveSquare()

        expected = []
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())
Beispiel #2
0
    def test_get_transform_matrix_one_order_only_indices(self):
        uut = InteractiveSquare()
        uut._matrices[1] = (None, {(0, 1): 0.25}, None)

        expected = [[1, 0.25], [0, 1]]
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())
Beispiel #3
0
    def test_get_transform_matrix_two_order_only_indices(self):
        uut = InteractiveSquare()
        uut._matrices[1] = (None, {(0, 1): 0.25}, np.dot)
        uut._matrices[2] = (None, {(1, 0): 0.5}, np.dot)

        expected = [[1, 0.25], [0.5, 1.125]]
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())
Beispiel #4
0
    def test_get_transform_matrix_one_order_only_matrix(self):
        uut = InteractiveSquare()

        expected = np.array([[1, 0.25], [0.5, 1]])

        uut.register_transform(expected)

        actual = uut._get_transform_matrix()

        self.assertEqual(expected.tolist(), actual.tolist())
Beispiel #5
0
    def test_get_transform_matrix_two_order_both_matrix_and_indices(self):
        matrix_1 = np.array([[1, 0.25], [0, 1]])
        matrix_2 = np.array([[1, 0.75], [0, 1]])

        uut = InteractiveSquare()
        uut._matrices[1] = (matrix_1, {(1, 0): 0.5}, np.dot)
        uut._matrices[2] = (matrix_2, {(1, 0): 1.25}, np.dot)

        expected = [[1.375, 1], [1.75, 1.3125]]
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())
Beispiel #6
0
    def test_get_transform_matrix_two_order_only_matrix(self):
        matrix_1 = np.array([[1, 0.25], [0, 1]])
        matrix_2 = np.array([[1, 0], [0.5, 1]])

        uut = InteractiveSquare()
        uut._matrices[1] = (matrix_1, {}, np.dot)
        uut._matrices[2] = (matrix_2, {}, np.dot)

        expected = [[1, 0.25], [0.5, 1.125]]
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())
Beispiel #7
0
    def test_get_transform_matrix_one_order_both_matrix_and_indices(self):
        uut = InteractiveSquare()

        matrix = np.array([[1, 0.25], [0, 1]])

        uut = InteractiveSquare()
        uut._matrices[0] = [matrix, {}, None]
        uut._matrices[0][1][(1, 0)] = 0.5

        expected = np.array([[1, 0.25], [0.5, 1]])
        actual = uut._get_transform_matrix()

        self.assertEqual(expected.tolist(), actual.tolist())
Beispiel #8
0
    def test_get_transform_matrix_three_order_sorted(self):
        matrix_1 = np.array([[0.25, 0.5], [0.75, 1]])
        matrix_2 = np.array([[1.25, 1.5], [1.75, 2]])
        matrix_3 = np.array([[2.25, 2.5], [2.75, 3]])

        uut = InteractiveSquare()
        uut._matrices[1] = (matrix_1, {}, np.dot)
        uut._matrices[7] = (matrix_3, {}, np.dot)
        uut._matrices[3] = (matrix_2, {}, np.dot)

        expected = [[8.078125, 11.96875], [9.765625, 14.46875]]
        actual = uut._get_transform_matrix()

        self.assertEqual(expected, actual.tolist())