From: Han-Wen Nienhuys Date: Tue, 13 Jun 2006 13:34:37 +0000 (+0000) Subject: * buildscripts/output-distance.py (test_compare_signatures): X-Git-Tag: release/2.10.0-2~519 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1924dc355a8c2add4dddde185519ec24c4e1e78b;p=lilypond.git * buildscripts/output-distance.py (test_compare_signatures): timing routines. (read_signature_file): use new signature format. * scm/stencil.scm (write-system-signature): simpler signature format. --- diff --git a/ChangeLog b/ChangeLog index e500743052..8a4830e8f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,14 @@ 2006-06-13 Han-Wen Nienhuys + * buildscripts/output-distance.py (test_compare_signatures): + timing routines. + (read_signature_file): use new signature format. + + * scm/stencil.scm (write-system-signature): simpler signature + format. + * lily/stem.cc (calc_stem_end_position): calc quantized-positions - for beamed case. + for beamed case. Backportme. * lily/note-spacing.cc (stem_dir_correction): don't inspect stem_end_position, but estimate instead. Backportme. diff --git a/buildscripts/output-distance.py b/buildscripts/output-distance.py index 91db6f0699..fcb8e3731c 100644 --- a/buildscripts/output-distance.py +++ b/buildscripts/output-distance.py @@ -246,8 +246,20 @@ class SystemLink: def read_signature_file (name): print 'reading', name - exp_str = ("[%s]" % open (name).read ()) - entries = safeeval.safe_eval (exp_str) + + entries = open (name).read ().split ('\n') + def string_to_tup (s): + return tuple (map (float, s.split (' '))) + + def string_to_entry (s): + fields = s.split('@') + fields[2] = string_to_tup (fields[2]) + fields[3] = string_to_tup (fields[3]) + + return tuple (fields) + + entries = [string_to_entry (e) for e in entries + if e and not e.startswith ('#')] grob_sigs = [GrobSignature (e) for e in entries] sig = SystemSignature (grob_sigs) @@ -702,12 +714,37 @@ def test_basic_compare (): names = [d['name'] for d in dicts] system ('lilypond -ddump-signatures --png -b eps ' + ' '.join (names)) + test_compare_signatures (names) - sigs = dict ((n, read_signature_file ('%s-1.signature' % n)) for n in names) +def test_compare_signatures (names, timing=False): + + import time + + times = 1 + if timing: + times = 100 + + t0 = time.clock () + + count = 0 + for t in range (0, times): + sigs = dict ((n, read_signature_file ('%s-1.signature' % n)) for n in names) + count += 1 + + if timing: + print 'elapsed', (time.clock() - t0)/count + + + t0 = time.clock () + count = 0 combinations = {} for (n1, s1) in sigs.items(): for (n2, s2) in sigs.items(): combinations['%s-%s' % (n1, n2)] = SystemLink (s1,s2).distance () + count += 1 + + if timing: + print 'elapsed', (time.clock() - t0)/count results = combinations.items () results.sort () @@ -747,6 +784,7 @@ def main (): dest="run_test", action="store_true", help='run test method') + p.add_option ('--max-count', dest="max_count", metavar="COUNT", @@ -754,7 +792,6 @@ def main (): default=0, action="store", help='only analyze COUNT signature pairs') - p.add_option ('', '--threshold', dest="threshold", diff --git a/scm/stencil.scm b/scm/stencil.scm index 5f3413df8f..0c4bf830cf 100644 --- a/scm/stencil.scm +++ b/scm/stencil.scm @@ -325,7 +325,16 @@ grestore (define (pythonic-pair expr) (format "(~a,~a)" (car expr) (cdr expr))) - + + + (define (raw-string expr) + "escape quotes and slashes for python consumption" + (regexp-substitute/global #f "[@\n]" (format "~a" expr) 'pre " " 'post)) + + (define (raw-pair expr) + (format "~a ~a" + (car expr) (cdr expr))) + (define (found-grob expr) (let* ((grob (car expr)) @@ -344,12 +353,12 @@ grestore rest) (format output - "['~a', '~a', ~a, ~a, '~a'],\n" + "~a@~a@~a@~a@~a\n" (cdr (assq 'name (ly:grob-property grob 'meta) )) - (pythonic-string location) - (pythonic-pair (if (interval-empty? x-ext) '(1 . -1) x-ext)) - (pythonic-pair (if (interval-empty? y-ext) '(1 . -1) y-ext)) - (pythonic-string collected)) + (raw-string location) + (raw-pair (if (interval-empty? x-ext) '(1 . -1) x-ext)) + (raw-pair (if (interval-empty? y-ext) '(1 . -1) y-ext)) + (raw-string collected)) )) (define (interpret-for-signature escape collect expr)