Esempio n. 1
0
	def test_processors_6x6_block(self):
        # given
        P0 = ProcessorI()
        collector = Spy()

        A = M6( 1 ,2 ,3 ,4 ,5 ,6  	
		,7 ,8 ,9 ,10 ,11 ,12  
		,13 ,14 ,15 ,16 ,17 ,18  
		,19 ,20 ,21 ,22 ,23 ,24  
		,25 ,26 ,27 ,28 ,29 ,30  
		,31 ,32 ,33 ,34 ,35,36 )
        
        B = M6(36 ,35 ,34 ,33 ,32 ,31  	
		,30 ,29 ,28 ,27 ,26 ,25  
		,24 ,23 ,22 ,21 ,20 ,19  
		,18 ,17 ,16 ,15 ,14 ,13  
		,12 ,11 ,10 ,9 ,8 ,7  
		,6 ,5 ,4 ,3 ,2 ,1  )

        C = M6(336 ,315 ,294 ,273 ,252 ,231 	
		,1092 ,1035 ,978 ,921 ,864 ,807 
		,1848 ,1755 ,1662 ,1569 ,1476 ,1383 
		,2604 ,2475 ,2346 ,2217 ,2088 ,1959 
		,3360 ,3195 ,3030 ,2865 ,2700 ,2535 
		,4116 ,3915 ,3714 ,3513 ,3312 ,3111)

        # when
        P0.init(0, 1, None, None, collector)
        P0.injectA(A, 0)
        P0.injectB(B, 0)

        # then
        assert_that(collector.inject, called().with_args(0, C, ANY_ARG))
Esempio n. 2
0
    def test_horizontal_shift_6x6_blocks_3x3(self):
        # given
        original = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                      31, 32, 33, 34, 35, 36)

        # when
        actual = matrix_horizontal_shift(original, block_order=3)

        # then
        expected = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 22, 23, 24, 19, 20, 21, 28, 29, 30, 25, 26, 27,
                      34, 35, 36, 31, 32, 33)

        assert_that(actual, is_(expected))
Esempio n. 3
0
    def test_join_9_2x2_blocks_in_6x6_matrix(self):
        # given
        A0 = M2(1, 2, 7, 8)

        A1 = M2(3, 4, 9, 10)

        A2 = M2(5, 6, 11, 12)

        A3 = M2(13, 14, 19, 20)

        A4 = M2(15, 16, 21, 22)

        A5 = M2(17, 18, 23, 24)

        A6 = M2(25, 26, 31, 32)

        A7 = M2(27, 28, 33, 34)

        A8 = M2(29, 30, 35, 36)

        # when
        actual = matrix_join(A0, A1, A2, A3, A4, A5, A6, A7, A8)
        # then
        expected = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                      31, 32, 33, 34, 35, 36)

        assert_that(actual, is_(expected))
Esempio n. 4
0
    def test_split_6x6_in_9_blocks(self):
        # given
        original = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                      31, 32, 33, 34, 35, 36)

        # when
        blocks = matrix_split(original, block_order=2)

        # then
        E00 = M2(1, 2, 7, 8)

        E01 = M2(3, 4, 9, 10)

        E02 = M2(5, 6, 11, 12)

        E10 = M2(13, 14, 19, 20)

        E11 = M2(15, 16, 21, 22)

        E12 = M2(17, 18, 23, 24)

        E20 = M2(25, 26, 31, 32)

        E21 = M2(27, 28, 33, 34)

        E22 = M2(29, 30, 35, 36)

        assert_that(blocks, is_([E00, E01, E02, E10, E11, E12, E20, E21, E22]))
Esempio n. 5
0
    def test_order_6(self):
        # given
        A = M6(1, 2, -1, 3, -5, 3, 3, 0, 2, 7, 1, 2, 5, 3, 3, 1, 4, 4, 2, 1, 2,
               2, 3, 3, -2, 2, 6, 6, 9, 7, -2, 2, -4, 2, 6, 5)

        B = M6(1, 2, 7, 7, -1, 3, 2, 1, 2, 1, -1, 2, 3, 0, 5, 5, 6, 1, 3, 1, 4,
               1, 6, 4, 2, 4, 3, 3, 3, 9, 1, 4, 3, 2, 1, 9)

        # when
        C = matrix_multiply(A, B)

        # then
        expected = M6(4, -1, 12, -2, -3, 0, 34, 25, 68, 45, 56, 66, 35, 46, 84,
                      74, 32, 100, 25, 31, 52, 42, 33, 72, 63, 68, 92, 65, 106,
                      172, 13, 44, 11, -2, 11, 101)

        assert_that(C, is_(expected))
Esempio n. 6
0
    def test_join_4_3x3_blocks_in_6x6_matrix(self):
        # given
        A0 = M3(1, 2, 3, 7, 8, 9, 13, 14, 15)

        A1 = M3(4, 5, 6, 10, 11, 12, 16, 17, 18)

        A2 = M3(19, 20, 21, 25, 26, 27, 31, 32, 33)

        A3 = M3(22, 23, 24, 28, 29, 30, 34, 35, 36)

        # when
        actual = matrix_join(A0, A1, A2, A3)

        # then
        expected = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                      31, 32, 33, 34, 35, 36)

        assert_that(actual, is_(expected))
Esempio n. 7
0
    def test_split_6x6_in_4_blocks(self):
        # given
        original = M6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
                      17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
                      31, 32, 33, 34, 35, 36)

        # when
        blocks = matrix_split(original, block_order=3)

        # then
        E00 = M3(1, 2, 3, 7, 8, 9, 13, 14, 15)

        E01 = M3(4, 5, 6, 10, 11, 12, 16, 17, 18)

        E10 = M3(19, 20, 21, 25, 26, 27, 31, 32, 33)

        E11 = M3(22, 23, 24, 28, 29, 30, 34, 35, 36)

        assert_that(blocks, is_([E00, E01, E10, E11]))