我有一个大小为(3997,29)的numpy数组(arr)。我正在使用这个数组来创建一个数据集。该数组具有整数和浮点变量。所以 dtype 是参考。但是当我执行它时,我得到以下错误。
“ValueError:不是位置 ID(无效的对象 ID)”
with h5py.File("test1.h5", 'w') as f:
grp = f.create_group('Nodes')
with h5py.File("test1.h5", 'r+') as f:
grp = f.require_group('Nodes')
ref_dtype = h5py.special_dtype(ref=h5py.Reference)
arrshape = np.shape(arr)
dset = grp.create_dataset('Init' ,arrshape, dtype = ref_dtype , data= arr)
错误发生在最后一行。以下是回溯消息
dset = f.create_dataset('Init' ,arrshape, dtype = ref_dtype , data= arr)
文件“C:\Users\rupesh.n\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py_hl\group.py”,第 108 行,在 create_dataset dsid = dataset.make_new_dset(self, shape, dtype, data , **kwds)
文件“C:\Users\rupesh.n\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py_hl\dataset.py”,第 137 行,在 make_new_dset dset_id = h5d.create(parent.id, None, tid , sid, dcpl=dcpl)
文件“h5py_objects.pyx”,第 54 行,在 h5py._objects.with_phil.wrapper
文件“h5py_objects.pyx”,第 55 行,在 h5py._objects.with_phil.wrapper 中
文件“h5py\h5d.pyx”,第 79 行,在 h5py.h5d.create
ValueError: Not a location id (Invalid object id)