Exemplo n.º 1
0
 def test_covdict_apply_mask(self):
     msk = np.random.randint(0, 2, 2 * mpisize).reshape(1, -1)
     mskdict = Masks()
     comm.Bcast(msk, root=0)
     mskdict.append(('test', 'nan', str(2 * mpisize), 'nan'), msk, True)
     cov = np.random.rand(2, 2 * mpisize)
     covdict = Covariances()
     covdict.append(('test', 'nan', str(2 * mpisize), 'nan'), cov, True)
     covdict.apply_mask(mskdict)
     pix_num = msk.sum()
     self.assertTrue(('test', 'nan', str(pix_num), 'nan') in covdict.keys())
 def test_covdict_apply_mask(self):
     msk = np.array([0, 1, 0, 1, 1]).reshape(1, 5)
     mskdict = Masks()
     mskdict.append(('test', 'nan', '5', 'nan'), msk, True)
     cov_field = Field.from_global_data(RGSpace(shape=(5, 5)),
                                        np.random.rand(5, 5))
     arr = cov_field.local_data
     covdict = Covariances()
     covdict.append(('test', 'nan', '5', 'nan'), arr, True)
     covdict.apply_mask(mskdict)
     arr = np.delete(cov_field.to_global_data(), [0, 2], 0)
     arr = np.delete(arr, [0, 2], 1)
     for i in range(arr.shape[0]):
         self.assertListEqual(
             list((covdict[('test', 'nan', '3',
                            'nan')].to_global_data())[i]), list(arr[i]))