Esempio n. 1
0
 def test_clean_reg_refs_2d(self):
     file_path = 'test.h5'
     data_utils.delete_existing_file(file_path)
     with h5py.File(file_path, mode='w') as h5_f:
         h5_dset = h5_f.create_dataset('Test', data=np.random.rand(7, 5))
         ref_in = (slice(0, None, 2), slice(None))
         cleaned = reg_ref.clean_reg_ref(h5_dset, ref_in)
         self.assertTrue(np.all([x == y for x, y in zip(ref_in, cleaned)]))
     os.remove(file_path)
Esempio n. 2
0
 def test_clean_reg_refs_1d(self):
     file_path = 'test.h5'
     data_utils.delete_existing_file(file_path)
     with h5py.File(file_path, mode='w') as h5_f:
         h5_dset = h5_f.create_dataset('Test', data=np.random.rand(7))
         ref_in = (slice(0, None, 2))
         cleaned = reg_ref.clean_reg_ref(h5_dset, ref_in)
         self.assertEqual(ref_in, cleaned[0])
     os.remove(file_path)
Esempio n. 3
0
    def test_clean_reg_refs_illegal_too_few_slices(self):
        file_path = 'test.h5'
        data_utils.delete_existing_file(file_path)
        with h5py.File(file_path, mode='w') as h5_f:
            h5_dset = h5_f.create_dataset('Test', data=np.random.rand(7, 5))
            ref_in = (slice(0, None, 2))
            with self.assertRaises(ValueError):
                _ = reg_ref.clean_reg_ref(h5_dset, ref_in)

        os.remove(file_path)
Esempio n. 4
0
 def test_clean_reg_refs_out_of_bounds(self):
     file_path = 'test.h5'
     data_utils.delete_existing_file(file_path)
     with h5py.File(file_path, mode='w') as h5_f:
         h5_dset = h5_f.create_dataset('Test', data=np.random.rand(7, 5))
         ref_in = (slice(0, 13, 2), slice(None))
         expected = (slice(0, 7, 2), slice(None))
         cleaned = reg_ref.clean_reg_ref(h5_dset, ref_in, verbose=False)
         self.assertTrue(np.all([x == y
                                 for x, y in zip(expected, cleaned)]))
     os.remove(file_path)