本文整理汇总了Python中music21.mainTest函数的典型用法代码示例。如果您正苦于以下问题:Python mainTest函数的具体用法?Python mainTest怎么用?Python mainTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mainTest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: str
"tempos": [],
"timeSignatureFirst": "4/4",
"timeSignatures": [
"4/4"
]
},
"__class__": "music21.metadata.RichMetadata",
"__version__": [
"""
+ str(VERSION[0])
+ """,
"""
+ str(VERSION[1])
+ """,
"""
+ str(VERSION[2])
+ """
]
}
"""
),
)
# ------------------------------------------------------------------------------
if __name__ == "__main__":
import music21
music21.mainTest(Test, "noDocTest")
开发者ID:antoniopessotti,项目名称:music21,代码行数:30,代码来源:testMetadata.py
示例2: getattr
match = False
for skip in ['_', '__', 'Test', 'Exception']:
if part.startswith(skip) or part.endswith(skip):
match = True
if match:
continue
name = getattr(sys.modules[self.__module__], part)
if callable(name) and not isinstance(name, types.FunctionType):
try: # see if obj can be made w/ args
obj = name()
except TypeError:
continue
a = copy.copy(obj)
b = copy.deepcopy(obj)
self.assertIsNot(a, None)
self.assertIsNot(b, None)
# -----------------------------------------------------------------------------
_DOC_ORDER = (
Editorial,
)
if __name__ == "__main__":
#import doctest
#doctest.testmod()
import music21
music21.mainTest(Test)
开发者ID:cuthbertLab,项目名称:music21,代码行数:30,代码来源:editorial.py
示例3: open
if fp is None:
fp = environLocal.getTempFile('.qm')
for n in obj.flat.notes:
music = music + n.name + ' '
music += '\n'
with open(fp, 'w') as f:
f.write(music)
return fp
if __name__ == '__main__':
import music21
music21.mainTest()
# from music21 import common
#
# converter.registerSubconverter(QMConverter)
#
# print('\nFILE')
# print('+++++++++++++++++++++++++')
#
# parserPath = common.getSourceFilePath() / 'converter'
# testPath = parserPath / 'quarterMusicTestIn.qm'
#
# a = converter.parse(testPath)
#
# a.show('text')
#
#
开发者ID:cuthbertLab,项目名称:music21,代码行数:31,代码来源:qmConverter.py
示例4: testRuleFrequency
def testRuleFrequency(self):
import time
print(time.ctime())
(num1, num2, num3, num4a, num4b) = ruleFrequency()
print(time.ctime())
print(num1)
print(num2)
print(num3)
print(num4a)
print(num4b)
self.assertEqual(num4a, 57)
self.assertEqual(num4b, 104)
if (__name__ == "__main__"):
#runPiece(267)
# (totalDict, foundPieceOpus) = findCorrections(correctionType="min6", startPiece=21, endPiece=22)
# print totalDict
# if len(foundPieceOpus) > 0:
# foundPieceOpus.show('lily.png')
import music21
music21.mainTest(Test) #TestExternal) #, TestExternal)
# correctedMin6()
# correctedMaj3()
# improvedHarmony()
#------------------------------------------------------------------------------
# eof
开发者ID:EQ4,项目名称:music21,代码行数:29,代码来源:capua.py
示例5:
Interval 6 ⠴
Rest eighth ⠭
Barline final ⠣⠅
Measure 35 Left, Note Grouping 1:
Ascending Chord:
Octave 3 ⠸
B 16th ⠾
Interval 3 ⠬
Rest 16th ⠍
Ascending Chord:
Octave 2 ⠘
B eighth ⠚
Interval 3 ⠬
Interval 5 ⠔
Rest eighth ⠭
Barline final ⠣⠅
====
---end grand segment---
'''
self.maxDiff = None
self.assertEqual(x.splitlines(), y.splitlines())
if __name__ == "__main__":
import music21
music21.mainTest(Test) #, runTest='testVerdiDebug')
#------------------------------------------------------------------------------
# eof
开发者ID:ahankinson,项目名称:music21,代码行数:30,代码来源:examples.py
示例6: GraphException
except KeyError: # no color match
raise GraphException('invalid color name: %s' % color)
elif common.isListLike(color):
percent = False
for sub in color:
if sub < 1:
percent = True
break
if percent:
if len(color) == 1:
color = [color[0], color[0], color[0]]
# convert to 0 100% values as strings with % symbol
colorStrList = [str(x * 100) + "%" for x in color]
return webcolors.rgb_percent_to_hex(colorStrList)
else: # assume integers
return webcolors.rgb_to_hex(tuple(color))
raise GraphException('invalid color specification: %s' % color)
class Test(unittest.TestCase):
def testColors(self):
self.assertEqual(getColor([0.5, 0.5, 0.5]), '#808080')
self.assertEqual(getColor(0.5), '#808080')
self.assertEqual(getColor(255), '#ffffff')
self.assertEqual(getColor('Steel Blue'), '#4682b4')
if __name__ == "__main__":
# sys.arg test options will be used in mainTest()
import music21
music21.mainTest(Test) #TestExternal, 'noDocTest') #, runTest='testGetPlotsToMakeA')
开发者ID:cuthbertLab,项目名称:music21,代码行数:30,代码来源:utilities.py
示例7: testRichMetadata02
self.assertEqual(
score.metadata.search(
'qu.d',
field='title',
),
(True, 'title'),
)
self.assertEqual(
score.metadata.search(
re.compile('(.*)canon(.*)'),
),
(True, 'movementName'),
)
def testRichMetadata02(self):
from music21 import corpus
from music21 import metadata
score = corpus.parse('bwv66.6')
richMetadata = metadata.RichMetadata()
richMetadata.merge(score.metadata)
richMetadata.update(score)
self.assertEqual(richMetadata.noteCount, 165)
self.assertEqual(richMetadata.quarterLength, 36.0)
# -----------------------------------------------------------------------------
if __name__ == '__main__':
import music21
music21.mainTest(Test, 'noDocTest')
开发者ID:cuthbertLab,项目名称:music21,代码行数:30,代码来源:testMetadata.py
示例8: Test
# initialOffset=0.0,
# flatten=True,
# classLists=classLists)
# return listOfTimespanTrees[0]
#---------------------
class Test(unittest.TestCase):
def testFastPopulate(self):
'''
tests that the isSorted speed up trick ends up producing identical results.
'''
from music21 import corpus
sf = corpus.parse('bwv66.6').flat
sfTree = sf.asTree()
#print(sfTree)
sf.isSorted = False
sf._cache = {}
sfTreeSlow = sf.asTree()
for i in range(len(sf)):
fasti = sfTree[i]
slowi = sfTreeSlow[i]
self.assertIs(fasti, slowi)
#---------------------
if __name__ == '__main__':
import music21
music21.mainTest(Test) #, runTest='testFastPopulate')
开发者ID:jamesgoodsell,项目名称:music21,代码行数:30,代码来源:fromStream.py
示例9: sorted
while tss:
timespan = tss.pop()
currentTimespansInList = sorted(tss,
key=lambda x: (x.offset, x.endTime))
tsTree.removeTimespan(timespan)
currentTimespansInTree = [x for x in tsTree]
self.assertEqual(currentTimespansInTree,
currentTimespansInList,
(attempt, currentTimespansInTree, currentTimespansInList))
if tsTree.rootNode is not None:
currentPosition = min(
x.offset for x in currentTimespansInList)
currentEndTime = max(
x.endTime for x in currentTimespansInList)
self.assertEqual(tsTree.rootNode.endTimeLow,
min(x.endTime for x in currentTimespansInList))
self.assertEqual(tsTree.rootNode.endTimeHigh,
max(x.endTime for x in currentTimespansInList))
self.assertEqual(tsTree.lowestPosition(), currentPosition)
self.assertEqual(tsTree.endTime, currentEndTime)
for i in range(len(currentTimespansInTree)):
self.assertEqual(currentTimespansInList[i], currentTimespansInTree[i])
#------------------------------------------------------------------------------
if __name__ == "__main__":
import music21
music21.mainTest(Test) #, runTest='testElementsStoppingAt')
开发者ID:00gavin,项目名称:music21,代码行数:29,代码来源:timespanTree.py
示例10: testGetAccidentalCountSumAdvanced
s2 = stream.Stream()
s2.append(note.Note('D-2'))
s2.append(note.Note('F#5'))
self.assertEqual(getAccidentalCountSum([s1, s2]), {'flat': 1, 'sharp': 1})
def testGetAccidentalCountSumAdvanced(self):
s1 = corpus.parse('bach/bwv7.7')
s2 = corpus.parse('bach/bwv66.6')
totalNotes = len(s1.flat.notes) + len(s2.flat.notes)
tally = getAccidentalCountSum([s1, s2], True)
self.assertEqual(tally, {'sharp': 195, 'natural': 324})
self.assertEqual(totalNotes, tally['sharp'] + tally['natural'])
class TestSlow(unittest.TestCase):
def runTest(self):
pass
def testAccidentalCountBachChorales(self):
# the total number of accidentals in the Bach Chorales
chorales = list( corpus.chorales.Iterator() )
self.assertEqual(getAccidentalCountSum(chorales, True),
{'double-sharp': 4, 'flat': 7886, 'natural': 79869, 'sharp': 14940})
if __name__ == "__main__":
import music21
music21.mainTest(Test) # replace 'Test' with 'TestSlow' to test it on all 371 Bach Chorales.
开发者ID:sbrother,项目名称:music21,代码行数:29,代码来源:gatherAccidentals.py
示例11: ap
ap('7---')
elif 'PageLayout' in elClasses and layoutToBreaks:
popHyphens()
ap('77---')
elif 'LineBreak' in elClasses:
popHyphens()
ap('7---')
elif 'PageBreak' in elClasses:
popHyphens()
ap('77---')
elif 'ColumnBreak' in elClasses:
popHyphens()
ap('777---')
else:
error(el, ErrorLevel.LOG)
return ''.join(volpianoTokens)
class Test(unittest.TestCase):
pass
def testNoteNames(self):
pass
if __name__ == '__main__':
import music21
music21.mainTest(Test, 'importPlusRelative')
开发者ID:ELVIS-Project,项目名称:music21,代码行数:30,代码来源:volpiano.py
示例12:
'cicon',
field='composer',
fileExtensions=('.krn',),
)
self.assertEqual(len(searchResult), 0)
searchResult = mdb.search(
'cicon',
field='composer',
fileExtensions=('.xml'),
)
self.assertEqual(len(searchResult), 1)
# -----------------------------------------------------------------------------
_DOC_ORDER = (
MetadataBundle,
)
__all__ = [
'MetadataEntry',
'MetadataBundle',
]
if __name__ == '__main__':
import music21
music21.mainTest(Test) #, runTest='testFileExtensions')
# -----------------------------------------------------------------------------
开发者ID:cuthbertLab,项目名称:music21,代码行数:30,代码来源:bundles.py
示例13: iterateSequencePairwise
def iterateSequencePairwise(self, sequence):
prev = None
for x in sequence:
cur = x
if prev is not None:
yield prev, cur
prev = cur
def runNBConvert(self, ipythonNotebookFilePath):
try:
from nbconvert import nbconvertapp as nb
except ImportError:
environLocal.warn("nbconvert is not installed, run pip3 install nbconvert")
raise
outputPath = os.path.splitext(self.sourceToAutogenerated(ipythonNotebookFilePath))[0]
app = nb.NbConvertApp.instance() # @UndefinedVariable
app.initialize(argv=['--to', 'rst', '--output', outputPath, ipythonNotebookFilePath])
app.writer.build_directory = os.path.dirname(ipythonNotebookFilePath)
app.start()
return True
if __name__ == '__main__':
i = IPythonNotebookReSTWriter()
p5 = i.ipythonNotebookFilePaths[5]
i.convertOneNotebook(p5)
import music21
music21.mainTest('moduleRelative')
开发者ID:ahankinson,项目名称:music21,代码行数:29,代码来源:writers.py
示例14: testFastPopulate
def testFastPopulate(self):
'''
tests that the isSorted speed up trick ends up producing identical results.
'''
from music21 import corpus
sf = corpus.parse('bwv66.6').flat
sfTree = sf.asTree()
#print(sfTree)
sf.isSorted = False
sf._cache = {}
sfTreeSlow = sf.asTree()
for i in range(len(sf)):
fasti = sfTree[i]
slowi = sfTreeSlow[i]
self.assertIs(fasti, slowi)
# def xtestExampleScoreAsTimespans(self):
# from music21 import tree
# score = tree.makeExampleScore()
# treeList = tree.fromStream.listOfTreesByClass(score, useTimespans=True)
# tl0 = treeList[0]
#---------------------
if __name__ == '__main__':
import music21
music21.mainTest(Test) #, runTest='testExampleScoreAsTimespans')
开发者ID:fzalkow,项目名称:music21,代码行数:29,代码来源:fromStream.py
示例15: testWTCImport03
# def testWTCImport03(self):
# score = corpus.parse('bach/bwv862', 1)
# self.assertEqual(
# score.metadata.title,
# 'WTC I: Prelude and Fugue in A flat major',
# )
# def testWTCImport04(self):
# score = corpus.parse('bach/bwv888', 1)
# self.assertEqual(
# score.metadata.title,
# 'WTC II: Prelude and Fugue in A major',
# )
# #s.show()
# def testWorkReferences(self):
# s = corpus.getWorkReferences()
#
# # presenly 19 top level lists
# self.assertEqual(len(s)>=19, True)
# self.assertEqual(len(s[0].keys()), 4)
if __name__ == '__main__':
import music21
music21.mainTest('noDocTest',Test)
# -----------------------------------------------------------------------------
# eof
开发者ID:cuthbertLab,项目名称:music21,代码行数:29,代码来源:testCorpus.py
示例16: str
print [note1.name + str(note1.octave) for note1 in cantusFirmus.notes]
if not goodHarmony: print "bad harmony"
else: print "harmony good"
if not goodMelody: print "bad melody"
else: print "melody good"
except ModalCounterpointException:
pass
d1 = duration.Duration()
d1.type = "whole"
for tN in hopeThisWorks2.notes:
tN.duration = d1
for tN in cantusFirmus.notes:
tN.duration = d1
lilyOut = twoStreamLily(hopeThisWorks2, cantusFirmus)
lilyOut.showPNGandPlayMIDI()
def twoStreamLily(st1, st2):
lilyOut = lily.LilyString()
lilyOut += "<< \\time 4/4\n"
lilyOut += " \\new Staff { "
lilyOut += st1.lily + " } \n"
lilyOut += " \\new Staff { "
lilyOut += st2.lily + " } \n"
lilyOut += ">> \n"
return lilyOut
if (__name__ == "__main__"):
music21.mainTest(TestExternal) #TestExternal
开发者ID:knuton,项目名称:music21,代码行数:30,代码来源:counterpoint.py
示例17: editorial
>>> acc = pitch.Accidental()
>>> acc.editorial
<music21.editorial.Editorial {} >
>>> acc.editorial.ficta = pitch.Accidental('sharp')
>>> acc.editorial.ficta
<accidental sharp>
>>> acc.editorial
<music21.editorial.Editorial {'ficta': <accidental sharp>} >
'''
from music21 import editorial
if self._editorial is None:
self._editorial = editorial.Editorial()
return self._editorial
@editorial.setter
def editorial(self, ed):
self._editorial = ed
class Test(unittest.TestCase):
pass
if __name__ == '__main__':
import music21
music21.mainTest(Test) #, runTest='')
# -----------------------------------------------------------------------------
# eof
开发者ID:cuthbertLab,项目名称:music21,代码行数:30,代码来源:style.py
示例18: t
'2010.06.24': 3.932,
}),
('schumann/opus41no1/movement2', 7,
{'2009.12.14': 5.88,
'2009.12.15': 5.126,
'2010.06.24': 5.799,
}),
('luca/gloria', 4,
{'2009.12.14': 3.174,
'2009.12.15': 2.954,
'2010.06.24': 3.063,
}),
]:
t = common.Timer()
t.start()
x = corpus.parseWork(known, forceSource=True)
t.stop()
dur = t()
environLocal.printDebug(['timing tolerance for', known,
'this run:', t, 'best runs:',
['%s: %s' % (x, y) for x, y in best.items()]])
self.assertEqual(True, dur <= max) # performance test
if __name__ == "__main__":
music21.mainTest(TestPerformance)
开发者ID:knuton,项目名称:music21,代码行数:29,代码来源:testPerformance.py
示例19: testWTCImport03
# def testWTCImport03(self):
# score = corpus.parse('bach/bwv862', 1)
# self.assertEqual(
# score.metadata.title,
# 'WTC I: Prelude and Fugue in A flat major',
# )
# def testWTCImport04(self):
# score = corpus.parse('bach/bwv888', 1)
# self.assertEqual(
# score.metadata.title,
# 'WTC II: Prelude and Fugue in A major',
# )
# #s.show()
# def testWorkReferences(self):
# s = corpus.getWorkReferences()
#
# # presenly 19 top level lists
# self.assertEqual(len(s)>=19, True)
# self.assertEqual(len(s[0].keys()), 4)
if __name__ == "__main__":
import music21
music21.mainTest("noDocTest", Test)
# ------------------------------------------------------------------------------
# eof
开发者ID:fzalkow,项目名称:music21,代码行数:30,代码来源:testCorpus.py
示例20: Test
return jsf.jsonWrite(filePath)
return self
#------------------------------------------------------------------------------
class Test(unittest.TestCase):
def runTest(self):
pass
#------------------------------------------------------------------------------
_DOC_ORDER = (
MetadataBundle,
)
__all__ = [
'MetadataEntry',
'MetadataBundle',
]
if __name__ == "__main__":
import music21
music21.mainTest(Test) #, runTest='testUserSpecifiedPath')
#------------------------------------------------------------------------------
开发者ID:sbrother,项目名称:music21,代码行数:30,代码来源:bundles.py
注:本文中的music21.mainTest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论