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.
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)
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 ()
dest="run_test",
action="store_true",
help='run test method')
+
p.add_option ('--max-count',
dest="max_count",
metavar="COUNT",
default=0,
action="store",
help='only analyze COUNT signature pairs')
-
p.add_option ('', '--threshold',
dest="threshold",
(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))
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)