]> git.donarmstrong.com Git - lilypond.git/commitdiff
* buildscripts/output-distance.py (test_compare_signatures):
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 13 Jun 2006 13:34:37 +0000 (13:34 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 13 Jun 2006 13:34:37 +0000 (13:34 +0000)
timing routines.
(read_signature_file): use new signature format.

* scm/stencil.scm (write-system-signature): simpler signature
format.

ChangeLog
buildscripts/output-distance.py
scm/stencil.scm

index e5007430529ad0beb222610b56f87205b924b927..8a4830e8f47e5021508d99f6817d45d1fb6ca4fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,14 @@
 2006-06-13  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * 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.
index 91db6f0699f4c22241c61d843ca5d7935b04c7a2..fcb8e3731c5bc1d7f931fa14bee65c5cc852184e 100644 (file)
@@ -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",
index 5f3413df8f64a24395a3334f207dd397446cd4c9..0c4bf830cf6765432561360913a2c3130185b864 100644 (file)
@@ -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)