@askewchan, np.savez( "tmp.npz", data=data, **d )?
import numpy as np
data = np.arange( 3 )
time = 23.5
position = [[23, 54], None]
d = dict( TIME=time, POSITION=position )
np.savez( "tmp.npz", data=data, **d )
d = np.load( "tmp.npz" )
for key, val in sorted( d.items() ):
print key, type(val), val
,
class Bag ,
bag.<tab> IPython:
class Bag( dict ):
""" a dict with d.key short for d["key"]
d = Bag( k=v ... / **dict / dict.items() / [(k,v) ...] ) just like dict
"""
def __init__(self, *args, **kwargs):
dict.__init__( self, *args, **kwargs )
self.__dict__ = self
def __getnewargs__(self):
return tuple(self)
d = Bag( np.load( "tmp.npz" ))
if d.TIME > 0:
print "time %g position %s" % (d.TIME, d.POSITION)