Skip to content

Commit

Permalink
Merge pull request #461 from lmfit/stats_with_gformat
Browse files Browse the repository at this point in the history
use gformat for fit statistics
  • Loading branch information
newville authored Mar 19, 2018
2 parents 7b6bbaf + cffdab4 commit cd02480
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lmfit/printfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def alphanumeric_sort(s, _nsre=re.compile('([0-9]+)')):
for text in re.split(_nsre, s)]


def getfloat_attr(obj, attr, fmt='%.5f'):
def getfloat_attr(obj, attr, length=11):
"""Format an attribute of an object for printing."""
val = getattr(obj, attr, None)
if val is None:
return 'unknown'
elif isinstance(val, int):
return '%d' % val
elif isinstance(val, float):
return fmt % val
return gformat(val, length=length).strip()
return repr(val)


Expand Down

0 comments on commit cd02480

Please sign in to comment.