def format(self, maxline=<NUM_LIT:0>, pstyle='<STR_LIT:v>', nline=None, extend=True):
<EOL>if nline is not None and maxline == <NUM_LIT:0>:<EOL><INDENT>maxline = nline         <EOL><DEDENT>if maxline is True:<EOL><INDENT>maxline = sys.maxsize<EOL><DEDENT>if maxline is False or maxline is None:<EOL><INDENT>maxline = -<NUM_LIT:1><EOL><DEDENT>if pstyle is not None:<EOL><INDENT>if pstyle[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>pstyle = '<STR_LIT>'<EOL><DEDENT>elif pstyle[:<NUM_LIT:1>] == '<STR_LIT:v>':<EOL><INDENT>pstyle = '<STR_LIT:v>'<EOL><DEDENT>elif pstyle[:<NUM_LIT:1>] == '<STR_LIT:m>':<EOL><INDENT>pstyle = '<STR_LIT:m>'<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>"+str(pstyle))<EOL><DEDENT><DEDENT>def collect(v1, v2, style='<STR_LIT:v>', stride=<NUM_LIT:1>, extend=False):<EOL><INDENT>"""<STR_LIT>"""<EOL>def nstar(v1, v2):<EOL><INDENT>sdev = max(v1.sdev, v2.sdev)<EOL>nstar = int(abs(v1.mean - v2.mean) / sdev)<EOL>if nstar > <NUM_LIT:5>:<EOL><INDENT>nstar = <NUM_LIT:5><EOL><DEDENT>elif nstar < <NUM_LIT:1>:<EOL><INDENT>nstar = <NUM_LIT:0><EOL><DEDENT>return '<STR_LIT:U+0020>' + nstar * '<STR_LIT:*>'<EOL><DEDENT>ct = <NUM_LIT:0><EOL>ans = []<EOL>width = [<NUM_LIT:0>,<NUM_LIT:0>,<NUM_LIT:0>]<EOL>stars = []<EOL>if v1.shape is None:<EOL><INDENT>keys = list(v1.keys())<EOL>if extend:<EOL><INDENT>v1 = _gvar.BufferDict(v1)<EOL>v2 = _gvar.BufferDict(v2)<EOL>ekeys = v1.extension_keys()<EOL>if len(ekeys) > <NUM_LIT:0>:<EOL><INDENT>first_ekey = ekeys[<NUM_LIT:0>]<EOL>keys += ekeys<EOL><DEDENT>else:<EOL><INDENT>extend = False<EOL><DEDENT><DEDENT>for k in keys:<EOL><INDENT>if extend and k == first_ekey:<EOL><INDENT>stars.append(None)<EOL>ans.append(None)<EOL><DEDENT>ktag = str(k)<EOL>if numpy.shape(v1[k]) == ():<EOL><INDENT>if ct%stride != <NUM_LIT:0>:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>if style in ['<STR_LIT:v>','<STR_LIT:m>']:<EOL><INDENT>v1fmt = v1[k].fmt(sep='<STR_LIT:U+0020>')<EOL>v2fmt = v2[k].fmt(sep='<STR_LIT:U+0020>')<EOL><DEDENT>else:<EOL><INDENT>v1fmt = v1[k].fmt(-<NUM_LIT:1>)<EOL>v2fmt = v2[k].fmt(-<NUM_LIT:1>)<EOL><DEDENT>if style == '<STR_LIT:m>' and v1fmt == v2fmt:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>stars.append(nstar(v1[k], v2[k]))<EOL>ans.append([ktag, v1fmt, v2fmt])<EOL>w = [len(ai) for ai in ans[-<NUM_LIT:1>]]<EOL>for i, (wo, wn) in enumerate(zip(width, w)):<EOL><INDENT>if wn > wo:<EOL><INDENT>width[i] = wn<EOL><DEDENT><DEDENT>ct += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>ktag = ktag + "<STR_LIT:U+0020>"<EOL>for i in numpy.ndindex(v1[k].shape):<EOL><INDENT>if ct%stride != <NUM_LIT:0>:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>ifmt = (len(i)*"<STR_LIT>")[:-<NUM_LIT:1>] % i<EOL>if style in ['<STR_LIT:v>','<STR_LIT:m>']:<EOL><INDENT>v1fmt = v1[k][i].fmt(sep='<STR_LIT:U+0020>')<EOL>v2fmt = v2[k][i].fmt(sep='<STR_LIT:U+0020>')<EOL><DEDENT>else:<EOL><INDENT>v1fmt = v1[k][i].fmt(-<NUM_LIT:1>)<EOL>v2fmt = v2[k][i].fmt(-<NUM_LIT:1>)<EOL><DEDENT>if style == '<STR_LIT:m>' and v1fmt == v2fmt:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>stars.append(nstar(v1[k][i], v2[k][i]))<EOL>ans.append([ktag+ifmt, v1fmt, v2fmt])<EOL>w = [len(ai) for ai in ans[-<NUM_LIT:1>]]<EOL>for i, (wo, wn) in enumerate(zip(width, w)):<EOL><INDENT>if wn > wo:<EOL><INDENT>width[i] = wn<EOL><DEDENT><DEDENT>ct += <NUM_LIT:1><EOL>ktag = "<STR_LIT>"<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>v2 = numpy.asarray(v2)<EOL>for k in numpy.ndindex(v1.shape):<EOL><INDENT>v1k = v1[k] if hasattr(v1[k], '<STR_LIT>') else v1[k].flat[<NUM_LIT:0>]<EOL>v2k = v2[k] if hasattr(v2[k], '<STR_LIT>') else v2[k].flat[<NUM_LIT:0>]<EOL>if ct%stride != <NUM_LIT:0>:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>kfmt = (len(k) * "<STR_LIT>")[:-<NUM_LIT:1>] % k<EOL>if style in ['<STR_LIT:v>','<STR_LIT:m>']:<EOL><INDENT>v1fmt = v1k.fmt(sep='<STR_LIT:U+0020>')<EOL>v2fmt = v2k.fmt(sep='<STR_LIT:U+0020>')<EOL><DEDENT>else:<EOL><INDENT>v1fmt = v1k.fmt(-<NUM_LIT:1>)<EOL>v2fmt = v2k.fmt(-<NUM_LIT:1>)<EOL><DEDENT>if style == '<STR_LIT:m>' and v1fmt == v2fmt:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>stars.append(nstar(v1k, v2k)) <EOL>ans.append([kfmt, v1fmt, v2fmt])<EOL>w = [len(ai) for ai in ans[-<NUM_LIT:1>]]<EOL>for i, (wo, wn) in enumerate(zip(width, w)):<EOL><INDENT>if wn > wo:<EOL><INDENT>width[i] = wn<EOL><DEDENT><DEDENT>ct += <NUM_LIT:1><EOL><DEDENT><DEDENT>collect.width = width<EOL>collect.stars = stars<EOL>return ans<EOL><DEDENT>dof = self.dof<EOL>if dof > <NUM_LIT:0>:<EOL><INDENT>chi2_dof = self.chi2/self.dof<EOL><DEDENT>else:<EOL><INDENT>chi2_dof = self.chi2<EOL><DEDENT>try:<EOL><INDENT>Q = '<STR_LIT>' % self.Q<EOL><DEDENT>except:<EOL><INDENT>Q = '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>logGBF = '<STR_LIT>' % self.logGBF<EOL><DEDENT>except:<EOL><INDENT>logGBF = '<STR_LIT>'<EOL><DEDENT>if self.prior is None:<EOL><INDENT>descr = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>descr = '<STR_LIT>'<EOL><DEDENT>table = ('<STR_LIT>'<EOL>'<STR_LIT>' % (descr, chi2_dof, dof, Q, logGBF))<EOL>if maxline < <NUM_LIT:0>:<EOL><INDENT>return table<EOL><DEDENT>if pstyle is not None:<EOL><INDENT>table = table + '<STR_LIT>'<EOL>prior = self.prior<EOL>if prior is None:<EOL><INDENT>if self.p0.shape is None:<EOL><INDENT>prior = _gvar.BufferDict(<EOL>self.p0, buf=self.p0.flatten() + _gvar.gvar(<NUM_LIT:0>,float('<STR_LIT>')))<EOL><DEDENT>else:<EOL><INDENT>prior = self.p0 + _gvar.gvar(<NUM_LIT:0>,float('<STR_LIT>'))<EOL><DEDENT><DEDENT>data = collect(self.palt, prior, style=pstyle, stride=<NUM_LIT:1>, extend=extend)<EOL>w1, w2, w3 = collect.width<EOL>fst = "<STR_LIT>" % (<EOL>max(w1, <NUM_LIT:15>), <NUM_LIT:3> * '<STR_LIT:U+0020>',<EOL>max(w2, <NUM_LIT:10>), int(max(w2,<NUM_LIT:10>)/<NUM_LIT:2>) * '<STR_LIT:U+0020>', max(w3,<NUM_LIT:10>)<EOL>)<EOL>if len(self.linear) > <NUM_LIT:0>:<EOL><INDENT>spacer = ['<STR_LIT:U+0020>', '<STR_LIT:->']<EOL><DEDENT>else:<EOL><INDENT>spacer = ['<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>for i, (di, stars) in enumerate(zip(data, collect.stars)):<EOL><INDENT>if di is None:<EOL><INDENT>ndashes = (<EOL>max(w1, <NUM_LIT:15>) + <NUM_LIT:3> + max(w2, <NUM_LIT:10>) + int(max(w2, <NUM_LIT:10>)/<NUM_LIT:2>)<EOL>+ <NUM_LIT:4> + max(w3, <NUM_LIT:10>)<EOL>)<EOL>table += ndashes * '<STR_LIT:->' + '<STR_LIT:\n>'<EOL>continue<EOL><DEDENT>table += (<EOL>(fst % tuple(di)) +<EOL>spacer[i in self.linear] +<EOL>stars + '<STR_LIT:\n>'<EOL>)<EOL><DEDENT><DEDENT>settings = "<STR_LIT>"<EOL>if not self.add_svdnoise or self.svdcut is None or self.svdcut < <NUM_LIT:0>:<EOL><INDENT>settings += "<STR_LIT>".format(<EOL>svdcut=self.svdcut if self.svdcut is not None else <NUM_LIT:0.0>,<EOL>svdn=self.svdn<EOL>)<EOL><DEDENT>else:<EOL><INDENT>settings += "<STR_LIT>".format(<EOL>svdcut=self.svdcut, svdn=self.svdn<EOL>)<EOL><DEDENT>criterion = self.stopping_criterion<EOL>try:<EOL><INDENT>fmtstr = [<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>][criterion if criterion is not None else <NUM_LIT:0>]<EOL>settings += fmtstr.format(*self.tol)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>if criterion is not None and criterion == <NUM_LIT:0>:<EOL><INDENT>settings +="<STR_LIT>".format(<EOL>itns=self.nit, time=self.time<EOL>)<EOL><DEDENT>else:<EOL><INDENT>settings +="<STR_LIT>".format(<EOL>itns=self.nit, time=self.time<EOL>)<EOL><DEDENT>default_line = '<STR_LIT>'<EOL>newline = "<STR_LIT>".format(<EOL>self.fitter, self.description<EOL>)<EOL>if newline != default_line:<EOL><INDENT>settings += newline<EOL><DEDENT>else:<EOL><INDENT>settings += '<STR_LIT:\n>'<EOL><DEDENT>if maxline <= <NUM_LIT:0> or self.data is None:<EOL><INDENT>return table + settings<EOL><DEDENT>ny = self.y.size<EOL>stride = <NUM_LIT:1> if maxline >= ny else (int(ny/maxline) + <NUM_LIT:1>)<EOL>if hasattr(self, '<STR_LIT>'):<EOL><INDENT>f = self.fcn_p<EOL><DEDENT>elif self.x is False:<EOL><INDENT>f = self.fcn(self.p)<EOL><DEDENT>else:<EOL><INDENT>f = self.fcn(self.x, self.p)<EOL><DEDENT>if hasattr(f, '<STR_LIT>'):<EOL><INDENT>f = _gvar.BufferDict(f)<EOL><DEDENT>else:<EOL><INDENT>f = numpy.array(f)<EOL><DEDENT>data = collect(self.y, f, style='<STR_LIT:v>', stride=stride, extend=False)<EOL>w1,w2,w3 = collect.width<EOL>clabels = ("<STR_LIT:key>","<STR_LIT>","<STR_LIT>")<EOL>if self.y.shape is not None and self.x is not False and self.x is not None:<EOL><INDENT>try:<EOL><INDENT>x = numpy.array(self.x)<EOL>xlist = []<EOL>ct = <NUM_LIT:0><EOL>for k in numpy.ndindex(x.shape):<EOL><INDENT>if ct%stride != <NUM_LIT:0>:<EOL><INDENT>ct += <NUM_LIT:1><EOL>continue<EOL><DEDENT>xlist.append("<STR_LIT>" % x[k])<EOL><DEDENT>assert len(xlist) == len(data)<EOL><DEDENT>except:<EOL><INDENT>xlist = None<EOL><DEDENT>if xlist is not None:<EOL><INDENT>for i,(d1,d2,d3) in enumerate(data):<EOL><INDENT>data[i] = (xlist[i],d2,d3)<EOL><DEDENT>clabels = ("<STR_LIT>","<STR_LIT>","<STR_LIT>")<EOL><DEDENT><DEDENT>w1,w2,w3 = max(<NUM_LIT:9>,w1+<NUM_LIT:4>), max(<NUM_LIT:9>,w2+<NUM_LIT:4>), max(<NUM_LIT:9>,w3+<NUM_LIT:4>)<EOL>table += "<STR_LIT>"<EOL>fst = "<STR_LIT>" % (w1, w2, w3)<EOL>table += fst % clabels<EOL>table += (w1 + w2 + w3) * "<STR_LIT:->" + "<STR_LIT:\n>"<EOL>for di, stars in zip(data, collect.stars):<EOL><INDENT>table += fst[:-<NUM_LIT:1>] % tuple(di) + stars + '<STR_LIT:\n>'<EOL><DEDENT>return table + settings<EOL>
Formats fit output details into a string for printing.

        The output tabulates the ``chi**2`` per degree of freedom of the fit
        (``chi2/dof``), the number of degrees of freedom, the ``Q``  value of
        the fit (ie, p-value), and the logarithm of the Gaussian Bayes Factor
        for the fit (``logGBF``). At the end it lists the SVD cut, the number
        of eigenmodes modified by the SVD cut, the tolerances used in the fit,
        and the time in seconds needed to do the fit. The tolerance used to
        terminate the fit is marked with an asterisk. It also lists
        information about the fitter used if it is other than the standard
        choice.

        Optionally, ``format`` will also list the best-fit values
        for the fit parameters together with the prior for each (in ``[]`` on
        each line). Lines for parameters that deviate from their prior by more
        than one (prior) standard deviation are marked with asterisks, with
        the number of asterisks equal to the number of standard deviations (up
        to five). Lines for parameters designated as linear (see ``linear``
        keyword) are marked with a minus sign after their prior.

        ``format`` can also list all of the data and the corresponding values
        from the fit, again with asterisks on lines  where there is a
        significant discrepancy.

        Args:
            maxline (int or bool): Maximum number of data points for which
                fit results and input data are tabulated. ``maxline<0``
                implies that only ``chi2``, ``Q``, ``logGBF``, and ``itns``
                are tabulated; no parameter values are included. Setting
                ``maxline=True`` prints all data points; setting it
                equal ``None`` or ``False`` is the same as setting
                it equal to ``-1``. Default is ``maxline=0``.
            pstyle (str or None): Style used for parameter list. Supported
                values are 'vv' for very verbose, 'v' for verbose, and 'm' for
                minimal. When 'm' is set, only parameters whose values differ
                from their prior values are listed. Setting ``pstyle=None``
                implies no parameters are listed.
            extend (bool): If ``True``, extend the parameter list to
                include values derived from log-normal or other
                non-Gaussian parameters. So values for fit parameter
                ``p['log(a)']``, for example, are listed together with
                values ``p['a']`` for the exponential of the fit parameter.
                Setting ``extend=False`` means that only the value
                for ``p['log(a)']`` is listed. Default is ``True``.

        Returns:
            String containing detailed information about fit.