1
0
forked from IPKM/nmreval

set precision when saving data; fixes T253

This commit is contained in:
Dominik Demuth 2023-01-13 18:53:23 +01:00
parent 34ebaf34bd
commit 0e62f01103

View File

@ -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(),