diff --git a/odl/space/npy_tensors.py b/odl/space/npy_tensors.py index 9f86ad0cbdd..2b363fe6758 100644 --- a/odl/space/npy_tensors.py +++ b/odl/space/npy_tensors.py @@ -2606,12 +2606,14 @@ def __hash__(self): def repr_part(self): """String usable in a space's ``__repr__`` method.""" max_elems = 2 * np.get_printoptions()['edgeitems'] + precision = np.get_printoptions()['precision'] def factors_repr(factors): factor_strs = [] for fac in factors: if fac.ndim == 0: - factor_strs.append('{:.4}'.format(float(fac))) + fmt = '{{:{}}}'.format(precision) + factor_strs.append(fmt.format(float(fac))) else: factor_strs.append(array_str(fac, nprint=max_elems)) if len(factor_strs) == 1: @@ -2633,12 +2635,14 @@ def factors_repr(factors): def __repr__(self): """Return ``repr(self)``.""" max_elems = 2 * np.get_printoptions()['edgeitems'] + precision = np.get_printoptions()['precision'] def factors_repr(factors): factor_strs = [] for fac in factors: if fac.ndim == 0: - factor_strs.append('{:.4}'.format(float(fac))) + fmt = '{{:{}}}'.format(precision) + factor_strs.append(fmt.format(float(fac))) else: factor_strs.append(array_str(fac, nprint=max_elems)) return '({})'.format(', '.join(factor_strs))