diff --git a/tensorbackends/backends/ctf/ctf_backend.py b/tensorbackends/backends/ctf/ctf_backend.py index 3bd749a..35f8590 100644 --- a/tensorbackends/backends/ctf/ctf_backend.py +++ b/tensorbackends/backends/ctf/ctf_backend.py @@ -62,6 +62,13 @@ def ndim(self, a): def copy(self, a): return a.copy() + def save(self, tsr, filename): + with open(filename, 'w+b') as file: + np.save(file, tsr.numpy(), allow_pickle=False) + + def load(self, filename): + return self.astensor(np.load(filename)) + def einsum(self, subscripts, *operands): if not all(isinstance(operand, self.tensor) for operand in operands): raise TypeError('all operands should be {}'.format(self.tensor.__qualname__)) diff --git a/tensorbackends/backends/ctfview/ctfview_backend.py b/tensorbackends/backends/ctfview/ctfview_backend.py index b5e5b98..ee82f37 100644 --- a/tensorbackends/backends/ctfview/ctfview_backend.py +++ b/tensorbackends/backends/ctfview/ctfview_backend.py @@ -63,6 +63,13 @@ def ndim(self, a): def copy(self, a): return a.copy() + def save(self, tsr, filename): + with open(filename, 'w+b') as file: + np.save(file, tsr.numpy(), allow_pickle=False) + + def load(self, filename): + return self.astensor(np.load(filename)) + def reshape(self, a, newshape): return a.reshape(*newshape)