Ejemplo n.º 1
0
 def _test(self, original, rows, cols):
     compressed_data = compress_rle(original, missing_data_indicator=MDI)
     result = decompress_rle(compressed_data,
                             rows,
                             cols,
                             missing_data_indicator=MDI)
     assert_array_equal(result, original)
Ejemplo n.º 2
0
 def test_mdi(self):
     # The input to decompress_rle must be big-endian 32-bit floats.
     src_floats = np.arange(11, dtype='>f4')
     src_floats[5] = 666
     src_floats[6] = 3
     src_buffer = src_floats.data
     result = decompress_rle(src_buffer, 3, 4, missing_data_indicator=666)
     assert_array_equal(result,
                        [[0, 1, 2, 3], [4, 666, 666, 666], [7, 8, 9, 10]])
Ejemplo n.º 3
0
 def test_mdi(self):
     # The input to decompress_rle must be big-endian 32-bit floats.
     src_floats = np.arange(11, dtype='>f4')
     src_floats[5] = 666
     src_floats[6] = 3
     src_buffer = src_floats.data
     result = decompress_rle(src_buffer, 3, 4, missing_data_indicator=666)
     assert_array_equal(result, [[0, 1, 2, 3],
                                 [4, 666, 666, 666],
                                 [7, 8, 9, 10]])
Ejemplo n.º 4
0
 def test_too_much_source_data(self):
     src_buffer = np.arange(10, dtype='>f4').data
     with self.assertRaises(ValueError):
         decompress_rle(src_buffer, 2, 3)
Ejemplo n.º 5
0
 def test_not_enough_source_data(self):
     src_buffer = np.arange(4, dtype='>f4').data
     with self.assertRaises(ValueError):
         decompress_rle(src_buffer, 5, 6)
Ejemplo n.º 6
0
 def test_no_mdi(self):
     # The input to decompress_rle must be big-endian 32-bit floats.
     src_buffer = np.arange(12, dtype='>f4').data
     result = decompress_rle(src_buffer, 3, 4)
     assert_array_equal(result, np.arange(12).reshape(3, 4))
     self.assertEqual(result.dtype, '=f4')
Ejemplo n.º 7
0
 def _test(self, original, rows, cols):
     compressed_data = compress_rle(original, missing_data_indicator=MDI)
     result = decompress_rle(compressed_data, rows, cols,
                             missing_data_indicator=MDI)
     assert_array_equal(result, original)
Ejemplo n.º 8
0
 def test_too_much_source_data(self):
     src_buffer = np.arange(10, dtype='>f4').data
     with self.assertRaises(ValueError):
         decompress_rle(src_buffer, 2, 3)
Ejemplo n.º 9
0
 def test_not_enough_source_data(self):
     src_buffer = np.arange(4, dtype='>f4').data
     with self.assertRaises(ValueError):
         decompress_rle(src_buffer, 5, 6)
Ejemplo n.º 10
0
 def test_no_mdi(self):
     # The input to decompress_rle must be big-endian 32-bit floats.
     src_buffer = np.arange(12, dtype='>f4').data
     result = decompress_rle(src_buffer, 3, 4)
     assert_array_equal(result, np.arange(12).reshape(3, 4))
     self.assertEqual(result.dtype, '=f4')