Exemplo n.º 1
0
    def test_get_blocks(self):
        """
        PIQS: Test the calculation of list of cumulative elements at each block.

        For N = 4

        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
                1 1 1
                1 1 1
                1 1 1
                     1
        Thus, the blocks are [5, 8, 9] denoting that after the first block 5
        elements have been accounted for and so on.
        """
        trueb1 = [2]
        trueb2 = [3, 4]
        trueb3 = [4, 6]
        trueb4 = [5, 8, 9]

        test_b1 = get_blocks(1)
        test_b2 = get_blocks(2)
        test_b3 = get_blocks(3)
        test_b4 = get_blocks(4)

        assert_equal(test_b1, trueb1)
        assert_equal(test_b2, trueb2)
        assert_equal(test_b3, trueb3)
Exemplo n.º 2
0
    def test_get_blocks(self):
        """
        PIQS: Test the calculation of list of cumulative elements at each block.

        For N = 4

        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
        1 1 1 1 1
                1 1 1
                1 1 1
                1 1 1
                     1
        Thus, the blocks are [5, 8, 9] denoting that after the first block 5
        elements have been accounted for and so on.
        """
        trueb1 = [2]
        trueb2 = [3, 4]
        trueb3 = [4, 6]
        trueb4 = [5, 8, 9]

        test_b1 = get_blocks(1)
        test_b2 = get_blocks(2)
        test_b3 = get_blocks(3)
        test_b4 = get_blocks(4)

        assert_equal(test_b1, trueb1)
        assert_equal(test_b2, trueb2)
        assert_equal(test_b3, trueb3)
Exemplo n.º 3
0
    def test_get_index(self):
        """
        PIQS: Test the index fetching function for given j, m, m1 value.
        """
        N = 1
        jmm1_list = [(0.5, 0.5, 0.5), (0.5, 0.5, -0.5),
                     (0.5, -0.5, 0.5), (0.5, -0.5, -0.5)]
        indices = [(0, 0), (0, 1), (1, 0), (1, 1)]

        blocks = get_blocks(N)
        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
        N = 2
        blocks = get_blocks(N)
        jmm1_list = [(1, 1, 1), (1, 1, 0), (1, 1, -1),
                     (1, 0, 1), (1, 0, 0), (1, 0, -1),
                     (1, -1, 1), (1, -1, 0), (1, -1, -1),
                     (0, 0, 0)]
        indices = [(0, 0), (0, 1), (0, 2),
                   (1, 0), (1, 1), (1, 2),
                   (2, 0), (2, 1), (2, 2),
                   (3, 3)]
        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
        N = 3
        blocks = get_blocks(N)
        jmm1_list = [(1.5, 1.5, 1.5), (1.5, 1.5, 0.5), (1.5, 1.5, -0.5),
                     (1.5, 1.5, -1.5), (1.5, 0.5, 0.5), (1.5, -0.5, -0.5),
                     (1.5, -1.5, -1.5), (1.5, -1.5, 1.5), (0.5, 0.5, 0.5),
                     (0.5, 0.5, -0.5), (0.5, - 0.5, 0.5),
                     (0.5, -0.5, -0.5)]

        indices = [(0, 0), (0, 1), (0, 2), (0, 3),
                   (1, 1), (2, 2), (3, 3), (3, 0),
                   (4, 4), (4, 5),
                   (5, 4), (5, 5)]

        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
Exemplo n.º 4
0
    def test_get_index(self):
        """
        PIQS: Test the index fetching function for given j, m, m1 value.
        """
        N = 1
        jmm1_list = [(0.5, 0.5, 0.5), (0.5, 0.5, -0.5),
                     (0.5, -0.5, 0.5), (0.5, -0.5, -0.5)]
        indices = [(0, 0), (0, 1), (1, 0), (1, 1)]

        blocks = get_blocks(N)
        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
        N = 2
        blocks = get_blocks(N)
        jmm1_list = [(1, 1, 1), (1, 1, 0), (1, 1, -1),
                     (1, 0, 1), (1, 0, 0), (1, 0, -1),
                     (1, -1, 1), (1, -1, 0), (1, -1, -1),
                     (0, 0, 0)]
        indices = [(0, 0), (0, 1), (0, 2),
                   (1, 0), (1, 1), (1, 2),
                   (2, 0), (2, 1), (2, 2),
                   (3, 3)]
        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
        N = 3
        blocks = get_blocks(N)
        jmm1_list = [(1.5, 1.5, 1.5), (1.5, 1.5, 0.5), (1.5, 1.5, -0.5),
                     (1.5, 1.5, -1.5), (1.5, 0.5, 0.5), (1.5, -0.5, -0.5),
                     (1.5, -1.5, -1.5), (1.5, -1.5, 1.5), (0.5, 0.5, 0.5),
                     (0.5, 0.5, -0.5), (0.5, - 0.5, 0.5),
                     (0.5, -0.5, -0.5)]

        indices = [(0, 0), (0, 1), (0, 2), (0, 3),
                   (1, 1), (2, 2), (3, 3), (3, 0),
                   (4, 4), (4, 5),
                   (5, 4), (5, 5)]

        calculated_indices = [get_index(N, jmm1[0], jmm1[1],
                                        jmm1[2], blocks)
                              for jmm1 in jmm1_list]
        assert_array_almost_equal(calculated_indices, indices)
Exemplo n.º 5
0
 def test_get_blocks(self):
     """
     PIQS: Test the function to get blocks.
     """
     N_list = [1, 2, 5, 7]
     blocks = [np.array([2]), np.array([3, 4]), np.array([6, 10, 12]),
               np.array([8, 14, 18, 20])]
     calculated_blocks = [get_blocks(i) for i in N_list]
     for (i, j) in zip(calculated_blocks, blocks):
         assert_array_equal(i, j)
Exemplo n.º 6
0
 def test_get_blocks(self):
     """
     PIQS: Test the function to get blocks.
     """
     N_list = [1, 2, 5, 7]
     blocks = [np.array([2]), np.array([3, 4]), np.array([6, 10, 12]),
               np.array([8, 14, 18, 20])]
     calculated_blocks = [get_blocks(i) for i in N_list]
     for (i, j) in zip(calculated_blocks, blocks):
         assert_array_equal(i, j)