# Revision history [back]

### Save tensor in file

I define the following $3+1$ manifold and chart:

n = 3
M = Manifold(1+n, 'M', structure='Lorentzian')
X.<t,r,th,ph> = M.chart(r"t r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi")


with a variable $eps$ and function $h$:

eps = var('eps')
h = function('h')(r,th)


The metric of this space is:

gdd = M.metric()

gdd[0,0] = -eps;    gdd[1,1] = r;    gdd[2,2] = h;    gdd[3,3] = 1


With this metric, I calculate numerous tensors (Riemann, Ricci, ...), which take a long time to compute. Therefore, I would like to save those tensors in a single file and then import them back every time I need them. I have tried using

np.save('file.npy', gdd)

but when I open file.npy I read the following:

Error! /Users/.../file.npy is not UTF-8 encoded

Is there a way I can save various symbolic tensors (which depend on functions and variables, as the one shown above) in a file, and load them back separately?