I seem to be hitting a wall on what is likely a very simple issue to solve. I have saved out a *.npz file containing a single variable--an object of class Network (a class I wrote).
# Initialize network
burstNetwork = Network(numChs,dt,UFRs,NBPs,BDs,UFRsByChan,varyFRbyChs,minChConstBurst,createChCorrelations)
if saveData:
pd.np.savez((saveDir + "simulator.npz"), burstNetwork=burstNetwork)
# Load network
simulator = np.load(simFilesDir + "simulator.npz")
network = simulator['burstNetwork']
network
Out[43]: array(<__main__.Network object at 0x000000000AEF0C18>, dtype=object)
network[0]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-44-297be643431d> in <module>()
----> 1 network[0]
IndexError: too many indices for array
When indexing an array you need a tuple that matches the dimensions in length. This is 0d, so the tuple has to be 0 length, ()
. The item
method also works.
In [922]: arr = np.array(1, dtype=object)
In [923]: arr.shape
Out[923]: ()
In [924]: arr
Out[924]: array(1, dtype=object)
In [925]: arr.item()
Out[925]: 1
In [926]: arr[()]
Out[926]: 1