Skip to content

Commit 39e3fb3

Browse files
committed
try hard to do sigfigs on string values
1 parent 8f26507 commit 39e3fb3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

probscale/formatters.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def _sig_figs(cls, x, n, expthresh=5, forceint=False):
3737
"""
3838

3939
# return a string value unaltered
40-
if isinstance(x, str) or x == 0.0:
41-
out = str(x)
40+
if isinstance(x, str):
41+
out = cls._sig_figs(float(x), n, expthresh=expthresh, forceint=forceint)
42+
43+
elif x == 0.0:
44+
out = '0'
4245

4346
# check on the number provided
44-
elif x is not None and not numpy.isinf(x) and not numpy.isnan(x):
47+
elif x is not None and numpy.isfinite(x):
4548

4649
# check on the _sig_figs
4750
if n < 1:

0 commit comments

Comments
 (0)