def fit_report(group, show_correl=True, min_correl=0.1, precision=None,
               _larch=None, **kws):
    """print report of fit statistics given 'fit parameter group'
    """
    if not _larch.symtable.isgroup(group):
        print('must pass Group to fit_report()')
        return
    _larch.symtable._sys.paramGroup = group

    topline = '===================== FIT RESULTS ====================='
    header = '[[%s]] %s'
    exprformat = '   %12s = %s = \'%s\''
    out = [topline]

    varformat  = '   %12s = %s (init= % f)'
    fmt_sca = "% f"
    fmt_err = "% f +/- %f"
    if precision is not None:
        varformat  = '   %%12s = %%s (init= %% .%if)' % precision
        fmt_sca = "%% .%if" % precision
        fmt_err = "%% .%if +/- %%.%if" % (precision, precision)

    npts = len(group.residual)
    ofit = getattr(group, 'fit_details', None)
    if ofit is None:  ofit = group
    methodname = getattr(ofit, 'method', 'leastsq')
    success = getattr(ofit, 'success', False)

    if success:
        subtitle = '   Fit succeeded, '
    else:
        subtitle = '   Fit Failed, '
    subtitle = "%s method = '%s'." % (subtitle, methodname)
    out.append(header % ('Statistics', subtitle))

    if hasattr(group, 'message'):
        out.append('   Message from fit    = %s' % (group.message))

    out.append('   npts, nvarys, nfree = %i, %i, %i' % (npts,
                                                        group.nvarys,
                                                        group.nfree))

    if hasattr(ofit, 'nfev'):
        out.append('   nfev (func calls)   = %i' % (ofit.nfev))
    if hasattr(group, 'chi_square'):
        out.append(('   chi_square          = %s' % fmt_sca) %
                   (group.chi_square))
    if hasattr(group, 'chi_reduced'):
        out.append(('   reduced chi_square  = %s' % fmt_sca) %
                   (group.chi_reduced))
    out.append(' ')
    out.append(header % ('Variables',''))
    exprs = []
    for name in dir(group):
        var = getattr(group, name)
        if len(name) < 14:
            name = (name + ' '*14)[:14]
        if isParameter(var):
            sval = fmt_sca % var.value
            if var.stderr is not None:
                sval = fmt_err % (var.value, var.stderr)
            if var.vary:
                out.append(varformat % (name, sval, var._initval))
            elif var.expr is not None:
                exprs.append(exprformat % (name, sval, var.expr))

    if len(exprs) > 0:
        out.append(header % ('Constraint Expressions', ''))
        out.extend(exprs)

    covar_vars = getattr(group, 'covar_vars', [])
    if show_correl and len(covar_vars) > 0:
        subtitle = '    (unreported correlations are < % .3f)' % min_correl
        out.append(' ')
        out.append(header % ('Correlations', subtitle))
        correls = {}
        for i, name in enumerate(covar_vars):
            par = getattr(group, name)
            if not par.vary:
                continue
            if hasattr(par, 'correl') and par.correl is not None:
                for name2 in covar_vars[i+1:]:
                    if name != name2 and name2 in par.correl:
                        correls["%s, %s" % (name, name2)] = par.correl[name2]

        sort_correl = sorted(correls.items(), key=lambda it: abs(it[1]))
        sort_correl.reverse()
        for name, val in sort_correl:
            if abs(val) < min_correl:
                break
            if 20 < len(name):
                name = (name + ' '*20)[:20]
            out.append('   %s = % .3f ' % (name, val))
    out.append('='*len(topline))
    return '\n'.join(out)
dataset/ETHPy150Open xraypy/xraylarch/lib/fitting/minimizer.py/fit_report/swapped operands of `<`