def savez(d, filename, addext=True):
    if addext:
        filename = filename + '.ndict.tar.gz'
    fname1 = 'arrays.npz'
    fname2 = 'names.txt'
    _d = ordered(d)
    # Write values (arrays)
    np.savez(filename+'.'+fname1, *_d.values())
    # Write keys (names of arrays)
    with open(filename+'.'+fname2, 'w') as thefile:
        for key in _d.keys(): thefile.write(key % "%s\n")
    # Write TAR file
    tar = tarfile.open(filename, "w:gz")
    for fname in [fname1, fname2]:
        tar.add(filename+'.'+fname, fname)
        os.remove(filename+'.'+fname)
    tar.close()

# Loads ndict from file written with savez
dataset/ETHPy150Open dpkingma/nips14-ssl/anglepy/ndict.py/savez/swapped operands of `%`