Esempio 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)
Esempio 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]])
Esempio 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]])
Esempio 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)
Esempio 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)
Esempio 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')
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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')