I have an numpy array(arr) of size (3997,29). I am using this array to create a dataset. This array has both integer and float variables. So dtype is reference. But when I execute it I get the below error.
"ValueError: Not a location id (Invalid object 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)
The error occurs in the last line. Below are the traceback messages
dset = f.create_dataset('Init' ,arrshape, dtype = ref_dtype , data= arr)
File "C:\Users\rupesh.n\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py\_hl\group.py", line 108, in create_dataset
dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds)
File "C:\Users\rupesh.n\AppData\Local\Continuum\anaconda3\lib\site-packages\h5py\_hl\dataset.py", line 137, in make_new_dset
dset_id = h5d.create(parent.id, None, tid, sid, dcpl=dcpl)
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5d.pyx", line 79, in h5py.h5d.create
ValueError: Not a location id (Invalid object id)
f
is not open when you try to accessgrp
, and that theinvalid object id
refers togrp
. For more than guesses we need a minimal reproducible example. – Opposition