def test_accidental_combine(self): rle = [ codec.RunLength(value=0, length=14), codec.RunLength(value=31, length=0) ] invert = codec.decode_run_length(rle, 15) rle_2 = codec.run_length_coding(invert, max_len=0xF) self.assertEqual(rle, rle_2)
def test_rle_max_double(self): arr = [-1, 0, 0, 0, 0, 1, 2] rle = codec.run_length_coding(np.array(arr), max_len=4) invert = codec.decode_run_length(rle, len(arr)) self.assertEqual(arr, invert)
def test_rle_break_plus_1(self): arr = [0, 0, 0, 0, 0, 1] rle = codec.run_length_coding(np.array(arr), max_len=4) invert = codec.decode_run_length(rle, len(arr)) self.assertEqual(invert, arr)
def test_rle_random(self): arr = [np.random.randint(-5, 5) for _ in range(10000)] rle = codec.run_length_coding(np.array(arr)) invert = codec.decode_run_length(rle, 10000) self.assertEqual(invert, arr)
def test_rle_consecutives(self): arr = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0] rle = codec.run_length_coding(np.array(arr)) invert = codec.decode_run_length(rle, len(arr)) self.assertEqual(invert, arr)
def test_rle_max_len(self): arr = [0, 0, 0, 0, 0, 1] rle = codec.run_length_coding(np.array(arr)) invert = codec.decode_run_length(rle, len(arr)) self.assertEqual(arr, invert)
def test_zero_block_reconstruct(self): matrix = np.array([[0, 0, 11, 0], [0, 0, 0, 0]]) lin = transform.zigzag(matrix) out = codec.run_length_coding(lin) invert = codec.decode_run_length(out, 8) self.assertEqual(lin, invert)