When you save a Python object (non-array), numpy wraps it in an array. The object is pickled:
In [112]: np.save('test.npy', {'foo':34})
In newer numpy versions, you have to explicitly allow it to load pickled items:
In [113]: data = np.load('test.npy')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-113-c5835e6fb31e> in <module>
----> 1 data = np.load('test.npy')
/usr/local/lib/python3.6/dist-packages/numpy/lib/npyio.py in load(file, mmap_mode, allow_pickle, fix_imports, encoding)
451 else:
452 return format.read_array(fid, allow_pickle=allow_pickle,
--> 453 pickle_kwargs=pickle_kwargs)
454 else:
455 # Try a pickle
/usr/local/lib/python3.6/dist-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
720 # The array contained Python objects. We need to unpickle the data.
721 if not allow_pickle:
--> 722 raise ValueError("Object arrays cannot be loaded when "
723 "allow_pickle=False")
724 if pickle_kwargs is None:
ValueError: Object arrays cannot be loaded when allow_pickle=False
In [115]: data = np.load('test.npy',allow_pickle=True)
In [116]: data
The result is an object dtype array with 1 element (0d)
Out[116]: array({'foo': 34}, dtype=object)
tolist can extract that object, as will item().
In [117]: data.tolist()
Out[117]: {'foo': 34}
In [118]: data.tolist()['foo']
Out[118]: 34
In [119]: data.item()
Out[119]: {'foo': 34}
In [120]: data[()]
Out[120]: {'foo': 34}
{'val1':0,'val2':1}, is a dictionary, not a structured array. If you do have one please share a MCVE