def test_r_plus(self): with h5py.File(data_utils.std_beps_path, mode='r+') as h5_f: h5_group = h5_f['/Raw_Measurement'] h5_main = h5_f['/Raw_Measurement/Ancillary'] self.assertTrue(hdf_utils.is_editable_h5(h5_group)) self.assertTrue(hdf_utils.is_editable_h5(h5_f)) self.assertTrue(hdf_utils.is_editable_h5(h5_main))
def test_w(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.arange(3)) h5_group = h5_f.create_group('blah') self.assertTrue(hdf_utils.is_editable_h5(h5_group)) self.assertTrue(hdf_utils.is_editable_h5(h5_f)) self.assertTrue(hdf_utils.is_editable_h5(h5_dset)) os.remove(file_path)
def test_closed_file(self): with h5py.File(data_utils.std_beps_path, mode='r+') as h5_f: h5_group = h5_f['/Raw_Measurement'] with self.assertRaises(ValueError): _ = hdf_utils.is_editable_h5(h5_group)
def test_invalid_type(self): # wrong kind of object with self.assertRaises(TypeError): _ = hdf_utils.is_editable_h5(np.arange(4))