Simplification
This commit is contained in:
@@ -11,7 +11,8 @@ from unittest.mock import patch
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
from audition import reference_review, solo_compare
|
||||
from tests import solo_compare
|
||||
reference_review = solo_compare
|
||||
from generator import vocabulary, production
|
||||
from generator.solo import export, harmonic, notation, placement, types
|
||||
from tests.solo_fixtures import song
|
||||
@@ -29,6 +30,20 @@ def pitched(duration, tie='', octave=5):
|
||||
|
||||
|
||||
class ComparisonTests(unittest.TestCase):
|
||||
def test_comparison_separates_pitch_timing_and_sounding_duration(self):
|
||||
events=lambda pitch,end: [dict(start='0',end=end,pitch=pitch)]
|
||||
a=events(60,'2')
|
||||
octave=solo_compare.relationships(a,events(72,'2'))
|
||||
self.assertEqual(octave['pitch_sequence_edit_distance'],1)
|
||||
self.assertEqual(octave['timed_attack_edit_distance'],0)
|
||||
self.assertEqual(octave['same_sounding_pitch_beats'],'0')
|
||||
self.assertEqual(octave['same_pitch_class_beats'],'2')
|
||||
shorter=solo_compare.relationships(a,events(60,'1'))
|
||||
self.assertEqual(shorter['pitch_sequence_edit_distance'],0)
|
||||
self.assertEqual(shorter['timed_attack_edit_distance'],1)
|
||||
self.assertEqual(shorter['same_sounding_pitch_beats'],'1')
|
||||
self.assertEqual(shorter['either_sounding_beats'],'2')
|
||||
|
||||
def test_exact_cli_is_a_real_exit_gate(self):
|
||||
args=['solo_compare','--generated-dir','unused','--output','unused','--reference','fixture/acoustic=unused','--require-exact']
|
||||
review={'exact_musical_match':False,'exact_matching_attacks':0,'differences':[{}],'rest_difference':True}
|
||||
@@ -85,6 +100,20 @@ class ComparisonTests(unittest.TestCase):
|
||||
b=self.review(root,'reference.xml',xml(pitched(24),leadin=prelude),form_start=2,pitch_convention='guitar-written')
|
||||
self.assertEqual(solo_compare.audition_bounds(a,b),(F(-4),F(4)))
|
||||
|
||||
def test_fixed_backing_includes_the_production_leadin(self):
|
||||
import array
|
||||
from generator import playback, score
|
||||
document=song(count=2,chords=('CM7',))
|
||||
document['staves'][0]['measures'][1]['section_label']='Acoustic Solo'
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
prelude='<measure number="0"><attributes><divisions>6</divisions></attributes>'+pitched(24)+'</measure>'
|
||||
actual=self.review(root,'actual.xml',xml(pitched(24),leadin=prelude),form_start=2,pitch_convention='guitar-written')
|
||||
with patch.object(score,'load_json',return_value=document),patch.object(solo_compare,'render_events',return_value=array.array('f',[0]*10)) as render,patch.object(playback,'write_pcm'):
|
||||
solo_compare.audition_pair(actual,actual,'fixture/acoustic',root,Path(root),{})
|
||||
# Backing's preceding bar starts at the same audition clock as the lead.
|
||||
self.assertEqual(render.call_args_list[0].args[0][0][0],0)
|
||||
self.assertTrue(any(start>=4 for start,end,pitch in render.call_args_list[0].args[0]))
|
||||
|
||||
def test_triplet_time_and_annotations_are_literal(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
triplet=pitched(2).replace('<type>quarter</type>','<type>eighth</type><time-modification><actual-notes>3</actual-notes><normal-notes>2</normal-notes></time-modification>')
|
||||
|
||||
Reference in New Issue
Block a user