From 0e62f0110385dbbc1358480fd3a3ebf7e0746534 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Fri, 13 Jan 2023 18:53:23 +0100 Subject: [PATCH] set precision when saving data; fixes T253 --- src/nmreval/data/points.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nmreval/data/points.py b/src/nmreval/data/points.py index 35d8403..3282627 100644 --- a/src/nmreval/data/points.py +++ b/src/nmreval/data/points.py @@ -648,19 +648,19 @@ class Points: header = [] for k, v in self.meta.items(): - header.append('%s: %s' % (k, str(v))) + header.append(f'{k}: {v}') header = '\n'.join(header) if np.all(self.mask): - np.savetxt(path, self.toarray(err=err), header=header, fmt='%.10f') + np.savetxt(path, self.toarray(err=err), header=header, fmt='%.10e') else: with path.open('w') as f: f.write(header) for i, l in enumerate(self.toarray(err=err)): if self.mask[i]: - f.write('\t'.join(map(str, l.tolist())) + '\n') + f.write('\t'.join(map(lambda _x: f'{_x:.10e}', l.tolist())) + '\n') else: - f.write('#' + '\t'.join(map(str, l.tolist())) + '\n') + f.write('#' + '\t'.join(map(lambda _x: f'{_x:.10e}', l.tolist())) + '\n') def get_state(self) -> dict: ret_dic = {'x': self._x.tolist(),