コード例 #1
0
ファイル: text_hw6.py プロジェクト: joshgrib/cs115
 def test01(self):
     sequence = '0' * 64
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '1111100000111110000000010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.390625, 4)
コード例 #2
0
ファイル: text_hw6.py プロジェクト: joshgrib/cs115
 def test03(self):
     sequence = '10' * 32
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '0000000001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 5.078125, 4)
コード例 #3
0
 def test07(self):
         sequence = "0"*8 + "01100110"*2 + "0"*8 + "00001000" + "01000010" + "01111110" + "0"*8
         compress = hw6.compress(sequence)
         self.assertEqual(compress, '0100100010000100001000010000100001000010011010000100100000010010000001000100011001001')
         uncompress = hw6.uncompress(compress)
         self.assertEqual(uncompress, sequence)
         self.assertAlmostEqual(hw6.compression(sequence), 1.328125, 4)
コード例 #4
0
 def test08(self):
         sequence = "00011000"+"00111100"*3 + "01111110"+"11111111"+"00111100"+"00100100" 
         compress = hw6.compress(sequence)
         self.assertEqual(compress, '00011000100010100100001000010000100001000001100110000010100000010001000010000001000100000100010')
         uncompress = hw6.uncompress(compress)
         self.assertEqual(uncompress, sequence)
         self.assertAlmostEqual(hw6.compression(sequence), 1.484375, 4)
コード例 #5
0
ファイル: test_hw6.py プロジェクト: EliasFrieling/CS115
 def test08(self):
     sequence = '100000000'*7+'1'
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '00000000010100000001010000000101000000010100000001010000000101000000010100000001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 1.25, 4)  
コード例 #6
0
 def test08(self):
     sequence = '0011' * 16
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '00010' * 32)
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 2.5, 4)
コード例 #7
0
 def test09(self):
     sequence = five
     compress = hw6.compress(five)
     self.assertEqual(compress, '00000010010011100001001110000100111001110100000001001110100000001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(five), 1.015625, 4)
コード例 #8
0
 def test08(self):
     sequence = smile
     compress = hw6.compress(smile)
     self.assertEqual(compress, '0100100010000100001000010000100001000010011010000100100000010010000001000100011001001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(smile), 1.328125, 4)
コード例 #9
0
 def test07(self):
     sequence = penguin
     compress = hw6.compress(penguin)
     self.assertEqual(compress, '00011000100010100100001000010000100001000001100110000010100000010001000010000001000100000100010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(penguin), 1.484375, 4)
コード例 #10
0
ファイル: text_hw6.py プロジェクト: joshgrib/cs115
 def test05(self):
     sequence = '0' * (hw6.MAX_RUN_LENGTH + 1) + '1' * (hw6.MAX_RUN_LENGTH + 1) + '0' * (64 - 2 * hw6.MAX_RUN_LENGTH - 2)
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '111110000000001111110000000001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.46875, 4)
コード例 #11
0
ファイル: text_hw6.py プロジェクト: joshgrib/cs115
 def test06(self):
     sequence = '0' * hw6.MAX_RUN_LENGTH + '1' * hw6.MAX_RUN_LENGTH + '0' * (64 - 2 * hw6.MAX_RUN_LENGTH)
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '111111111100010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.234375, 4)
コード例 #12
0
 def test01(self):
     sequence = '0' * 64
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '1111100000111110000000010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.390625, 4)
コード例 #13
0
 def test08(self):
     sequence = '11' * 32
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '000001111100000111110000000010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.46875, 4)
コード例 #14
0
ファイル: test_hw6.py プロジェクト: ztalarick/School
 def test07(self):
     sequence = '00111'
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '0001000011')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 2, 4)
コード例 #15
0
ファイル: test_hw6.py プロジェクト: bharddwaj/Intro-CS-Course
 def test06(self):
     sequence = '1' * hw6.MAX_RUN_LENGTH + '0' * hw6.MAX_RUN_LENGTH + '1' * (64 - 2 * hw6.MAX_RUN_LENGTH)
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '00000111111111100010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.3125, 4)
コード例 #16
0
ファイル: test_hw6.py プロジェクト: bharddwaj/Intro-CS-Course
 def test08(self):
     sequence = '0'*4 + '1'*8 + '0'*6
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '001000100000110')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 15/18, 4)
コード例 #17
0
ファイル: test_hw6.py プロジェクト: bharddwaj/Intro-CS-Course
 def test03(self):
     sequence = '10' * 32
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '0000000001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001000010000100001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 5.078125, 4)
コード例 #18
0
ファイル: test_hw6.py プロジェクト: bharddwaj/Intro-CS-Course
 def test05(self):
     sequence = '0' * (hw6.MAX_RUN_LENGTH + 1) + '1' * (hw6.MAX_RUN_LENGTH + 1) + '0' * (64 - 2 * hw6.MAX_RUN_LENGTH - 2)
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '111110000000001111110000000001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.46875, 4)
コード例 #19
0
 def test08(self):
     sequence = "1"*10 + "0"*8 + "10000000"*3 + "1"*8 + "0" + "00000001"*3 + "1"*8 + "0"
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '0000001010010000000100111000010011100001001110100001000000010011100001001110100100001')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 1.0119047619047619, 4)
コード例 #20
0
 def test07(self):
     sequence = "0"*9 + "01100110"*3 + "0"*9 + "00001000" + "01000010" + "01111110" + "0"*9
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '010100001000010000100001000010000100001000010000100001000010011100000100100000010010000001000100011001010')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 1.4, 4)
コード例 #21
0
 def test08(self):
     sequence = '0' * 6 + '1' * 10 + '0' * 9 + '1' * 4
     compress = hw6.compress(sequence)
     self.assertEqual(compress, '00110010100100100100')
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 0.6896551724137931,
                            4)
コード例 #22
0
 def test08(self):
     sequence = '101' * 16
     compress = hw6.compress(sequence)
     self.assertEqual(
         compress,
         '00000000010000100010000010001000001000100000100010000010001000001000100000100010000010001000001000100000100010000010001000001000100000100010000010001000001000100000100001'
     )
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 3.5417, 4)
コード例 #23
0
ファイル: test_hw6.py プロジェクト: jschmidtnj/CS115
 def test08(self):
     """tested a second different checkerboard"""
     sequence = '0100100111' * 8
     compress = hw6.compress(sequence)
     self.assertEqual(
         compress,
         '000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011000010000100010000010001000011'
     )
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 3.0, 4)
コード例 #24
0
ファイル: test_hw6.py プロジェクト: jschmidtnj/CS115
 def test07(self):
     """tested one random checkerboard"""
     sequence = '01' * 8
     compress = hw6.compress(sequence)
     self.assertEqual(
         compress,
         '00001000010000100001000010000100001000010000100001000010000100001000010000100001'
     )
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 5.0, 4)
コード例 #25
0
ファイル: test_hw6.py プロジェクト: jschmidtnj/CS115
 def test11(self):
     """testing the five"""
     sequence = "1" * 9 + "0" * 7 + "10000000" * 2 + "1" * 7 + "0" + "00000001" * 2 + "1" * 7 + "0"
     compress = hw6.compress(sequence)
     self.assertEqual(
         compress,
         '00000010010011100001001110000100111001110100000001001110100000001'
     )
     uncompress = hw6.uncompress(compress)
     self.assertEqual(uncompress, sequence)
     self.assertAlmostEqual(hw6.compression(sequence), 1.015625, 4)