diff --git a/pyproject.toml b/pyproject.toml index cfa5f73..280d899 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,7 @@ classifiers = [ requires-python = ">=3.10" dependencies = [ "asteval", - "bumps", + "bumps<1.0.0", "DFO-LS", "lmfit", "numpy", diff --git a/src/easyscience/variable/descriptor_number.py b/src/easyscience/variable/descriptor_number.py index 1b1e257..66f0e7a 100644 --- a/src/easyscience/variable/descriptor_number.py +++ b/src/easyscience/variable/descriptor_number.py @@ -299,9 +299,15 @@ def __repr__(self) -> str: string = '<' string += self.__class__.__name__ + ' ' string += f"'{self._name}': " - string += f'{self._scalar.value:.4f}' - if self.variance: - string += f' \u00b1 {self.error:.4f}' + if np.abs(self._scalar.value)>1e4 or (np.abs(self._scalar.value)<1e-4 and self._scalar.value != 0): + # Use scientific notation for large or small values + string += f'{self._scalar.value:.3e}' + if self.variance: + string += f' \u00b1 {self.error:.3e}' + else: + string += f'{self._scalar.value:.4f}' + if self.variance: + string += f' \u00b1 {self.error:.4f}' obj_unit = self._scalar.unit if obj_unit == 'dimensionless': obj_unit = '' @@ -485,4 +491,4 @@ def _base_unit(self) -> str: return string[i:] elif letter not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '+', '-']: return string[i:] - return '' \ No newline at end of file + return ''