def repairCF(cf: List[int], gamutMax): reasons = checkCF(cf) length = len(cf) cf = [ConstPitch(x) for x in cf] tCF = makeTemporalisedLine(cf, NoteLength.WHOLE) sm = makeSimMap([tCF], tCF) return repairLine(cf, cantusSpec(length, gamutMax, ''), reasons, gamutMax, sm)
def test_gamutFailure(workingCF, cantus, cantusGamut): workingCF[2] = 1 assert checkCF(workingCF).reasons[0].split(':')[0].split('.')[1] == "GAMUT" symCF = [ConstPitch(x) for x in workingCF] sm = makeSimMap([makeTemporalisedLine(symCF, NoteLength.WHOLE)], makeTemporalisedLine(symCF, NoteLength.WHOLE)) x = smartRepairLine(symCF, cantus, checkCF(workingCF), cantusGamut, sm) assert x is not None assert checkCF(x).isValid()
def repairS3(cf: List[int], s3: List[int], gamutMax): reasons = checkS1(cf, s3) cf = [ConstPitch(x) for x in cf] s3 = [ConstPitch(x) for x in s3] tCF = makeTemporalisedLine(cf, NoteLength.WHOLE) tS3 = makeTemporalisedLine(s3, NoteLength.QUARTER) sm = makeSimMap([tCF], tS3) return repairLine(s3, thirdSpeciesSpec(cf, gamutMax, ''), reasons, gamutMax, sm)
def repairS2(cf: List[int], s2: List[int], gamutMax): reasons = checkS1(cf, s2) cf = [ConstPitch(x) for x in cf] s2 = [ConstPitch(x) for x in s2] tCF = makeTemporalisedLine(cf, NoteLength.WHOLE) tS2 = makeTemporalisedLine(s2, NoteLength.HALF) sm = makeSimMap([tCF], tS2) return repairLine(s2, secondSpeciesSpec(cf, gamutMax, ''), reasons, gamutMax, sm)
def repairS1(cf: List[int], s1: List[int], gamutMax): reasons = checkS1(cf, s1) cf = [ConstPitch(x) for x in cf] s1 = [ConstPitch(x) for x in s1] tCF = makeTemporalisedLine(cf, NoteLength.WHOLE) tS1 = makeTemporalisedLine(s1, NoteLength.WHOLE) sm = makeSimMap([tCF], tS1) return repairLine(s1, firstSpeciesSpec(cf, gamutMax, ''), reasons, gamutMax, sm)
def test_SimFailure(workingCF): cf = workingCF s1 = workingCF.copy() s1[1] = s1[1] + 11 #seventh assert checkS1(cf, s1).reasons[0].split(':')[0].split('.')[1] == "SIMULTANEITY" symCF = [ConstPitch(x) for x in cf] symS1 = [ConstPitch(x) for x in s1] sm = makeSimMap([makeTemporalisedLine(symCF, NoteLength.WHOLE)], makeTemporalisedLine(symS1, NoteLength.WHOLE)) x = smartRepairLine(symS1, firstSpeciesSpec(symCF, 20, ''), checkS1(cf, s1), 13, sm) assert x is not None assert checkS1(cf,x).isValid()