예제 #1
0
 def test_no_land_mask(self):
     with mock.patch('numpy.frombuffer',
                     return_value=np.arange(3)):
         with self.assertRaises(ValueError) as err:
             pp._read_data_bytes(mock.Mock(), self.create_lbpack(120),
                                 (3, 4), np.dtype('>f4'),
                                 -999, mask=None)
         self.assertEqual(str(err.exception),
                          ('No mask was found to unpack the data. '
                           'Could not load.'))
예제 #2
0
 def check_read_data(self, field_data, lbpack, mask):
     # Calls pp._read_data_bytes with the necessary mocked items, an lbpack
     # instance, the correct data shape and mask instance.
     with mock.patch('numpy.frombuffer', return_value=field_data):
         return pp._read_data_bytes(mock.Mock(), self.create_lbpack(lbpack),
                                    mask.shape, np.dtype('>f4'),
                                    -999, mask=mask)
예제 #3
0
 def test_boundary_decompression(self):
     boundary_packing = mock.Mock(rim_width=4, x_halo=3, y_halo=2)
     lbpack = mock.Mock(n1=0, boundary_packing=boundary_packing)
     r = pp._read_data_bytes(self.data_payload_bytes, lbpack,
                             self.data_shape, self.decompressed.dtype, -99)
     self.assertMaskedArrayEqual(r, self.decompressed)