示例#1
0
 def test_mdi_larger(self):
     # Check that everything still works if the compressed data are
     # *larger* than the original data.
     data = np.arange(12, dtype=np.float32).reshape(3, 4) + 5
     data[data % 2 == 0] = 666
     with self.assertRaises(ValueError):
         compress_rle(data, missing_data_indicator=666)
示例#2
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)
示例#3
0
 def test_mdi(self):
     data = np.arange(12, dtype=np.float32).reshape(3, 4) + 5
     data[1, 1:] = 999
     compressed_data = compress_rle(data, missing_data_indicator=999)
     expected = np.array([5, 6, 7, 8, 9, 999, 3, 13, 14, 15, 16],
                              dtype='f4')
     expected.byteswap(True)
     self.assertEqual(compressed_data, expected.data)
示例#4
0
 def test_no_mdi(self):
     data = np.arange(42, dtype=np.float32).reshape(7, 6)
     compressed_data = compress_rle(data)
     expected = np.arange(42, dtype='f4')
     expected.byteswap(True)
     self.assertEqual(compressed_data, expected.data)
示例#5
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)