Juergen Spitzmueller wrote:
Angus Leeming wrote:

It's a sensible thing to do anyway...


ok.


So the metrics file contains the correct number of entries?
Are they all reasonable looking or does it contain your "ridiculous" entry?


Each snippet gets its own metrics file, calculated from the corresponding logfile.

In a file with a filled inset (displayed correct) and an empty inset (displayed wrong), I have the following contents:

in 0lyxpreview.metrics:
        Snippet 1 0.916667
which is reasonable

in 1lyxpreview.metrics:
        Snippet 1 -2147483646.000000
which is wrong

The log files have:

0lyxpreview.log
        Preview: Snippet 1 282168 0 575415

1lyxpreview.log:
        Preview: Snippet 1 0 0 0


If not, then the flaw is in LyX's handling of this metrics file rather than
in the metrics file itself, no?


I don't think so, since the bogus values are already in the metrics.

Thanks for the explanation. I think that this should fix things properly. José can advise on whether "float(ascent)" will work in Python 1.5.2.

            if snippet:
                ascent  = string.atoi(match.group(2))
                descent = string.atoi(match.group(3))

                frac = 0.5
                if ascent > 0 and descent > 0:
                    ascent  = float(ascent) + tp_ascent
                    descent = float(descent) - tp_descent

                    if abs(ascent + descent) > 0.1:
                        frac = ascent / (ascent + descent)

                    # Sanity check
                    if frac < 0 or frac > 1:
                        frac = 0.5

                metrics.write("Snippet %s %f\n" % (match.group(1), frac))

            else:
                tp_descent = string.atof(match.group(2))
                tp_ascent  = string.atof(match.group(4))

Reply via email to