Skip to content

Commit f3ff2d1

Browse files
committed
Use same float formatting that Qt uses
This was the default formatting that Qt was using before for floats. This keeps us from accidentally rounding smaller numbers to zero, like the anisotropic broadening parameters, which are often on the order of 1e-4. Signed-off-by: Patrick Avery <[email protected]>
1 parent e1ec5ad commit f3ff2d1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hexrdgui/calibration/tree_item_models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ def data(self, index, role):
131131
config = self.config_path(path)
132132

133133
if role == Qt.DisplayRole and config.get('_units'):
134-
if isinstance(data, float):
135-
# Make sure it is rounded to 3 decimal places
136-
data = round(data, 3)
137-
138-
# Don't attach units to infinity
139134
is_inf = isinstance(data, float) and np.isinf(data)
135+
# Don't attach units to infinity
140136
if not is_inf:
137+
if isinstance(data, float):
138+
# Format it into a string
139+
data = f'{data:.6g}'
140+
141141
data = f"{data}{config['_units']}"
142142

143143
return data

0 commit comments

Comments
 (0)