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 doCheckCF(self): print("Checking CF") self.results.clear() cf = [int(x) for x in self.cfInput.text().split(',')] problems = checkCF(cf) print(problems) self.resultsLabel.setText("Problems with Cantus Firmus:") if not problems.reasons: self.results.addItem("Cantus Firmus is valid!") else: for problem in problems.reasons: self.results.addItem(problem.split(':')[1])
def test_badCFIsBad(badCF): assert not checkCF(badCF).isValid()
def test_goodCFIsGood(goodCF): assert checkCF(goodCF).isValid()
def test_repairCFWorksOnBrokenCF(foundry, cantus, maxCount, cantusGamut): badSpecs = getAllBadSpecs(cantus, maxCount) for badSpec in badSpecs: foundry = Foundry(Optimize()).applySpec(badSpec) cantus = foundry.extractPitches(badSpec.line) assert checkCF(repairCF(cantus, cantusGamut)).isValid()