예제 #1
0
 def test_puncture(self):
     """Test to puncture of a code."""
     rm14_puncture = Matrix([
         0b0111011100111110,
         0b0000000000111110,
         0b0000011100001110,
         0b0011001100110010,
         0b0101010100010100,
         ], 16)
     self.assertEqual(
         tools.puncture(self.rm14_add, columns=(0, 4, 8, 9, 15)),
         rm14_puncture.diagonal_form)
     self.assertEqual(
         tools.puncture(self.rm14_add,
                        columns=(0, 4, 8, 9, 15),
                        remove_zeroes=True),
         rm14_puncture.submatrix(
             (i for i in range(16)
              if i not in [0, 4, 8, 9, 15])).diagonal_form)
예제 #2
0
 def test_truncate(self):
     """Test to truncate of a code."""
     rm14_trunc = Matrix([
         0b0000111100001111,
         0b0000000011111111,
         ], 16)
     # print()
     # print(tools.truncate(self.rm14_add, columns=(0, 1, 2)))
     self.assertEqual(
         tools.truncate(self.rm14_add, columns=(0, 4, 8, 9, 15)),
         Matrix())
     self.assertEqual(
         tools.truncate(self.rm14_add, columns=(0, 1, 2, 3)),
         rm14_trunc)
     self.assertEqual(
         tools.truncate(self.rm14_add,
                        columns=(0, 4, 8, 9, 15),
                        remove_zeroes=True),
         Matrix())
     self.assertEqual(
         tools.truncate(self.rm14_add,
                        columns=(0, 1, 2, 3),
                        remove_zeroes=True),
         rm14_trunc.submatrix(range(4, 16)))