Update Section Names
ci / checks (push) Successful in 47m26s

This commit is contained in:
khodowany
2026-09-30 08:05:28 -05:00
parent f5f0ab5eec
commit 7683793052
6 changed files with 37 additions and 31 deletions
+8 -2
View File
@@ -8,6 +8,7 @@ import shutil
import tempfile
import unittest
import generator.arrange.form
import generator.arrange.generate
import generator.engraving.cache
import generator.engraving.fonts
@@ -152,7 +153,8 @@ class ScaleOutputTests(unittest.TestCase):
before = copy.deepcopy(source)
warnings = io.StringIO()
with contextlib.redirect_stdout(warnings):
report = generator.scales.mapping.annotate(source, [generator.scales.timeline.Solo(0, 12, 'Guitar Solo')], tests.scale_fixtures.library(), 'fixture.xml')
report = generator.scales.mapping.annotate(source, [generator.scales.timeline.Solo(0, 12, 'Acoustic Solo')], tests.scale_fixtures.library(), 'fixture.xml')
self.assertTrue(report.startswith('Acoustic: Acoustic Solo\n'))
self.assertIn('fixture.xml, Acoustic, source measure 3', warnings.getvalue())
self.assertIn('No exact match within the permitted catalog', report)
self.assertIn('Parent degree: 1; chord-root mode: C Ionian', report)
@@ -166,7 +168,7 @@ class ScaleOutputTests(unittest.TestCase):
def test_layout_keeps_exact_offsets_continuations_and_uniform_size(self):
source = tests.test_musicxml.parse(tests.test_accompaniment.xml_bars([tests.test_musicxml.xml_note()] * 40))
staff = source['staves'][0]
staff['measures'][0]['section_label'] = 'Guitar Solo'
staff['measures'][0]['section_label'] = 'Electric Solo'
staff['scale_spans'] = [{'id': f'scale-{i}', 'start': generator.model.rational(a), 'end': generator.model.rational(b), 'label': label, 'matched': True} for i, (a, b, label) in enumerate(((0, fractions.Fraction(3, 2), 'C Ionian'), (fractions.Fraction(3, 2), 60, 'D Harmonic Minor')), 1)]
fonts = generator.engraving.fonts.Fonts(pathlib.Path('package/assets/fonts/petaluma'))
layout = generator.engraving.layout.layout_score(source, generator.engraving.types.Style(), fonts)
@@ -174,6 +176,7 @@ class ScaleOutputTests(unittest.TestCase):
self.assertEqual(len({s.scale for s in systems}), 1)
self.assertTrue(all(len(p.systems) == 2 for p in layout.pages[:-1]))
self.assertGreater(len(systems), 2)
self.assertEqual([p.value for s in systems for p in s.primitives if p.role == 'section'], ['Electric Solo'])
for system in systems:
expected = [s['label'] for s in staff['scale_spans'] if generator.model.fraction(s['start']) < system.end and generator.model.fraction(s['end']) > system.start]
self.assertEqual([p.value for p in system.primitives if p.role == 'scale'], expected)
@@ -181,9 +184,12 @@ class ScaleOutputTests(unittest.TestCase):
def test_only_soloing_part_is_annotated_without_revoicing(self):
content = '<harmony><root><root-step>C</root-step></root><kind>major</kind></harmony>' + tests.test_musicxml.xml_note()
source = tests.test_musicxml.parse(tests.test_musicxml.xml_score(content))
roles = {'acoustic': ('slash', 'accompaniment'), 'electric': ('rest', 'slash'), 'vocal': ('rest', 'rest')}
for part in ('acoustic', 'electric', 'vocal'):
before = generator.arrange.generate.arrange_document(source, part, rhythms=tests.rhythm_fixtures.library())
result = generator.arrange.generate.arrange_document(source, part, rhythms=tests.rhythm_fixtures.library(), scales=tests.scale_fixtures.library())
sections = generator.arrange.form.full_arrangement_sections(source['staves'][0]['measures'], part)
self.assertEqual([(s.label, s.role) for s in sections[3:5]], list(zip(('Acoustic Solo', 'Electric Solo'), roles[part])))
spans = result['staves'][0].pop('scale_spans', [])
self.assertEqual(result, before)
self.assertEqual(len(spans), int(part != 'vocal'))