From 46500f5dca40f244f517018ca7ff54c8a8947aaf Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:11:20 -1000 Subject: [PATCH 1/9] Drop the blank lines sitting just inside docstring delimiters 314 docstrings ended with a blank line before their closing quotes, a few began with one after the opening quotes. Whitespace only: a doctest's expected output is already terminated by the end of the docstring, so the blank line was doing nothing. Covers docstrings proper plus the doc strings held in _DOC_ATTR dicts. AI-assisted (Claude) --- music21/abcFormat/__init__.py | 2 -- music21/alpha/analysis/aligner.py | 6 ------ music21/alpha/analysis/hasher.py | 1 - music21/analysis/correlate.py | 2 -- music21/analysis/discrete.py | 6 ------ music21/analysis/harmonicFunction.py | 1 - music21/analysis/metrical.py | 1 - music21/analysis/reduceChordsOld.py | 1 - music21/analysis/reduction.py | 1 - music21/analysis/windowed.py | 2 -- music21/articulations.py | 2 -- music21/audioSearch/scoreFollower.py | 3 --- music21/base.py | 3 --- music21/beam.py | 2 -- music21/braille/basic.py | 2 -- music21/braille/noteGrouping.py | 1 - music21/braille/segment.py | 1 - music21/braille/text.py | 1 - music21/braille/translate.py | 1 - music21/capella/fromCapellaXML.py | 1 - music21/chord/__init__.py | 13 ------------- music21/clef.py | 2 -- music21/common/classTools.py | 1 - music21/common/decorators.py | 1 - music21/common/formats.py | 1 - music21/common/numberTools.py | 1 - music21/configure.py | 1 - music21/converter/subConverters.py | 1 - music21/corpus/__init__.py | 2 -- music21/corpus/corpora.py | 4 ---- music21/corpus/manager.py | 1 - music21/corpus/virtual.py | 1 - music21/duration.py | 2 -- music21/dynamics.py | 1 - music21/editorial.py | 1 - music21/environment.py | 1 - music21/expressions.py | 6 ------ music21/features/base.py | 3 --- music21/features/jSymbolic.py | 25 ------------------------- music21/features/native.py | 3 --- music21/features/outputFormats.py | 2 -- music21/figuredBass/notation.py | 1 - music21/figuredBass/possibility.py | 1 - music21/figuredBass/realizer.py | 1 - music21/freezeThaw.py | 2 -- music21/graph/__init__.py | 1 - music21/graph/axis.py | 3 --- music21/graph/findPlot.py | 3 --- music21/graph/plot.py | 8 -------- music21/graph/primitives.py | 3 --- music21/harmony.py | 5 ----- music21/instrument.py | 4 ---- music21/interval.py | 3 --- music21/key.py | 1 - music21/lily/lilyObjects.py | 4 ---- music21/lily/translate.py | 13 ------------- music21/metadata/__init__.py | 4 ---- music21/metadata/bundles.py | 2 -- music21/metadata/caching.py | 1 - music21/metadata/primitives.py | 1 - music21/meter/base.py | 2 -- music21/meter/core.py | 5 ----- music21/midi/percussion.py | 1 - music21/midi/translate.py | 2 -- music21/musedata/__init__.py | 8 -------- music21/musedata/translate.py | 1 - music21/musicxml/m21ToXml.py | 11 ----------- music21/musicxml/xmlObjects.py | 3 --- music21/musicxml/xmlToM21.py | 2 -- music21/note.py | 1 - music21/noteworthy/binaryTranslate.py | 1 - music21/noteworthy/translate.py | 7 ------- music21/omr/correctors.py | 7 ------- music21/omr/evaluators.py | 2 -- music21/pitch.py | 5 ----- music21/repeat.py | 5 ----- music21/roman.py | 5 ----- music21/romanText/clercqTemperley.py | 2 -- music21/romanText/rtObjects.py | 2 -- music21/romanText/tsvConverter.py | 2 -- music21/romanText/writeRoman.py | 2 -- music21/scale/intervalNetwork.py | 4 ---- music21/search/base.py | 1 - music21/search/lyrics.py | 1 - music21/search/segment.py | 1 - music21/serial.py | 1 - music21/sieve.py | 4 ---- music21/sites.py | 3 --- music21/spanner.py | 2 -- music21/stream/base.py | 15 --------------- music21/stream/core.py | 1 - music21/stream/filters.py | 4 ---- music21/stream/iterator.py | 1 - music21/stream/streamStatus.py | 1 - music21/stream/tools.py | 1 - music21/style.py | 1 - music21/tempo.py | 3 --- music21/text.py | 1 - music21/tree/core.py | 1 - music21/tree/fromStream.py | 1 - music21/tree/spans.py | 2 -- music21/tree/trees.py | 4 ---- music21/variant.py | 7 ------- music21/voiceLeading.py | 3 --- music21/volume.py | 1 - 105 files changed, 314 deletions(-) diff --git a/music21/abcFormat/__init__.py b/music21/abcFormat/__init__.py index 7319a00509..4adcab5256 100644 --- a/music21/abcFormat/__init__.py +++ b/music21/abcFormat/__init__.py @@ -2785,7 +2785,6 @@ def __add__(self, other: ABCHandler) -> ABCHandler: True >>> ah3.tokens[3] == ah2.tokens[0] True - ''' ah = self.__class__() # will get the same class type ah.tokens = self.tokens + other.tokens @@ -3114,7 +3113,6 @@ def _buildMeasureBoundaryIndices( [[0, 9], [10, 16], [16, 23], [23, 29], [29, 36], [36, 42], [42, 49], [49, 56], [56, 61], [62, 64], [64, 70], [70, 77], [77, 84], [84, 90], [90, 96], [96, 103], [103, 110], [110, 115]] - ''' # collect start and end pairs of split pairs = [] diff --git a/music21/alpha/analysis/aligner.py b/music21/alpha/analysis/aligner.py index 4df85e39f2..d7604ded32 100644 --- a/music21/alpha/analysis/aligner.py +++ b/music21/alpha/analysis/aligner.py @@ -176,7 +176,6 @@ def makeHashedStreams(self): >>> sa2.hashedSourceStream [NoteHashWithReference(Pitch=69, Duration=1.0, Offset=0.0), NoteHashWithReference(Pitch=67, Duration=1.0, Offset=1.0)] - ''' if not self.preHashed: self.hashedTargetStream = self.hasher.hashStream(self.targetStream) @@ -230,7 +229,6 @@ def setupDistanceMatrix(self): Traceback (most recent call last): music21.alpha.analysis.aligner.AlignerException: Cannot perform alignment with empty source stream. - ''' if not self.hashedTargetStream: self.makeHashedStreams() @@ -306,7 +304,6 @@ def populateDistanceMatrix(self): [2, 2, 2, 4], [4, 4, 3, 3], [6, 6, 5, 3]]) - ''' # calculate insert and delete costs based on the first tuple in the Source S @@ -381,7 +378,6 @@ def getPossibleMovesFromLocation(self, i, j): >>> sa.getPossibleMovesFromLocation(3, 0) [0, None, None] - ''' verticalCost = int(self.distanceMatrix[i - 1][j]) if i >= 1 else None horizontalCost = int(self.distanceMatrix[i][j - 1]) if j >= 1 else None @@ -736,7 +732,6 @@ def tupleEqualityWithoutReference(self, tup1, tup2): >>> sa.tupleEqualityWithoutReference(nhwr1, nhwr3) False - ''' for val in tup1.hashItemsKeys: if getattr(tup1, val) != getattr(tup2, val): @@ -828,7 +823,6 @@ def calculateChangesList(self): 1 >>> saD.similarityScore 0.5 - ''' i = self.n j = self.m diff --git a/music21/alpha/analysis/hasher.py b/music21/alpha/analysis/hasher.py index 9da199112c..2b271010a9 100644 --- a/music21/alpha/analysis/hasher.py +++ b/music21/alpha/analysis/hasher.py @@ -186,7 +186,6 @@ def _hashMIDIPitchName(self, e, thisChord=None): >>> r = note.Rest() >>> h._hashMIDIPitchName(r, thisChord=c) 0 - ''' if thisChord and self.hashChordsAsChords: return 1 diff --git a/music21/analysis/correlate.py b/music21/analysis/correlate.py index 563d94c393..e629da9868 100644 --- a/music21/analysis/correlate.py +++ b/music21/analysis/correlate.py @@ -45,7 +45,6 @@ class ActivityMatch: .. image:: images/ScatterWeightedPitchSpaceDynamicSymbol.* :width: 600 - ''' def __init__(self, streamObj): if not hasattr(streamObj, 'classes') or 'Stream' not in streamObj.classes: @@ -59,7 +58,6 @@ def _findActive(self, objNameSrc=None, objNameDst=None): Do the analysis, finding correlations of src with dst returns an ordered list of dictionaries, in the form {'src': obj, 'dst': [objs]} - ''' if objNameSrc is None: objNameSrc = (note.Note, chord.Chord) diff --git a/music21/analysis/discrete.py b/music21/analysis/discrete.py index 13af52e373..be51d2a462 100644 --- a/music21/analysis/discrete.py +++ b/music21/analysis/discrete.py @@ -565,14 +565,12 @@ def _likelyKeys(self, sStream): def _bestKeyEnharmonic(self, pitchObj, mode, sStream=None): ''' - >>> ks = analysis.discrete.KrumhanslSchmuckler() >>> s = converter.parse('tinynotation: 4/4 b-4 e- f g-') >>> ks._bestKeyEnharmonic(pitch.Pitch('e#'), 'minor', s) >>> ks._bestKeyEnharmonic(pitch.Pitch('f-'), 'major', s) - ''' if pitchObj is None: return None @@ -881,7 +879,6 @@ def getWeights(self, weightType='major'): 12 >>> a.getWeights('major') [16.8..., 0.8..., 12.9..., 1.4..., ...] - ''' weightType = weightType.lower() # note: only one value is different from KrumhanslSchmuckler @@ -1045,7 +1042,6 @@ def getPitchSpan(self, subStream) -> tuple[pitch.Pitch, pitch.Pitch]|None: >>> s.insert(4, harmony.ChordSymbol('C6')) >>> p.getPitchSpan(s) is None True - ''' if subStream is self._referenceStream and self.minPitchObj and self.maxPitchObj: return self.minPitchObj, self.maxPitchObj @@ -1118,7 +1114,6 @@ def solutionLegend(self, compress: bool = False) -> list[ >>> x = p.process(s.parts[1]) >>> [len(y) for y in [x for x in p.solutionLegend(compress=True)]] [2, 2] - ''' colorsUsed = [] if compress: @@ -1160,7 +1155,6 @@ def solutionUnitString(self): def solutionToColor(self, solution: int|None) -> str: ''' - >>> p = analysis.discrete.Ambitus() >>> s = stream.Stream() >>> c = chord.Chord(['a2', 'b4', 'c8']) diff --git a/music21/analysis/harmonicFunction.py b/music21/analysis/harmonicFunction.py index cee140a835..25237bf19e 100644 --- a/music21/analysis/harmonicFunction.py +++ b/music21/analysis/harmonicFunction.py @@ -178,7 +178,6 @@ def functionToRoman(thisHarmonicFunction: HarmonicFunction, >>> rn = roman.RomanNumeral('vi') >>> str(analysis.harmonicFunction.romanToFunction(rn)) 'Tp' - ''' if isinstance(keyOrScale, str): keyOrScale = key.Key(keyOrScale) diff --git a/music21/analysis/metrical.py b/music21/analysis/metrical.py index 10aa5222b9..8a20f44e08 100644 --- a/music21/analysis/metrical.py +++ b/music21/analysis/metrical.py @@ -114,7 +114,6 @@ def thomassenMelodicAccent(streamIn: stream.Stream): ('E4', 0.5561) ('D4', 0.17) ('D4', 0.0) - ''' # we use .ps instead of Intervals for speed, since # we just need perceived contours diff --git a/music21/analysis/reduceChordsOld.py b/music21/analysis/reduceChordsOld.py index 2281f8c329..adf531979a 100644 --- a/music21/analysis/reduceChordsOld.py +++ b/music21/analysis/reduceChordsOld.py @@ -154,7 +154,6 @@ def reduceMeasureToNChords(self, def computeMeasureChordWeights(self, measureObj, weightAlgorithm=None): ''' - >>> s = analysis.reduceChordsOld.testMeasureStream1().notes >>> cr = analysis.reduceChordsOld.ChordReducer() >>> cws = cr.computeMeasureChordWeights(s) diff --git a/music21/analysis/reduction.py b/music21/analysis/reduction.py index 7628593d9c..5c9dfbaddb 100644 --- a/music21/analysis/reduction.py +++ b/music21/analysis/reduction.py @@ -463,7 +463,6 @@ class PartReduction: of all parts. The default is True. If the `normalize` parameter is False, no normalization will take place. The default is True. - ''' def __init__(self, srcScore=None, diff --git a/music21/analysis/windowed.py b/music21/analysis/windowed.py index 64bead7e89..09e143d955 100644 --- a/music21/analysis/windowed.py +++ b/music21/analysis/windowed.py @@ -94,7 +94,6 @@ def getMinimumWindowStream(self, timeSignature='1/4'): >>> wa1 = analysis.windowed.WindowedAnalysis(s, p) >>> wa2 = analysis.windowed.WindowedAnalysis(s.flatten(), p) - ''' # create a stream that contains just a 1/4 time signature; this is # the minimum window size (and partitioning will be done by measure) @@ -151,7 +150,6 @@ def analyze(self, windowSize, windowType='overlap'): >>> a, b = wa.analyze(1, windowType='adjacentAverage') >>> len(a), len(b) (36, 36) - ''' maxWindowCount = len(self._windowedStream) # assuming that this is sorted diff --git a/music21/articulations.py b/music21/articulations.py index 95b03e1f11..6e4b8953f8 100644 --- a/music21/articulations.py +++ b/music21/articulations.py @@ -219,7 +219,6 @@ class TimbreArticulation(Articulation): # ------------------------------------------------------------------------------ class Accent(DynamicArticulation): ''' - >>> a = articulations.Accent() ''' def __init__(self, **keywords): @@ -246,7 +245,6 @@ def __init__(self, **keywords): class Staccato(LengthArticulation): ''' - >>> a = articulations.Staccato() ''' def __init__(self, **keywords): diff --git a/music21/audioSearch/scoreFollower.py b/music21/audioSearch/scoreFollower.py index 5d6584957d..073f116056 100644 --- a/music21/audioSearch/scoreFollower.py +++ b/music21/audioSearch/scoreFollower.py @@ -120,7 +120,6 @@ def repeatTranscription(self): False >>> print(ScF.lastNotePosition) 10 - ''' from music21 import audioSearch @@ -382,7 +381,6 @@ def updatePosition(self, prob, totalLengthPeriod, time_start): >>> exitType = ScF.updatePosition(prob, totalLengthPeriod, time_start) >>> print(exitType) countdownExceeded - ''' exitType = False @@ -462,7 +460,6 @@ def predictNextNotePosition(self, totalLengthPeriod, totalSeconds): ... totalLengthPeriod, totalSeconds) >>> print(predictedStartPosition) 18 - ''' extraLength = totalLengthPeriod * totalSeconds / self.seconds_recording middleRhythm = 0 diff --git a/music21/base.py b/music21/base.py index 76c3b76f07..2d0addf2ea 100644 --- a/music21/base.py +++ b/music21/base.py @@ -316,7 +316,6 @@ def _getEqualityAttributes(cls) -> frozenset[str]: True >>> 'pitch' in base._getEqualityAttributes(bar.Barline) False - ''' equalityAttributes = set() # equalityAttributesIgnore works, but not yet needed. @@ -2192,7 +2191,6 @@ def getAllContextsByClass(self, className): TODO: make it so that it does not skip over multiple matching classes at the same offset. with sortTuple - ''' el = self.getContextByClass(className) while el is not None: @@ -3505,7 +3503,6 @@ def splitAtDurations(self) -> _SplitTuple: ('64th', 0, (,)) TODO: unite this and other functions into a "split" function -- document obscure uses. - ''' atm = self.duration.aggregateTupletMultiplier() quarterLengthList = [opFrac(c.quarterLength * atm) for c in self.duration.components] diff --git a/music21/beam.py b/music21/beam.py index 86afb6273c..e6e258ed04 100644 --- a/music21/beam.py +++ b/music21/beam.py @@ -642,7 +642,6 @@ def setAll(self, type, direction=None): # type is okay @ReservedAssignment >>> a.setAll('sexy') Traceback (most recent call last): music21.beam.BeamException: beam type cannot be sexy - ''' if type not in ('start', 'stop', 'continue', 'partial'): raise BeamException(f'beam type cannot be {type}') @@ -679,7 +678,6 @@ def setByNumber(self, number, type, direction=None): # type is okay @ReservedAs >>> a.setByNumber(2, 'crazy') Traceback (most recent call last): music21.beam.BeamException: beam type cannot be crazy - ''' # permit providing one argument hyphenated if '-' in type: diff --git a/music21/braille/basic.py b/music21/braille/basic.py index 22d600e972..acbca7bf5b 100644 --- a/music21/braille/basic.py +++ b/music21/braille/basic.py @@ -592,7 +592,6 @@ def yieldBrailleArticulations(noteEl): ⠦ ⠨⠦ ⠸⠦ - ''' def _brailleArticulationsSortKey(inner_articulation): isBowing = isinstance(inner_articulation, articulations.Bowing) @@ -1237,7 +1236,6 @@ def transcribeHeading( ⠀⠀⠀⠀⠑⠀⠀⠀⠀⠀ ⠞⠗⠁⠝⠟⠥⠊⠇⠇⠕⠲ ⠀⠀⠀⠣⠣⠨⠉⠀⠀⠀ - ''' if (music21KeySignature is None and music21TimeSignature is None diff --git a/music21/braille/noteGrouping.py b/music21/braille/noteGrouping.py index 588a0d255f..9df8c7f030 100644 --- a/music21/braille/noteGrouping.py +++ b/music21/braille/noteGrouping.py @@ -118,7 +118,6 @@ def transcribeGroup(self, brailleElementGrouping=None): transcribe a group of notes, possibly excluding certain attributes. Returns a (unicode) string of brailleElementGrouping transcribed. - ''' self.reset() if brailleElementGrouping is not None: diff --git a/music21/braille/segment.py b/music21/braille/segment.py index 35b30b2e29..739c9fb824 100644 --- a/music21/braille/segment.py +++ b/music21/braille/segment.py @@ -697,7 +697,6 @@ def showLeadingOctaveFromNoteGrouping(self, noteGrouping: BrailleElementGrouping True >>> bs1.showLeadingOctaveFromNoteGrouping(beg1) True - ''' currentKey = self.currentGroupingKey previousKey = self.previousGroupingKey diff --git a/music21/braille/text.py b/music21/braille/text.py index 6335f59499..a5fa2f9508 100644 --- a/music21/braille/text.py +++ b/music21/braille/text.py @@ -147,7 +147,6 @@ def addToNewLine(self, brailleNoteGrouping): >>> print(str(bt)) hi ⠨⠜⠄⠹⠹⠹ - ''' self.makeNewLine() if self.rightHandSymbol or self.leftHandSymbol: diff --git a/music21/braille/translate.py b/music21/braille/translate.py index f7e19da882..1d693f551b 100644 --- a/music21/braille/translate.py +++ b/music21/braille/translate.py @@ -597,7 +597,6 @@ def measureToBraille(music21Measure, ⠼⠁⠀⠐⠽⠣⠅ >>> print(braille.translate.measureToBraille(p.measure(1))) ⠼⠙⠲⠀⠐⠽⠣⠅ - ''' measureToTranscribe = music21Measure if not inPlace: diff --git a/music21/capella/fromCapellaXML.py b/music21/capella/fromCapellaXML.py index 5410207ef9..820cf6e967 100644 --- a/music21/capella/fromCapellaXML.py +++ b/music21/capella/fromCapellaXML.py @@ -877,7 +877,6 @@ def barlineListFromBarline(self, barlineElement: ET.Element) -> list[bar.Barline >>> repeatTag = ci.domElementFromText('') >>> ci.barlineListFromBarline(repeatTag) [, ] - ''' barlineList: list[bar.Barline] = [] hasRepeatEnd = False diff --git a/music21/chord/__init__.py b/music21/chord/__init__.py index d258b3746a..3c5a16330c 100644 --- a/music21/chord/__init__.py +++ b/music21/chord/__init__.py @@ -925,7 +925,6 @@ def formatVectorString(vectorList: Iterable[int]) -> str: >>> c1.formatVectorString([10, 11, 3, 5]) '' - ''' msg = ['<'] for e in vectorList: # should be numbers @@ -1333,7 +1332,6 @@ def bass( # # >>> cmin_inv.bass() # - ''' if newbass: newbassPitch: pitch.Pitch @@ -1424,7 +1422,6 @@ def canBeTonic(self) -> bool: >>> a = chord.Chord(['g', 'b', 'd']) >>> a.canBeTonic() True - ''' if self.isMajorTriad() or self.isMinorTriad(): return True @@ -2152,7 +2149,6 @@ def hasRepeatedChordStep( >>> cChord.hasRepeatedChordStep(5) False - ''' if testRoot is None: testRoot = self.root() @@ -2189,7 +2185,6 @@ def intervalFromChordStep( >>> print(cmaj.intervalFromChordStep(6)) None - ''' if testRoot is None: try: @@ -2544,7 +2539,6 @@ def isAugmentedSixth(self, *, permitAnyInversion: bool = False) -> bool: True If `permitAnyInversion` is True then any inversion is allowed. - ''' # cardinality is just used to speed up the call to avoid checking multiple augmented # 6ths on a triad, etc. The fact that Ab C F# Gb will have cardinality of 3 @@ -2692,7 +2686,6 @@ def isConsonant(self) -> bool: >>> c13.isConsonant() False - ''' c2 = self.removeRedundantPitchNames(inPlace=False) if len(c2.pitches) == 1: @@ -2939,7 +2932,6 @@ def isGermanAugmentedSixth(self, *, permitAnyInversion=False) -> bool: >>> gr6d = chord.Chord(['A-3', 'C-4', 'E-4', 'F#4']) >>> gr6d.isGermanAugmentedSixth() False - ''' return self._isAugmentedSixthHelper( (4, 27, -1), @@ -4000,7 +3992,6 @@ def semiClosedPosition( ... ) >>> c1 - ''' c2 = self.closedPosition(forceOctave=forceOctave, inPlace=inPlace, @@ -4491,7 +4482,6 @@ def transpose(self, value, *, inPlace=False): >>> a.transpose(aInterval, inPlace=True) >>> a - ''' if hasattr(value, 'diatonic'): # it is an Interval class intervalObj = value @@ -4985,7 +4975,6 @@ def fullName(self) -> str: >>> chord.Chord(['d1', 'e4-', 'b3-'], quarterLength=2/3).fullName 'Chord {D in octave 1 | E-flat in octave 4 | B-flat in octave 3} Quarter Triplet (2/3 QL)' - ''' msg = [] sub = [] @@ -5823,7 +5812,6 @@ def fromForteClass(notation: str|Sequence[int]) -> Chord: >>> chord.fromForteClass((11, 1)) - ''' card = None num = 1 @@ -5879,7 +5867,6 @@ def fromIntervalVector(notation: Sequence[int], getZRelation: bool = False) -> C >>> chord.fromIntervalVector((1, 1, 1, 1, 1, 1)).getZRelation() - ''' addressList = None if common.isListLike(notation): diff --git a/music21/clef.py b/music21/clef.py index 7ff0c6c80c..a62569feec 100644 --- a/music21/clef.py +++ b/music21/clef.py @@ -107,7 +107,6 @@ class Clef(base.Music21Object): True >>> clef.NoClef().sign 'none' - ''', 'line': ''' The line, counting from the bottom up, that the clef resides on. @@ -602,7 +601,6 @@ class TenorClef(CClef): 'C' >>> a.line 4 - ''' def __init__(self, **keywords): diff --git a/music21/common/classTools.py b/music21/common/classTools.py index 024074b6e7..a8ce7ddeb8 100644 --- a/music21/common/classTools.py +++ b/music21/common/classTools.py @@ -84,7 +84,6 @@ def isNum(usrData: t.Any) -> t.TypeGuard[t.Union[float, int, Fraction]]: >>> from decimal import Decimal >>> common.isNum(Decimal('2.0')) True - ''' # noinspection PyBroadException try: diff --git a/music21/common/decorators.py b/music21/common/decorators.py index a71e37455b..390a33063b 100644 --- a/music21/common/decorators.py +++ b/music21/common/decorators.py @@ -125,7 +125,6 @@ def deprecated( Restore stderr at the end. >>> sys.stderr = saveStdErr - ''' if hasattr(method, '__qualname__'): funcName = method.__qualname__ diff --git a/music21/common/formats.py b/music21/common/formats.py index 7d9bf7cce3..40bbbc64b3 100644 --- a/music21/common/formats.py +++ b/music21/common/formats.py @@ -73,7 +73,6 @@ def findSubConverterForFormat(fmt: str) -> type[SubConverter]|None: >>> common.findSubConverterForFormat('t') - ''' fmt = fmt.lower().strip() from music21 import converter diff --git a/music21/common/numberTools.py b/music21/common/numberTools.py index 21c798fad1..34eb8cbd5c 100644 --- a/music21/common/numberTools.py +++ b/music21/common/numberTools.py @@ -931,7 +931,6 @@ def groupContiguousIntegers(src: list[int]) -> list[list[int]]: # noinspection SpellCheckingInspection def fromRoman(num: str, *, strictModern: bool = False) -> int: ''' - Convert a Roman numeral (upper or lower) to an int https://code.activestate.com/recipes/81611-roman-numerals/ diff --git a/music21/configure.py b/music21/configure.py index 772cee6ab7..06ffbecdd5 100644 --- a/music21/configure.py +++ b/music21/configure.py @@ -318,7 +318,6 @@ def prependPromptHeader(self, msg): def appendPromptHeader(self, msg): ''' - >>> d = configure.Dialog() >>> d.appendPromptHeader('test') >>> d._promptHeader diff --git a/music21/converter/subConverters.py b/music21/converter/subConverters.py index 2cfea252b0..f505ce45d6 100644 --- a/music21/converter/subConverters.py +++ b/music21/converter/subConverters.py @@ -61,7 +61,6 @@ class SubConverter: codecWrite = True or False (default False) if encodings need to be used to write stringEncoding = string (default 'utf-8'). If codecWrite is True, this specifies what encoding to use - ''' readBinary: bool = False canBePickled: bool = True diff --git a/music21/corpus/__init__.py b/music21/corpus/__init__.py index 7b4982374c..f369e711ff 100644 --- a/music21/corpus/__init__.py +++ b/music21/corpus/__init__.py @@ -109,7 +109,6 @@ def getCorePaths( >>> abcFilePaths = corpus.getCorePaths(fileExtensions=('abc',)) >>> len(abcFilePaths) >= 100 True - ''' return corpora.CoreCorpus().getPaths( fileExtensions=fileExtensions, @@ -267,7 +266,6 @@ def noCorpus(): >>> corpus.noCorpus() False - ''' return corpora.CoreCorpus().noCorpus diff --git a/music21/corpus/corpora.py b/music21/corpus/corpora.py index b394dc8b95..651d28485a 100644 --- a/music21/corpus/corpora.py +++ b/music21/corpus/corpora.py @@ -292,7 +292,6 @@ def getWorkList( >>> len(coreCorpus.getWorkList('verdi')) 1 - ''' if str(workName).startswith('schumann/'): # pragma: no cover # no default schumanns, but older examples showed this. @@ -396,7 +395,6 @@ def search( ... field='noteCount', ... ) - ''' return self.metadataBundle.search( query, @@ -660,7 +658,6 @@ def manualCoreCorpusPath(self): >>> #_DOCS_SHOW coreCorpus.manualCoreCorpusPath is None >>> True #_DOCS_HIDE True - ''' userSettings = environment.UserSettings() if 'manualCoreCorpusPath' in userSettings.keys(): @@ -967,7 +964,6 @@ def name(self): >>> corpus.corpora.LocalCorpus('funkCorpus').name 'funkCorpus' - ''' if self._name is None: return 'local' diff --git a/music21/corpus/manager.py b/music21/corpus/manager.py index f3fd0bba4c..5632bd3255 100644 --- a/music21/corpus/manager.py +++ b/music21/corpus/manager.py @@ -296,7 +296,6 @@ def search( If ``corpusNames`` is None, all corpora known to music21 will be searched. See usersGuide (chapter 11) for more information on searching - ''' # >>> corpus.search('coltrane', corpusNames=('virtual',)) # diff --git a/music21/corpus/virtual.py b/music21/corpus/virtual.py index 599448bd45..747264f739 100644 --- a/music21/corpus/virtual.py +++ b/music21/corpus/virtual.py @@ -77,7 +77,6 @@ def getUrlByExt(self, extList=None): class BachBWV1007Prelude(VirtualWork): ''' - >>> a = corpus.virtual.BachBWV1007Prelude() >>> a.getUrlByExt('.xml') ['https://kern.ccarh.org/cgi-bin/ksdata?l=cc/bach/cello&file=bwv1007-01.krn&f=xml'] diff --git a/music21/duration.py b/music21/duration.py index a0af8d0460..0f5616adb8 100644 --- a/music21/duration.py +++ b/music21/duration.py @@ -331,7 +331,6 @@ def dottedMatch(qLen: OffsetQLIn, >>> duration.dottedMatch(0.00001, 2) (False, False) - ''' for dots in range(maxDots + 1): # assume qLen has n dots, so find its non-dotted length @@ -1268,7 +1267,6 @@ def setDurationType( >>> a.setDurationType(4.0) >>> a.totalTupletLength() 8.0 - ''' self._checkFrozen() if not isinstance(durType, str): diff --git a/music21/dynamics.py b/music21/dynamics.py index 146ea79783..a48deb15c8 100644 --- a/music21/dynamics.py +++ b/music21/dynamics.py @@ -172,7 +172,6 @@ class Dynamic(base.Music21Object): .. image:: images/dynamics_simple.* :width: 344 - ''' classSortOrder = 10 _styleClass = style.TextStyle diff --git a/music21/editorial.py b/music21/editorial.py index 8ece0a43ce..7dde23f389 100644 --- a/music21/editorial.py +++ b/music21/editorial.py @@ -72,7 +72,6 @@ class Editorial(prebase.ProtoM21Object, dict): .. image:: images/noteEditorialFictaSharp.* :width: 103 - ''' _DOC_ATTR: dict[str, str] = { 'comments': ''' diff --git a/music21/environment.py b/music21/environment.py index dd724a2de5..2d805c429c 100644 --- a/music21/environment.py +++ b/music21/environment.py @@ -941,7 +941,6 @@ def getKeysToPaths(self): 'musicxmlPath' 'pdfPath' 'vectorPath' - ''' return envSingleton().getKeysToPaths() diff --git a/music21/expressions.py b/music21/expressions.py index 23674a0d42..95ec81cf24 100644 --- a/music21/expressions.py +++ b/music21/expressions.py @@ -179,7 +179,6 @@ class RehearsalMark(Expression): >>> rm = expressions.RehearsalMark('B') >>> rm - ''' classSortOrder = -30 _styleClass = style.TextStylePlacement @@ -220,7 +219,6 @@ def _getNumberingFromContent(c) -> str|None: >>> print(ex._getNumberingFromContent('*')) None - ''' if c is None: return None @@ -704,7 +702,6 @@ def name(self) -> str: >>> invertedMordent = expressions.InvertedMordent(accidental=sharp) >>> invertedMordent.name 'inverted mordent (sharp)' - ''' theName: str = super().name if self.accidental is not None: @@ -1270,7 +1267,6 @@ class Trill(Ornament): The size property has been removed and replaced with `.getSize()` (which requires a `srcObj` and optional `keySig` param). Added optional `keySig` param to `.realize()` as well. - ''' _direction: str = 'up' @@ -1299,7 +1295,6 @@ def name(self) -> str: >>> doubleSharpedTrill = expressions.Trill(accidental=pitch.Accidental('double-sharp')) >>> doubleSharpedTrill.name 'trill (double-sharp)' - ''' theName: str = super().name if self.accidental: @@ -1992,7 +1987,6 @@ def name(self) -> str: ... delay=1.0, lowerAccidental=pitch.Accidental('double-flat')) >>> delayedBy1Turn.name 'delayed(delayQL=1.0) turn (lower=double-flat)' - ''' theName: str = super().name if self.delay == OrnamentDelay.DEFAULT_DELAY: diff --git a/music21/features/base.py b/music21/features/base.py index f26214c57b..32e5e44812 100644 --- a/music21/features/base.py +++ b/music21/features/base.py @@ -213,7 +213,6 @@ def getAttributeLabels(self) -> list[str]: 'Fifths_Pitch_Histogram_3', 'Fifths_Pitch_Histogram_4', 'Fifths_Pitch_Histogram_5', 'Fifths_Pitch_Histogram_6', 'Fifths_Pitch_Histogram_7', 'Fifths_Pitch_Histogram_8', 'Fifths_Pitch_Histogram_9', 'Fifths_Pitch_Histogram_10', 'Fifths_Pitch_Histogram_11'] - ''' post: list[str] = [] if self.dimensions == 1: @@ -1224,7 +1223,6 @@ def extractorsById(idOrList: str|Iterable[str], >>> y = [x.id for x in features.extractorsById('all')] >>> y[0:3], y[-3:-1] (['M1', 'M2', 'M3'], ['CS12', 'MC1']) - ''' from music21.features import jSymbolic from music21.features import native @@ -1268,7 +1266,6 @@ def extractorById(idOrList: str|Iterable[str], >>> fe = features.extractorById('p20')(s) # call class >>> fe.extract().vector [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] - ''' ebi = extractorsById(idOrList=idOrList, library=library) if ebi: diff --git a/music21/features/jSymbolic.py b/music21/features/jSymbolic.py index dc48ea6abc..e98a8b876e 100644 --- a/music21/features/jSymbolic.py +++ b/music21/features/jSymbolic.py @@ -102,7 +102,6 @@ def process(self) -> None: class MostCommonMelodicIntervalFeature(featuresModule.FeatureExtractor): ''' - >>> s = corpus.parse('bwv66.6') >>> fe = features.jSymbolic.MostCommonMelodicIntervalFeature(s) >>> f = fe.extract() @@ -129,7 +128,6 @@ def process(self) -> None: class DistanceBetweenMostCommonMelodicIntervalsFeature( featuresModule.FeatureExtractor): ''' - >>> s = corpus.parse('bwv66.6') >>> fe = features.jSymbolic.DistanceBetweenMostCommonMelodicIntervalsFeature(s) >>> f = fe.extract() @@ -192,7 +190,6 @@ def process(self) -> None: class RelativeStrengthOfMostCommonIntervalsFeature( featuresModule.FeatureExtractor): ''' - >>> s = corpus.parse('bwv66.6') >>> fe = features.jSymbolic.RelativeStrengthOfMostCommonIntervalsFeature(s) >>> f = fe.extract() @@ -856,7 +853,6 @@ def process(self) -> None: class RelativeStrengthOfTopPitchClassesFeature(featuresModule.FeatureExtractor): ''' - >>> s = corpus.parse('bwv66.6') >>> fe = features.jSymbolic.RelativeStrengthOfTopPitchClassesFeature(s) >>> fe.extract().vector @@ -924,7 +920,6 @@ def process(self) -> None: class IntervalBetweenStrongestPitchClassesFeature( featuresModule.FeatureExtractor): ''' - >>> s = corpus.parse('bwv66.6') >>> fe = features.jSymbolic.IntervalBetweenStrongestPitchClassesFeature(s) >>> fe.extract().vector @@ -1495,7 +1490,6 @@ class VibratoPrevalenceFeature(featuresModule.FeatureExtractor): Number of notes for which Pitch Bend messages change direction at least twice divided by total number of notes that have Pitch Bend messages associated with them. - ''' id = 'P25' name = 'Vibrato Prevalence' @@ -1516,7 +1510,6 @@ class PrevalenceOfMicrotonesFeature(featuresModule.FeatureExtractor): Number of Note Ons that are preceded by isolated MIDI Pitch Bend messages as a fraction of the total number of Note Ons.' - ''' id = 'P26' name = 'Prevalence Of Microtones' @@ -1580,7 +1573,6 @@ class SecondStrongestRhythmicPulseFeature(featuresModule.FeatureExtractor): >>> f = fe.extract() >>> f.vector [192] - ''' id = 'R2' name = 'Second Strongest Rhythmic Pulse' @@ -1616,7 +1608,6 @@ class HarmonicityOfTwoStrongestRhythmicPulsesFeature( >>> f = fe.extract() >>> f.vector [0.5] - ''' id = 'R3' name = 'Harmonicity of Two Strongest Rhythmic Pulses' @@ -1699,7 +1690,6 @@ class StrengthRatioOfTwoStrongestRhythmicPulsesFeature( >>> fe = features.jSymbolic.StrengthRatioOfTwoStrongestRhythmicPulsesFeature(sch) >>> fe.extract().vector[0] 7.0 - ''' id = 'R6' name = 'Strength Ratio of Two Strongest Rhythmic Pulses' @@ -1756,7 +1746,6 @@ class NumberOfStrongPulsesFeature(featuresModule.FeatureExtractor): Not yet implemented. Number of beat peaks with normalized frequencies over 0.1. - ''' id = 'R8' name = 'Number of Strong Pulses' @@ -1874,7 +1863,6 @@ class BeatHistogramFeature(featuresModule.FeatureExtractor): A feature extractor that finds a feature array with entries corresponding to the frequency values of each of the bins of the beat histogram (except the first 40 empty ones). - ''' id = 'R14' name = 'Beat Histogram' @@ -2608,7 +2596,6 @@ class VariationOfDynamicsFeature(featuresModule.FeatureExtractor): Standard deviation of loudness levels of all notes. TODO: implement - ''' id = 'D2' name = 'Variation of Dynamics' @@ -2623,7 +2610,6 @@ class VariationOfDynamicsInEachVoiceFeature(featuresModule.FeatureExtractor): channel that contains at least one note. TODO: implement - ''' id = 'D3' name = 'Variation of Dynamics In Each Voice' @@ -2639,7 +2625,6 @@ class AverageNoteToNoteDynamicsChangeFeature(featuresModule.FeatureExtractor): same channel (in MIDI velocity units). TODO: implement - ''' id = 'D4' @@ -2789,7 +2774,6 @@ class VoiceEqualityNoteDurationFeature(featuresModule.FeatureExtractor): Not implemented. TODO: implement - ''' id = 'T5' name = 'Voice Equality - Note Duration' @@ -2802,7 +2786,6 @@ class VoiceEqualityDynamicsFeature(featuresModule.FeatureExtractor): Not implemented. TODO: implement - ''' id = 'T6' name = 'Voice Equality - Dynamics' @@ -2815,7 +2798,6 @@ class VoiceEqualityMelodicLeapsFeature(featuresModule.FeatureExtractor): Not implemented. TODO: implement - ''' id = 'T7' name = 'Voice Equality - Melodic Leaps' @@ -2886,7 +2868,6 @@ class RelativeNoteDensityOfHighestLineFeature(featuresModule.FeatureExtractor): Not implemented. TODO: implement - ''' id = 'T13' name = 'Relative Note Density of Highest Line' @@ -3027,7 +3008,6 @@ def process(self) -> None: class NotePrevalenceOfPitchedInstrumentsFeature( featuresModule.FeatureExtractor): ''' - >>> s1 = stream.Stream() >>> s1.append(instrument.AcousticGuitar()) >>> s1.repeatAppend(note.Note(), 4) @@ -3089,7 +3069,6 @@ class NotePrevalenceOfUnpitchedInstrumentsFeature( Not implemented. TODO: implement - ''' id = 'I4' name = 'Note Prevalence of Unpitched Instruments' @@ -3118,7 +3097,6 @@ class TimePrevalenceOfPitchedInstrumentsFeature( in seconds of the piece.' TODO: implement - ''' id = 'I5' name = 'Time Prevalence of Pitched Instruments' @@ -3146,7 +3124,6 @@ class VariabilityOfNotePrevalenceOfPitchedInstrumentsFeature( >>> fe = features.jSymbolic.VariabilityOfNotePrevalenceOfPitchedInstrumentsFeature(s1) >>> fe.extract().vector [0.33333...] - ''' id = 'I6' name = 'Variability of Note Prevalence of Pitched Instruments' @@ -3190,7 +3167,6 @@ class VariabilityOfNotePrevalenceOfUnpitchedInstrumentsFeature( official standard. TODO: implement - ''' id = 'I7' name = 'Variability of Note Prevalence of Unpitched Instruments' @@ -3213,7 +3189,6 @@ class NumberOfPitchedInstrumentsFeature(featuresModule.FeatureExtractor): >>> fe = features.jSymbolic.NumberOfPitchedInstrumentsFeature(s1) >>> fe.extract().vector [2] - ''' id = 'I8' name = 'Number of Pitched Instruments' diff --git a/music21/features/native.py b/music21/features/native.py index 6a7cce1731..214602229a 100644 --- a/music21/features/native.py +++ b/music21/features/native.py @@ -87,7 +87,6 @@ class QualityFeature(featuresModule.FeatureExtractor): # for monophonic melodies # incomplete measures / pickups for monophonic melodies - ''' id = 'P22' name = 'Quality' @@ -741,7 +740,6 @@ class ChordBassMotionFeature(featuresModule.FeatureExtractor): 0.0, 0.0, 0.07..., 0.008...] Post 1990s music has a lot more semitone motion. - ''' id = 'CS12' name = 'Chord Bass Motion' @@ -880,7 +878,6 @@ class LanguageFeature(featuresModule.FeatureExtractor): >>> fe = features.native.LanguageFeature(s) >>> fe.extract().vector [3] - ''' id = 'TX1' name = 'Language Feature' diff --git a/music21/features/outputFormats.py b/music21/features/outputFormats.py index 5e6a06d7eb..b163329815 100644 --- a/music21/features/outputFormats.py +++ b/music21/features/outputFormats.py @@ -88,7 +88,6 @@ def getHeaderLines(self, includeClassLabel: bool = True, ['Identifier', 'Changes_of_Meter', 'Composer'] ['string', 'discrete', 'discrete'] ['meta', '', 'class'] - ''' if self._dataSet is None: # pragma: no cover raise OutputFormatException('cannot get header lines without a DataSet') @@ -217,7 +216,6 @@ def getHeaderLines(self, includeClassLabel: bool = True, @ATTRIBUTE Changes_of_Meter NUMERIC @ATTRIBUTE class {} @DATA - ''' if self._dataSet is None: # pragma: no cover raise OutputFormatException('cannot get header lines without a DataSet') diff --git a/music21/figuredBass/notation.py b/music21/figuredBass/notation.py index 86c1cb8627..e679f41d91 100644 --- a/music21/figuredBass/notation.py +++ b/music21/figuredBass/notation.py @@ -641,7 +641,6 @@ def _reprInternal(self) -> str: def _toAccidental(self) -> pitch.Accidental|None: ''' - >>> from music21.figuredBass import notation as n >>> m1 = n.Modifier('#') >>> m2 = n.Modifier('-') diff --git a/music21/figuredBass/possibility.py b/music21/figuredBass/possibility.py index 6c5bc64565..7ee1e1e146 100644 --- a/music21/figuredBass/possibility.py +++ b/music21/figuredBass/possibility.py @@ -944,7 +944,6 @@ def partPairs( (, ), (, ), (, )] - ''' return list(zip(possibA, possibB, strict=True)) diff --git a/music21/figuredBass/realizer.py b/music21/figuredBass/realizer.py index 2011a60007..7e2c0a2376 100644 --- a/music21/figuredBass/realizer.py +++ b/music21/figuredBass/realizer.py @@ -456,7 +456,6 @@ def realize( >>> r4 = fbLine4.realize() >>> r4.getNumSolutions() 13 - ''' if fbRules is None: fbRules = rules.Rules() diff --git a/music21/freezeThaw.py b/music21/freezeThaw.py index 3176ec6fc3..c8f25caf8b 100644 --- a/music21/freezeThaw.py +++ b/music21/freezeThaw.py @@ -230,7 +230,6 @@ def packStream(self, streamObj=None): >>> sf = freezeThaw.StreamFreezer(s) >>> pprint(sf.packStream()) {'m21Version': (...), 'stream': } - ''' # do all things necessary to set up the stream if streamObj is None: @@ -442,7 +441,6 @@ def setupStoredElementOffsetTuples(self, streamObj): (, 'end')] >>> s2._storedElementOffsetTuples[2][0] is v1 True - ''' if hasattr(streamObj, '_storedElementOffsetTuples'): # in the case of a spanner storing a Stream, like a StaffGroup diff --git a/music21/graph/__init__.py b/music21/graph/__init__.py index aa362942d6..6e86c6f193 100644 --- a/music21/graph/__init__.py +++ b/music21/graph/__init__.py @@ -134,7 +134,6 @@ def plotStream( .. image:: images/HorizontalBarPitchSpaceOffset.* :width: 600 - ''' plotMake = findPlot.getPlotsToMake(graphFormat, xValue, yValue, zValue) # environLocal.printDebug(['plotClassName found', plotMake]) diff --git a/music21/graph/axis.py b/music21/graph/axis.py index 30630ebd85..807b4fcea4 100644 --- a/music21/graph/axis.py +++ b/music21/graph/axis.py @@ -121,7 +121,6 @@ def _reprInternal(self): >>> axStream = graph.axis.DynamicsAxis(s, axisName='y') >>> axStream - ''' c = self.client if c is not None: @@ -1034,7 +1033,6 @@ def getOffsetMap(self): >>> om3 = ax.getOffsetMap() >>> om3 {} - ''' s = self.stream if s is None: @@ -1322,7 +1320,6 @@ def ticks(self): >>> ax.maxValue = 6 >>> ax.ticks() [(3, '$ppp$'), (4, '$pp$'), (5, '$p$'), (6, '$mp$')] - ''' ticks = [] if self.minValue is None: diff --git a/music21/graph/findPlot.py b/music21/graph/findPlot.py index dee2df5c91..7dfd5e222d 100644 --- a/music21/graph/findPlot.py +++ b/music21/graph/findPlot.py @@ -109,7 +109,6 @@ def getAxisQuantities(synonyms=False, axesToCheck=None): >>> graph.findPlot.getAxisQuantities(True, axesToCheck=theseAxes) ['count', 'quantity', 'frequency', 'counting', 'offset', 'measure', 'offsets', 'measures', 'time'] - ''' if axesToCheck is None: axesToCheck = getAxisClasses() @@ -167,7 +166,6 @@ def getPlotClassesFromFormat(graphFormat, checkPlotClasses=None): >>> pcs = [graph.plot.ScatterWeighted, graph.plot.Dolan] >>> graph.findPlot.getPlotClassesFromFormat('scatterweighted', pcs) [] - ''' graphFormat = userFormatsToFormat(graphFormat).lower() @@ -306,7 +304,6 @@ def getPlotsToMake(graphFormat: str|None = None, OrderedDict({'x': , 'y': , 'z': }))] - ''' def _bestPlotType(graphClassesToChooseFrom): # now get the best graph type from this possibly motley list diff --git a/music21/graph/plot.py b/music21/graph/plot.py index eb87a027e9..9b10fbbc7d 100644 --- a/music21/graph/plot.py +++ b/music21/graph/plot.py @@ -671,7 +671,6 @@ class HistogramPitchClass(Histogram): .. image:: images/HistogramPitchClass.* :width: 600 - ''' axesClasses: dict[str, type[axis.Axis]] = { **Histogram.axesClasses, @@ -699,7 +698,6 @@ class HistogramQuarterLength(Histogram): .. image:: images/HistogramQuarterLength.* :width: 600 - ''' axesClasses: dict[str, type[axis.Axis]] = { **Histogram.axesClasses, @@ -779,7 +777,6 @@ class ScatterWeightedPitchClassQuarterLength(ScatterWeighted): .. image:: images/ScatterWeightedPitchClassQuarterLength.* :width: 600 - ''' axesClasses: dict[str, type[axis.Axis]] = { **ScatterWeighted.axesClasses, @@ -814,7 +811,6 @@ class ScatterWeightedPitchSpaceDynamicSymbol(ScatterWeighted): .. image:: images/ScatterWeightedPitchSpaceDynamicSymbol.* :width: 600 - ''' axesClasses: dict[str, type[axis.Axis]] = { **ScatterWeighted.axesClasses, @@ -1009,7 +1005,6 @@ class WindowedKey(WindowedAnalysis): >>> p.processorClass = analysis.discrete.TemperleyKostkaPayne >>> p.doneAction = None #_DOCS_HIDE >>> p.run() - ''' processorClassDefault = discrete.KrumhanslSchmuckler @@ -1027,7 +1022,6 @@ class WindowedAmbitus(WindowedAnalysis): :width: 600 .. image:: images/legend-WindowedAmbitus.* - ''' processorClassDefault = discrete.Ambitus @@ -1174,7 +1168,6 @@ class HorizontalBarPitchClassOffset(HorizontalBar): .. image:: images/HorizontalBarPitchClassOffset.* :width: 600 - ''' axesClasses: dict[str, type[axis.Axis]] = { **HorizontalBar.axesClasses, @@ -1305,7 +1298,6 @@ class Dolan(HorizontalBarWeighted): .. image:: images/Dolan.* :width: 600 - ''' def __init__(self, streamObj=None, **keywords): diff --git a/music21/graph/primitives.py b/music21/graph/primitives.py index 526c2dc4b5..fe460b19ea 100644 --- a/music21/graph/primitives.py +++ b/music21/graph/primitives.py @@ -739,7 +739,6 @@ class GraphColorGridLegend(Graph): .. image:: images/GraphColorGridLegend.* :width: 600 - ''' _DOC_ATTR: dict[str, str] = { 'hideLeftBottomSpines': 'bool to hide the left and bottom axis spines; default True', @@ -914,7 +913,6 @@ class GraphHorizontalBar(Graph): To make an equally spaced plot, like in a Pitch Space plot, leave empty data in the form: `('', [], {})` - ''' _DOC_ATTR: dict[str, str] = { 'barSpace': 'Amount of vertical space each bar takes; default 8', @@ -1190,7 +1188,6 @@ class GraphScatterWeighted(Graph): .. image:: images/GraphScatterWeighted.* :width: 600 - ''' _DOC_ATTR: dict[str, str] = { 'maxDiameter': 'the maximum diameter of any ellipse, default 1.25', diff --git a/music21/harmony.py b/music21/harmony.py index ec9dabb64c..f9d152f2c7 100644 --- a/music21/harmony.py +++ b/music21/harmony.py @@ -1177,7 +1177,6 @@ def chordSymbolFigureFromChord(inChord: chord.Chord, includeChordType=False): OMIT_FROM_DOCS >>> harmony.changeAbbreviationFor('major', '') - ''' if not inChord.pitches: return '' @@ -1212,7 +1211,6 @@ def compare(inChordNums, givenChordNums, permittedOmissions=()): The corresponding semitones are compared, and if they do not match it is determined whether this is a permitted omission, etc. - ''' m = len(givenChordNums) if m > len(inChordNums): @@ -1393,7 +1391,6 @@ def getAbbreviationListGivenChordType(chordType): >>> harmony.getAbbreviationListGivenChordType('minor-major-13th') ['mM13', 'minmaj13'] - ''' return CHORD_TYPES[chordType][1] @@ -1405,7 +1402,6 @@ def getCurrentAbbreviationFor(chordType): >>> harmony.getCurrentAbbreviationFor('dominant-seventh') '7' - ''' return getAbbreviationListGivenChordType(chordType)[0] @@ -1417,7 +1413,6 @@ def getNotationStringGivenChordType(chordType): >>> harmony.getNotationStringGivenChordType('German') '1,-3,#4,-6' - ''' return CHORD_TYPES[chordType][0] diff --git a/music21/instrument.py b/music21/instrument.py index 16772e6d23..16becc2d64 100644 --- a/music21/instrument.py +++ b/music21/instrument.py @@ -104,7 +104,6 @@ def bundleInstruments(streamIn: stream.Stream, Bass Drum Bass Drum Cowbell - ''' if inPlace: s = streamIn @@ -332,7 +331,6 @@ def __init__(self, **keywords): class Piano(KeyboardInstrument): ''' - >>> p = instrument.Piano() >>> p.instrumentName 'Piano' @@ -398,7 +396,6 @@ def __init__(self, **keywords): class ElectricPiano(Piano): ''' - >>> p = instrument.ElectricPiano() >>> p.instrumentName 'Electric Piano' @@ -2545,7 +2542,6 @@ def getAllNamesForInstrument(instrumentClass: Instrument, 'english', 'french', 'german', 'italian', 'russian', 'spanish', and 'abbreviation'. Note that the language string is not case-sensitive, so 'German' is also fine. - ''' language = language.lower() diff --git a/music21/interval.py b/music21/interval.py index df3357e4f9..3dde7bc268 100644 --- a/music21/interval.py +++ b/music21/interval.py @@ -1853,7 +1853,6 @@ def direction(self) -> Direction: >>> interval.DiatonicInterval('A', 1).generic.direction - ''' if self.generic.undirected != 1: return self.generic.direction @@ -2777,7 +2776,6 @@ def intervalFromGenericAndChromatic( >>> interval.intervalFromGenericAndChromatic(1, 0.5) - ''' gIntV: GenericInterval if not isinstance(gInt, GenericInterval): @@ -4096,7 +4094,6 @@ def subtract(intervalList): 'Descending Diminished Unison' >>> a.chromatic.semitones -1 - ''' from music21 import pitch if not intervalList: diff --git a/music21/key.py b/music21/key.py index 05a2d69a01..ffc80d7ca4 100644 --- a/music21/key.py +++ b/music21/key.py @@ -503,7 +503,6 @@ def alteredPitches(self) -> list[pitch.Pitch]: >>> nonTrad2.isNonTraditional = True >>> nonTrad2.alteredPitches [] - ''' if self._alteredPitches is not None: return self._alteredPitches diff --git a/music21/lily/lilyObjects.py b/music21/lily/lilyObjects.py index 7b354b8fb1..c7253e4124 100644 --- a/music21/lily/lilyObjects.py +++ b/music21/lily/lilyObjects.py @@ -487,7 +487,6 @@ def stringOutput(self) -> str: class LyIdentifierInit(LyObject): r''' - >>> lyIdInit = lily.lilyObjects.LyIdentifierInit(string='hello') >>> print(lyIdInit) "hello" @@ -856,7 +855,6 @@ def stringOutput(self) -> str: class LyOutputDefBody(LyObject): r''' - output_def_body: output_def_head_with_mode_switch '{' | output_def_head_with_mode_switch '{' @@ -1956,7 +1954,6 @@ class LyScriptAbbreviation(LyObject): Holds a script abbreviation (for articulations etc.), one of:: ^ + - | > . _ - ''' def __init__(self, value: str = '') -> None: super().__init__() @@ -1971,7 +1968,6 @@ class LyScriptDir(LyObject): Holds a script direction abbreviation (above, below etc.), one of:: _ ^ - - ''' def __init__(self, value: str = '') -> None: super().__init__() diff --git a/music21/lily/translate.py b/music21/lily/translate.py index 35e87bed4b..c573246baa 100644 --- a/music21/lily/translate.py +++ b/music21/lily/translate.py @@ -360,7 +360,6 @@ def loadObjectFromOpus(self, opusIn: stream.Opus, makeNotation: bool = True) -> def loadObjectFromScore(self, scoreIn: stream.Score, makeNotation: bool = True) -> None: r''' - creates a filled topLevelObject (lily.lilyObjects.LyLilypondTop) whose string representation accurately reflects this Score object. @@ -1153,7 +1152,6 @@ def appendContextFromNoteOrRest(self, noteOrRest: note.GeneralNote) -> None: fis' 4 - ''' # to be removed once grace notes are supported if noteOrRest.duration.isGrace: @@ -1218,7 +1216,6 @@ def appendContextFromChord(self, chordIn: chord.Chord) -> None: < c' f' aes' > 4 - ''' self.setContextForTupletStart(chordIn) self.appendBeamCode(chordIn) @@ -1362,7 +1359,6 @@ def appendBeamCode(self, noteOrChord: note.GeneralNote) -> None: [] >>> print(lpc.context) \set stemLeftBeamCount = #2 - ''' leftBeams = 0 rightBeams = 0 @@ -1421,7 +1417,6 @@ def appendStemCode(self, noteOrChord: note.GeneralNote) -> None: def lySimpleMusicFromChord(self, chordObj: chord.Chord) -> lyo.LySimpleMusic: ''' - >>> conv = lily.translate.LilypondConverter() >>> c1 = chord.Chord(['C#2', 'E4', 'D#5']) >>> c1.quarterLength = 3.5 @@ -1614,7 +1609,6 @@ def lyEmbeddedScmFromClef(self, clefObj: clef.Clef) -> lyo.LyEmbeddedScm: >>> lpEmbeddedScm = conv.lyEmbeddedScmFromClef(t8c) >>> print(lpEmbeddedScm) \clef "treble_8" - ''' dictTranslate = OrderedDict([ ('Treble8vbClef', 'treble_8'), @@ -1661,7 +1655,6 @@ def lyEmbeddedScmFromKeySignature(self, keyObj: key.KeySignature) -> lyo.LyEmbed >>> fSharp = key.KeySignature(6) >>> print(conv.lyEmbeddedScmFromKeySignature(fSharp)) \key fis \major - ''' keyAsKey = keyObj if isinstance(keyObj, key.Key) else keyObj.asKey('major') @@ -1896,7 +1889,6 @@ def lyPrefixCompositeMusicFromRelatedVariants( ) -> tuple[lyo.LyPrefixCompositeMusic, stream.Stream]: # noinspection PyShadowingNames r''' - >>> s1 = converter.parse('tinynotation: 4/4 a4 a a a a1') >>> s2 = converter.parse('tinynotation: 4/4 b4 b b b') >>> s3 = converter.parse('tinynotation: 4/4 c4 c c c') @@ -1988,7 +1980,6 @@ def lyPrefixCompositeMusicFromRelatedVariants( } - ''' # Order List @@ -2121,7 +2112,6 @@ def lyPrefixCompositeMusicFromVariant( ) -> lyo.LyPrefixCompositeMusic: # noinspection PyShadowingNames r''' - >>> pStream = converter.parse('tinynotation: 4/4 a4 b c d e4 f g a') >>> pStream.makeMeasures(inPlace=True) >>> p = stream.Part(pStream.elements) @@ -2156,7 +2146,6 @@ def lyPrefixCompositeMusicFromVariant( >>> print(lpc.addedVariants) ['london'] - ''' replacedElementsClef = replacedElements[0].getContextByClass(clef.Clef) @@ -2458,7 +2447,6 @@ def writeLyFile(self, ext: str = '', fp: str|pathlib.Path|None = None) -> pathli The extension should be ly. If fp is None then a named temporary file is created by environment.getTempFile. - ''' tloOut = str(self.topLevelObject) if fp is None: @@ -2487,7 +2475,6 @@ def runThroughLily( If skipWriting is True and a fileName is given then it will run that file through lilypond instead - ''' LILYEXEC = self.findLilyExec() if fileName is None: diff --git a/music21/metadata/__init__.py b/music21/metadata/__init__.py index e08de8796b..7f6b67aa58 100755 --- a/music21/metadata/__init__.py +++ b/music21/metadata/__init__.py @@ -985,7 +985,6 @@ def __setitem__(self, key: str, value: t.Any|Iterable[t.Any]): >>> md[3] = ['180 minutes'] Traceback (most recent call last): KeyError: 'metadata key must be str' - ''' if not isinstance(key, str): raise KeyError('metadata key must be str') @@ -1990,7 +1989,6 @@ def _isStandardUniqueName(self, uniqueName: str) -> bool: >>> md._isStandardUniqueName('ambitus') False - ''' return uniqueName in properties.UNIQUE_NAME_TO_PROPERTY_DESCRIPTION @@ -2498,7 +2496,6 @@ class RichMetadata(Metadata): Because RichMetadata is a Music21Object, `quarterLength` is a property that must return the length of the RichMetadata object itself and should not have been ovewritten - ''' # CLASS VARIABLES # @@ -2566,7 +2563,6 @@ def merge(self, other, favorSelf=False): >>> richMetadata.merge(md) >>> richMetadata.title 'Concerto in F' - ''' # specifically name attributes to copy, as do not want to get all # Metadata is a m21 object diff --git a/music21/metadata/bundles.py b/music21/metadata/bundles.py index efa17c2af6..3475312fb6 100644 --- a/music21/metadata/bundles.py +++ b/music21/metadata/bundles.py @@ -347,7 +347,6 @@ def __eq__(self, other): True >>> bachBundle == 'foo' False - ''' if hasattr(other, '_metadataEntries'): if self._metadataEntries == other._metadataEntries: @@ -1096,7 +1095,6 @@ def read(self, filePath=None): Traceback (most recent call last): music21.exceptions21.MetadataException: Unnamed MetadataBundles have no default file path to read from. - ''' timer = common.Timer() timer.start() diff --git a/music21/metadata/caching.py b/music21/metadata/caching.py index 01b4efe1bd..745b804941 100644 --- a/music21/metadata/caching.py +++ b/music21/metadata/caching.py @@ -316,7 +316,6 @@ def process_parallel(jobs, processCount=None): available cores. jobs is a list of :class:`~music21.metadata.MetadataCachingJob` objects. - ''' processCount = processCount or common.cpus() processCount = max(processCount, 1) diff --git a/music21/metadata/primitives.py b/music21/metadata/primitives.py index 8f73d12c07..14df0e7498 100644 --- a/music21/metadata/primitives.py +++ b/music21/metadata/primitives.py @@ -453,7 +453,6 @@ def hasError(self): ... ) >>> b.hasError False - ''' for attr in self.attrNames: if getattr(self, attr + 'Error') is not None: diff --git a/music21/meter/base.py b/music21/meter/base.py index 835752ba93..e0bd305667 100644 --- a/music21/meter/base.py +++ b/music21/meter/base.py @@ -497,7 +497,6 @@ class TimeSignature(TimeSignatureBase): >>> another44 = meter.TimeSignature() # '4/4' by default >>> one44 == another44 True - ''' _styleClass = style.TextStyle classSortOrder = 4 @@ -1261,7 +1260,6 @@ def _setDefaultAccentWeights(self, depth: int = 3) -> None: >>> ts2._setDefaultAccentWeights(3) # lower depth >>> [mt.weight for mt in ts2.accentSequence] [1.0, 0.125, 0.25, 0.125, 0.5, 0.125, 0.25, 0.125, 0.5, 0.125, 0.25, 0.125] - ''' # NOTE: this is a performance critical method firstPartitionForm: MeterSequence|int|None diff --git a/music21/meter/core.py b/music21/meter/core.py index f3fb0b52b7..9a2a468764 100644 --- a/music21/meter/core.py +++ b/music21/meter/core.py @@ -682,7 +682,6 @@ def partitionByCount(self, countRequest: int, loadDefault: bool = True) -> None: >>> a.partitionByCount(11, loadDefault=False) Traceback (most recent call last): music21.exceptions21.MeterException: Cannot set partition by 11 (5/8) - ''' opts = self.getPartitionOptions() optMatch = None @@ -962,7 +961,6 @@ def subdividePartitionsEqual(self, divisions: int|None = None) -> None: >>> ms.subdividePartitionsEqual(5) Traceback (most recent call last): music21.exceptions21.MeterException: Cannot set partition by 5 (3/8) - ''' divisionsLocal: int = 1 for i in range(len(self)): @@ -1024,7 +1022,6 @@ def _subdivideNested(self, processObjList, divisions): False >>> post2[0] is ms[0][0] True - ''' for obj in processObjList: obj.subdividePartitionsEqual(divisions) @@ -1957,7 +1954,6 @@ def offsetToSpan(self, qLenPos, permitMeterModulus=False): >>> a.offsetToSpan(4.33333336, permitMeterModulus=True) (1.0, 2.0) - ''' qLenPos = opFrac(qLenPos) if qLenPos >= self.duration.quarterLength or qLenPos < 0: @@ -1997,7 +1993,6 @@ def offsetToWeight(self, qLenPos): Fraction(1, 3) >>> a.offsetToWeight(1.5) Fraction(1, 3) - ''' # Not sure what this does! qLenPos = opFrac(qLenPos) diff --git a/music21/midi/percussion.py b/music21/midi/percussion.py index 3cb11ec5eb..b36105214a 100644 --- a/music21/midi/percussion.py +++ b/music21/midi/percussion.py @@ -144,7 +144,6 @@ def midiPitchToInstrument(self, midiPitch: int|pitch.Pitch) -> instrument.Instru >>> oneBDInstrument.modifier '1' - ''' if isinstance(midiPitch, int): diff --git a/music21/midi/translate.py b/music21/midi/translate.py index f39564330f..6f80058da5 100644 --- a/music21/midi/translate.py +++ b/music21/midi/translate.py @@ -177,7 +177,6 @@ def ticksToDuration( '64th' >>> d2.components[2].dots 1 - ''' if inputM21DurationObject is None: d = duration.Duration() @@ -984,7 +983,6 @@ def midiEventsToTimeSignature( >>> ts = midi.translate.midiEventsToTimeSignature(me2) >>> ts - ''' # http://www.sonicspot.com/guide/midifiles.html # The time signature defined with 4 bytes, a numerator, a denominator, diff --git a/music21/musedata/__init__.py b/music21/musedata/__init__.py index 941fc5e9c7..966304b88c 100644 --- a/music21/musedata/__init__.py +++ b/music21/musedata/__init__.py @@ -159,7 +159,6 @@ def isBack(self): def _getPitchParameters(self): ''' - >>> mdr = musedata.MuseDataRecord('Ef4 1 s d ==') >>> mdr.isNote() True @@ -397,7 +396,6 @@ def getBeams(self): >>> mdr = musedata.MuseDataRecord('E2 4 q u') >>> mdr.getBeams() is None True - ''' if self.stage == 1: return None @@ -458,7 +456,6 @@ def getArticulationObjects(self): >>> mdr = musedata.MuseDataRecord('C4 12 e u [ .p>') >>> mdr.getArticulationObjects() [, ] - ''' from music21 import articulations post = [] @@ -498,7 +495,6 @@ def getExpressionObjects(self): >>> mdr = musedata.MuseDataRecord('C4 12 e u [ .p>F') >>> mdr.getExpressionObjects() [] - ''' from music21 import expressions post = [] @@ -574,7 +570,6 @@ def hasCautionaryAccidental(self): >>> mdr = musedata.MuseDataRecord('C4 12 e u [') >>> mdr.hasCautionaryAccidental() False - ''' data = self._getAdditionalNotations() if data is None: @@ -833,7 +828,6 @@ def _scrubStage1(self, src): def _getDigitsFollowingTag(self, line, tag): ''' - >>> mdp = musedata.MuseDataPart() >>> mdp._getDigitsFollowingTag('junk WK#:2345', 'WK#:') '2345' @@ -864,7 +858,6 @@ def _getDigitsFollowingTag(self, line, tag): def _getAlphasFollowingTag(self, line, tag, keepSpace=False, keepCase=False): ''' - >>> mdp = musedata.MuseDataPart() >>> mdp._getAlphasFollowingTag('Group memberships: sound, score', 'Group memberships:') 'sound,score' @@ -1386,7 +1379,6 @@ def getDivisionsPerQuarterNote(self): def _getMeasureBoundaryIndices(self, src=None): ''' - >>> mdp = musedata.MuseDataPart() >>> mdp.stage is None True diff --git a/music21/musedata/translate.py b/music21/musedata/translate.py index 58ded0dd53..6f95655db5 100644 --- a/music21/musedata/translate.py +++ b/music21/musedata/translate.py @@ -43,7 +43,6 @@ def _musedataBeamToBeams(beamSymbol): >>> translate._musedataBeamToBeams(r']/') # must escape backslash /> - ''' from music21 import beam diff --git a/music21/musicxml/m21ToXml.py b/music21/musicxml/m21ToXml.py index d859d1ff67..605810d917 100644 --- a/music21/musicxml/m21ToXml.py +++ b/music21/musicxml/m21ToXml.py @@ -218,7 +218,6 @@ def _setTagTextFromAttribute( >>> subEl = seta(acc, e, 'alter', transform=int) >>> subEl.text '-2' - ''' if attributeName is None: attributeName = common.hyphenToCamelCase(tag) @@ -543,7 +542,6 @@ def fromDynamic(self, dynamicObject): ''' Provide a complete MusicXML string from a single dynamic by putting it into a Stream first. - ''' dCopy = copy.deepcopy(dynamicObject) out = stream.Stream() @@ -1233,7 +1231,6 @@ def staffLayoutToXmlStaffLayout(self, staffLayout, mxStaffLayoutIn=None): 40.0 - ''' if mxStaffLayoutIn is None: mxStaffLayout = Element('staff-layout') @@ -1494,7 +1491,6 @@ def scorePreliminaries(self) -> None: 0 >>> emptySX.spannerBundle - ''' self.setScoreLayouts() self.setMeterStream() @@ -2482,7 +2478,6 @@ def getSupports(self) -> list[Element]: >>> SX.stream.definesExplicitPageBreaks = True >>> SX.dump(SX.getSupports()[-1]) - ''' def getSupport(element: str, supports_type: bool, attribute: str|None = None, value: str|None = None): @@ -3193,7 +3188,6 @@ def moveForward(self, byOffset: OffsetQL): >>> len(MEX.xmlRoot) 1 - ''' amountToMoveForward: int = int(round(byOffset * self.currentDivisions)) if amountToMoveForward: @@ -4785,7 +4779,6 @@ def tupletToTimeModification(self, tup) -> Element: - ''' mxTimeModification = Element('time-modification') _setTagTextFromAttribute(tup, mxTimeModification, 'actual-notes', 'numberNotesActual') @@ -6235,7 +6228,6 @@ def dynamicToXml(self, d: dynamics.Dynamic) -> Element: 10080 - ''' mxDynamics = Element('dynamics') synchronizeIds(mxDynamics, d) @@ -6295,7 +6287,6 @@ def segnoToXml(self, segno: repeat.Segno) -> Element: - ''' mxSegno = Element('segno') synchronizeIds(mxSegno, segno) @@ -6448,7 +6439,6 @@ def tempoIndicationToXml(self, ti: tempo.TempoIndication) -> Element: Andante - ''' # if writing just a sound tag, place an empty words tag in a # direction type and then follow with sound declaration @@ -7516,7 +7506,6 @@ def intervalToXmlTranspose(self, i=None): -2 -1 - ''' # TODO: number attribute (staff number) # TODO: double empty attribute diff --git a/music21/musicxml/xmlObjects.py b/music21/musicxml/xmlObjects.py index 2342e50d8b..7c8babf783 100644 --- a/music21/musicxml/xmlObjects.py +++ b/music21/musicxml/xmlObjects.py @@ -154,7 +154,6 @@ def booleanToYesNo(value): >>> musicxml.xmlObjects.booleanToYesNo(5) 'yes' - ''' if value: # purposely not "is True" return 'yes' @@ -173,7 +172,6 @@ def fractionToPercent(value): >>> musicxml.xmlObjects.fractionToPercent(0.251) '25' - ''' return str(int(value * 100)) @@ -205,7 +203,6 @@ def isValidXSDID(text): >>> musicxml.xmlObjects.isValidXSDID(12345) False - ''' if not isinstance(text, str): return False diff --git a/music21/musicxml/xmlToM21.py b/music21/musicxml/xmlToM21.py index cc7a9b2e7c..6b57035eaf 100644 --- a/music21/musicxml/xmlToM21.py +++ b/music21/musicxml/xmlToM21.py @@ -899,7 +899,6 @@ def parsePartList(self, mxScore): entries into self.mxScorePartDict[partId] and adds them to any open entries, stored as PartGroup objects in self.partGroupList - ''' mxPartList = mxScore.find('part-list') if mxPartList is None: @@ -2336,7 +2335,6 @@ def applyMultiMeasureRest(self, r: note.Rest): >>> pp.applyMultiMeasureRest(r3) >>> pp.stream.show('text') {0.0} - ''' if self.activeMultiMeasureRestSpanner is None: return diff --git a/music21/note.py b/music21/note.py index 1f1fd4f6a1..9c0ff2a282 100644 --- a/music21/note.py +++ b/music21/note.py @@ -1761,7 +1761,6 @@ def transpose(self, value, *, inPlace=False): {0.0} {1.0} {1.0} - ''' from music21 import key if isinstance(value, interval.IntervalBase): diff --git a/music21/noteworthy/binaryTranslate.py b/music21/noteworthy/binaryTranslate.py index f9a292cedd..5cc3da30c9 100644 --- a/music21/noteworthy/binaryTranslate.py +++ b/music21/noteworthy/binaryTranslate.py @@ -186,7 +186,6 @@ {36.0} {0.0} {3.0} - ''' from __future__ import annotations diff --git a/music21/noteworthy/translate.py b/music21/noteworthy/translate.py index d83f9e4f02..f4e1cc84be 100644 --- a/music21/noteworthy/translate.py +++ b/music21/noteworthy/translate.py @@ -151,7 +151,6 @@ def parseList(self, dataList): {0.0} {0.0} {0.0} - ''' # Main for pi in dataList: @@ -243,7 +242,6 @@ def setDurationForObject(self, generalNote, durationInfo): >>> nwt.setDurationForObject(n, 'Half') >>> n.duration - ''' parts = durationInfo.split(',') lengthNote = parts[0] @@ -467,7 +465,6 @@ def translateNote(self, attributes): >>> nwt.translateNote({'Dur': 'Half', 'Pos': '-3'}) >>> measure[1] - ''' durationInfo = attributes['Dur'] pitchInfo = attributes['Pos'] @@ -522,7 +519,6 @@ def translateChord(self, attributes): >>> nwt.translateChord({'Dur': ['Half'], 'Pos': ['1,3,5']}) >>> measure[1] - ''' durationInfos = attributes['Dur'] pitchInfos = attributes['Pos'] @@ -610,7 +606,6 @@ def translateRest(self, attributes): {0.0} {2.0} {2.75} - ''' durationInfo = attributes['Dur'] @@ -649,7 +644,6 @@ def createClef(self, attributes): Traceback (most recent call last): music21.noteworthy.translate.NoteworthyTranslateException: Did not find a proper clef in type, OrangeClef - ''' currentClef = None if 'OctaveShift' in attributes: @@ -778,7 +772,6 @@ def createBarlines(self, attributes): >>> nwt.currentMeasure.leftBarline - ''' self.activeAccidentals = {} diff --git a/music21/omr/correctors.py b/music21/omr/correctors.py index bbfed53183..3e3b9fc2c1 100644 --- a/music21/omr/correctors.py +++ b/music21/omr/correctors.py @@ -101,7 +101,6 @@ def getAllHashes(self): def getSinglePart(self, pn): ''' returns a NEW SinglePart object for part number pn from the score - ''' return SinglePart(self.score.parts[pn], pn) @@ -167,7 +166,6 @@ def verticalProbabilityDist(self): ''' Uses a score and returns an array of probabilities. For n in the array, n is the probability that the nth part - ''' if self.distributionArray is not None: return self.distributionArray @@ -464,7 +462,6 @@ def getIncorrectMeasureIndices(self, runFast=False): >>> p[1].insert(0, meter.TimeSignature('3/8')) >>> sp.getIncorrectMeasureIndices(runFast=False) [] - ''' from music21 import meter self.incorrectMeasures = [] @@ -555,7 +552,6 @@ def runHorizontalSearch(self, i): ''' Returns an array of the indices of the minimum distance measures given a measure (with index i) to compare to. - ''' unused_probabilityDistribution = self.horizontalProbabilityDist() incorrectMeasures = self.incorrectMeasures @@ -804,7 +800,6 @@ def hashNote(self, n): def hashGrace(self, n): ''' Gives a Grace Note a duration of a 128th note - ''' graceNoteDuration = self.hashQuarterLength(0.015625) byteEncoding = chr(graceNoteDuration) @@ -886,7 +881,6 @@ def getMeasureDifference(self, hashString): >>> hasher.setSequenceMatcher() >>> hasher.getMeasureDifference('VFUF') 1.0 - ''' self.sequenceMatcher.set_seq2(hashString) @@ -1114,7 +1108,6 @@ def getProbabilityOnSubstitute(self, source, destination): Take minimum length. Compare index to index. Any additional letters in the flagged measure get graded as additions. Any additional letters in the comparison measure get graded as omissions. - ''' ls = len(source) ld = len(destination) diff --git a/music21/omr/evaluators.py b/music21/omr/evaluators.py index 32841f35e3..fa4c91eb79 100644 --- a/music21/omr/evaluators.py +++ b/music21/omr/evaluators.py @@ -28,7 +28,6 @@ class OmrGroundTruthPair: (or a pair of music21.stream.Score objects). See below for examples. - ''' def __init__(self, omr=None, ground=None): @@ -335,7 +334,6 @@ def autoCorrelationBestMeasure(inputScore): (18, 6) >>> print( float(totalUnflaggedWithMatches) / totalUnflagged ) 0.333... - ''' ss = correctors.ScoreCorrector(inputScore) allHashes = ss.getAllHashes() diff --git a/music21/pitch.py b/music21/pitch.py index 217fd3fb8a..cda3b89d85 100644 --- a/music21/pitch.py +++ b/music21/pitch.py @@ -791,7 +791,6 @@ class Microtone(prebase.ProtoM21Object, SlottedObjectMixin): >>> m.alter 0.3333... - ''' # CLASS VARIABLES # @@ -2517,7 +2516,6 @@ def convertMicrotonesToQuarterTones(self, *, inPlace: bool = False) -> t.Self|No >>> p.convertMicrotonesToQuarterTones(inPlace=True) >>> str(p) 'F~2(+12c)' - ''' if inPlace: returnObj = self @@ -4622,7 +4620,6 @@ def transpose( >>> dPitch.transpose(intv, inPlace=True) >>> dPitch - ''' # environLocal.printDebug(['Pitch.transpose()', value]) if isinstance(value, interval.IntervalBase): @@ -4905,7 +4902,6 @@ def _stepInKeySignature(self, alteredPitches: list[Pitch]) -> bool: >>> b._stepInKeySignature(ks.alteredPitches) False - ''' for p in alteredPitches: # all are altered tones, must have acc if p.step == self.step: # A# to A or A# to A-, etc @@ -5390,7 +5386,6 @@ def getStringHarmonic(self, chordIn: chord.Chord) -> chord.Chord|t.Literal[False (, , ) otherwise returns False - ''' # Takes in a chord, finds the interval between the notes from music21 import note diff --git a/music21/repeat.py b/music21/repeat.py index 22dca1761a..b136311504 100644 --- a/music21/repeat.py +++ b/music21/repeat.py @@ -491,7 +491,6 @@ def insertRepeat(s, start, end, *, inPlace=False): 'start' >>> s.parts[0].measure(6).rightBarline.direction 'end' - ''' if s is None: @@ -951,7 +950,6 @@ def _daCapoOrSegno(self): Return a DaCapo object if this piece uses any form of DaCapo; return a Segno object if this piece uses any form of Segno. Returns None if incoherent or the piece uses neither. - ''' sumDc = self._dcCount + self._dcafCount + self._dcacCount # for now, only accepting one segno @@ -1943,7 +1941,6 @@ class RepeatFinder: .. image:: images/repeat-SimplifyExample_ChoraleSimplified.* :width: 600 - ''' _DOC_ORDER = ['simplify', 'getMeasureSimilarityList', @@ -2010,7 +2007,6 @@ def getQuarterLengthOfPickupMeasure(self): Traceback (most recent call last): music21.repeat.NoInternalStreamException: RepeatFinder must be initialized with a stream - ''' if self.s is None: raise NoInternalStreamException( @@ -2563,7 +2559,6 @@ def getSimilarMeasureGroups(self, threshold=1): Notice that although measures 2-3 are the same as measures 6-7, we don't have ([2, 3], [6, 7]) in our result, since ([1, 2, 3], [5, 6, 7]) already contains that information. - ''' # see if we've already done this computation if self._mGroups is None: diff --git a/music21/roman.py b/music21/roman.py index 51041220ca..714f5ab4f9 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -428,7 +428,6 @@ def correctSuffixForChordQuality(chordObj, inversionString): >>> c = chord.Chord('E3 C4 G-4') >>> roman.correctSuffixForChordQuality(c, '6') 'o6' - ''' fifthType = chordObj.semitonesFromChordStep(5) if fifthType == 6: @@ -2389,7 +2388,6 @@ class RomanNumeral(harmony.Harmony): >>> roman.RomanNumeral('II', 'C', caseMatters=False).impliedQuality '' - ''', 'impliedScale': ''' If no key or scale is passed in as the second object, then @@ -3021,7 +3019,6 @@ def _parseOmittedSteps(self, workingFigure: str) -> str: '13b3' >>> rn.omittedSteps [4, 2, 7] - ''' omittedSteps = [] match = self._omittedStepsRegex.search(workingFigure) @@ -3075,7 +3072,6 @@ def _parseBracketedAlterations(self, workingFigure: str) -> str: '7' >>> rn.bracketedAlterations [('#', 5), ('b', 3)] - ''' matches = self._bracketedAlterationRegex.finditer(workingFigure) for m in matches: @@ -3965,7 +3961,6 @@ def isNeapolitan(self, >>> rn = roman.RomanNumeral('N53') >>> rn.isNeapolitan(require1stInversion=False) True - ''' if self.scaleDegree != 2: return False diff --git a/music21/romanText/clercqTemperley.py b/music21/romanText/clercqTemperley.py index 1fa06a92df..b03687190d 100644 --- a/music21/romanText/clercqTemperley.py +++ b/music21/romanText/clercqTemperley.py @@ -323,7 +323,6 @@ class CTSong(prebase.ProtoM21Object): Fadeout: I . . V | I . . V | I . . V | Co: [2/4] I | [4/4] . . . V | I . . V | $Fadeout S: [G] $In $Vr $Ch $In*2 $Ch $Vr2 $Ch $Ch $Co - """ _DOC_ORDER = ['text', 'toPart', 'title', 'homeTimeSig', 'homeKey', 'comments', 'rules'] _DOC_ATTR: dict[str, str] = { @@ -997,7 +996,6 @@ def fixupChordAtom(self, atom: str) -> str: 'vii/o7' >>> s.fixupChordAtom('iia') 'ii+' - ''' if 'x' in atom: atom = atom.replace('x', 'o') diff --git a/music21/romanText/rtObjects.py b/music21/romanText/rtObjects.py index c373ed4679..a227876fc2 100644 --- a/music21/romanText/rtObjects.py +++ b/music21/romanText/rtObjects.py @@ -512,7 +512,6 @@ class RTMeasure(RTToken): ['a'] >>> rtm.isMeasure() True - ''' def __init__(self, src: str = ''): @@ -911,7 +910,6 @@ class RTAnalyticKey(RTKeyTypeAtom): >>> bMinor.getKey() - ''' footerStrip = ':' diff --git a/music21/romanText/tsvConverter.py b/music21/romanText/tsvConverter.py index 9c91ac5877..9b81ac4580 100644 --- a/music21/romanText/tsvConverter.py +++ b/music21/romanText/tsvConverter.py @@ -522,7 +522,6 @@ class TsvHandler: >>> out_stream = handler.toM21Stream() >>> out_stream.parts[0].measure(1)[roman.RomanNumeral][0].figure 'I' - ''' def __init__(self, tsvFile: str|pathlib.Path, dcml_version: int = 1) -> None: if dcml_version == 1: @@ -1135,7 +1134,6 @@ def getLocalKey(local_key: str, global_key: str, convertDCMLToM21: bool = False) >>> romanText.tsvConverter.getLocalKey('vii', 'a', convertDCMLToM21=True) 'g' - ''' if convertDCMLToM21: local_key = characterSwaps(local_key, minor=isMinor(global_key[0]), direction='DCML-m21') diff --git a/music21/romanText/writeRoman.py b/music21/romanText/writeRoman.py index 132564fce9..58baadb691 100644 --- a/music21/romanText/writeRoman.py +++ b/music21/romanText/writeRoman.py @@ -269,7 +269,6 @@ def prepSequentialListOfLines(self) -> None: >>> testCase.combinedList[-2] 'Time Signature: 3/4' - ''' for thisMeasure in self.container.getElementsByClass(stream.Measure): @@ -388,7 +387,6 @@ def rnString(measureNumber: int|str, As these examples show, the chordString can be a Roman numeral alone (e.g. 'viio6') or one prefixed by a change of key ('G: I'). - ''' if inString: diff --git a/music21/scale/intervalNetwork.py b/music21/scale/intervalNetwork.py index 6d25c6fad0..15bcf218f1 100644 --- a/music21/scale/intervalNetwork.py +++ b/music21/scale/intervalNetwork.py @@ -488,7 +488,6 @@ def clear(self) -> None: def __eq__(self, other) -> bool: ''' - >>> edgeList1 = ['M2', 'M2', 'm2', 'M2', 'M2', 'M2', 'm2'] >>> edgeList2 = ['M2', 'M2', 'm2', 'M2', 'A3', 'm2'] @@ -2054,7 +2053,6 @@ def realizePitch( ['C1', 'G1', 'D2', 'A2', 'E3', 'B3', 'F#4', 'D-5', 'A-5', 'E-6', 'B-6', 'F7', 'C8'] >>> [str(p) for p in net5ths.realizePitch(pitch.Pitch('C2'))] ['C2', 'G2', 'D3', 'A3', 'E4', 'B4', 'F#5', 'D-6', 'A-6', 'E-7', 'B-7', 'F8', 'C9'] - ''' components = self.realize( pitchReference=pitchReference, @@ -2578,7 +2576,6 @@ def getRelativeNodeDegree( 2 >>> net.getRelativeNodeDegree('f6', 1, 'b3') 1 - ''' nId = self.getRelativeNodeId( pitchReference=pitchReference, @@ -2821,7 +2818,6 @@ def match(self, ['B-2', 'C3', 'E-3', 'E#3', 'F2', 'E--2'] >>> unmatched [] - ''' # these return a Node, not a nodeId # TODO: just getting first diff --git a/music21/search/base.py b/music21/search/base.py index b111c9197b..e6e856f628 100644 --- a/music21/search/base.py +++ b/music21/search/base.py @@ -1226,7 +1226,6 @@ def translateDurationToBytes(n: note.GeneralNote) -> str: '_' >>> (2 ** (ord(trans[0]) / 10)) / 256 # approximately 3 2.828... - ''' duration1to127 = 1 if n.duration.quarterLength: diff --git a/music21/search/lyrics.py b/music21/search/lyrics.py index c25120a841..ca0f886841 100644 --- a/music21/search/lyrics.py +++ b/music21/search/lyrics.py @@ -35,7 +35,6 @@ class IndexedLyric(namedtuple( )): ''' A Lyric that has been indexed to its attached element and position in a Stream. - ''' __slots__ = () _DOC_ATTR: dict[str, str] = { diff --git a/music21/search/segment.py b/music21/search/segment.py index 7b25d30852..792d00ea67 100644 --- a/music21/search/segment.py +++ b/music21/search/segment.py @@ -97,7 +97,6 @@ def translateMonophonicPartToSegments( >>> measureLists[0:2] [(1, 12), (7, 18)] - ''' from music21 import search if algorithm is None: diff --git a/music21/serial.py b/music21/serial.py index 01bbc7dacf..940696a981 100644 --- a/music21/serial.py +++ b/music21/serial.py @@ -427,7 +427,6 @@ def isSameRow(self, other): def getIntervalsAsString(self): ''' - Returns the string of intervals between consecutive pitch classes of a :class:`~music21.serial.ToneRow`. 'T' = 10, 'E' = 11. diff --git a/music21/sieve.py b/music21/sieve.py index b999fa5fc0..5f4605495b 100644 --- a/music21/sieve.py +++ b/music21/sieve.py @@ -253,7 +253,6 @@ def discreteBinaryPad(series: Iterable[int], fixRange=None) -> list[int]: >>> sieve.discreteBinaryPad([3, 4, 5]) [1, 1, 1] - ''' # make sure these are ints for x in series: @@ -293,7 +292,6 @@ def unitNormRange(series, fixRange=None): >>> sieve.unitNormRange([1, 3, 4]) [0.0, 0.666..., 1.0] - ''' if fixRange is not None: fixRange.sort() @@ -367,7 +365,6 @@ def unitNormStep(step, a=0, b=1, normalized=True): >>> post = sieve.unitNormStep(0.25, 0, 20, normalized=False) >>> len(post) 81 - ''' if a == b: return [] # no range, return boundary @@ -869,7 +866,6 @@ def _zUpdate(self, z=None): # -------------------------------------------------------------------------- def __call__(self): ''' - >>> a = sieve.CompressionSegment([3, 4, 5, 6, 7, 8]) >>> b = a() >>> str(b[0]) diff --git a/music21/sites.py b/music21/sites.py index b09a695cf6..645023faa9 100644 --- a/music21/sites.py +++ b/music21/sites.py @@ -281,7 +281,6 @@ def __len__(self): >>> aContexts.add(aObj) >>> len(aContexts) 2 - ''' return len(self.siteDict) @@ -585,7 +584,6 @@ def getAttrByName(self, attrName): >>> aSites.getAttrByName('blah') is None True - ''' post = None for obj in self.yieldSites(sortByCreationTime='reverse'): @@ -951,7 +949,6 @@ def remove(self, site): >>> aSites.remove(aSite) >>> len(aSites) 3 - ''' # must clear self._lastID = -1 # cannot be None diff --git a/music21/spanner.py b/music21/spanner.py index 6a04bd498e..ea6f9423d0 100644 --- a/music21/spanner.py +++ b/music21/spanner.py @@ -349,7 +349,6 @@ def purgeLocations(self, rescanIsDead=False): # -------------------------------------------------------------------------- def __getitem__(self, key): ''' - >>> n1 = note.Note('g') >>> n2 = note.Note('f#') >>> c1 = clef.BassClef() @@ -399,7 +398,6 @@ def getSpannedElements(self): def getSpannedElementsByClass(self, classFilterList): ''' - >>> n1 = note.Note('g') >>> n2 = note.Note('f#') >>> c1 = clef.AltoClef() diff --git a/music21/stream/base.py b/music21/stream/base.py index 18baebaf49..baea9a99bb 100644 --- a/music21/stream/base.py +++ b/music21/stream/base.py @@ -662,7 +662,6 @@ def __getitem__(self, still works until v9. This is an attempt to unify __getitem__ behavior in StreamIterators and Streams. - allowed iterables of qualified class names, e.g. `[note.Note, note.Rest]` - ''' # need to sort if not sorted, as this call may rely on index positions if not self.isSorted and self.autoSort: @@ -1557,7 +1556,6 @@ def index(self, el: base.Music21Object) -> int: >>> tuple(s).index(n3) 0 - ''' if not self.isSorted and self.autoSort: self.sort() # will set isSorted to True @@ -4317,7 +4315,6 @@ def getElementAfterElement(self, element, classList=None): Traceback (most recent call last): music21.exceptions21.StreamException: cannot find object () in Stream - ''' if classList is not None: classSet = set(classList) @@ -6181,7 +6178,6 @@ def extractContext(self, searchElement, before=4.0, after=4.0, NOTE: RENAME: this probably should be renamed, as we use Context in a special way. Perhaps better is extractNeighbors? - ''' display = self.cloneEmpty('extractContext') @@ -6246,7 +6242,6 @@ def _uniqueOffsetsAndEndTimes(self, offsetsOnly=False, endTimesOnly=False): >>> s.flatten()._uniqueOffsetsAndEndTimes(offsetsOnly=True, endTimesOnly=True) [] - ''' offsetDictValues = self._offsetDict.values() if endTimesOnly: @@ -9631,7 +9626,6 @@ def sliceByQuarterLengths(self, quarterLengthList, *, target=None, If `target` is None, the entire Stream is processed. Otherwise, only the element specified is manipulated. - ''' if not inPlace: # make a copy returnObj = self.coreCopyAsDerivation('sliceByQuarterLengths') @@ -10837,7 +10831,6 @@ def getOverlaps(self): >>> d = a.getOverlaps() >>> len(d[0]) 7 - ''' overlapMap = self._findLayering() # environLocal.printDebug(['overlapMap', overlapMap]) @@ -11151,7 +11144,6 @@ def allPlayingWhileSounding(self, el, elStream=None): is list, it is used like classList in elsewhere in stream to provide a list of classes that the el must be a part of. - ''' if elStream is not None: # a bit of safety elOffset = el.getOffsetBySite(elStream) @@ -11734,7 +11726,6 @@ def lyrics( >>> list(scr.lyrics(ignoreBarlines=True, recurse=False).keys()) [] - ''' returnLists: dict[int, list[RecursiveLyricList]] = {} numNotes = 0 @@ -12316,7 +12307,6 @@ def _insertDeletionVariant(self, v, matchBySpan=True): {1.0} {2.0} {3.0} - ''' from music21 import variant @@ -12452,7 +12442,6 @@ def _insertInsertionVariant(self, v, matchBySpan=True): {1.0} {2.0} {3.0} - ''' from music21 import variant @@ -12734,7 +12723,6 @@ def _fixMeasureNumbers(self, deletedMeasures, insertedMeasures): ... fixedNumbers.append( m.number ) >>> fixedNumbers [1, 2, 3, 4, 5] - ''' deletedMeasures.extend(insertedMeasures) allMeasures = deletedMeasures @@ -12857,7 +12845,6 @@ def showVariantAsOssialikePart(self, containedPart, variantGroups, *, inPlace=Fa >>> streamWithOssia = s.showVariantAsOssialikePart(sPart, ... ['variant1', 'variant2', 'variant3'], inPlace=False) >>> #_DOCS_SHOW streamWithOssia.show() - ''' from music21 import variant @@ -13460,7 +13447,6 @@ def bestTimeSignature(self): For further details about complex time signatures, etc. see `meter.bestTimeSignature()` - ''' return meter.bestTimeSignature(self) @@ -14193,7 +14179,6 @@ def partsToVoices(self, 4 >>> len(post.flatten().notes) 165 - ''' from music21 import spanner diff --git a/music21/stream/core.py b/music21/stream/core.py index fac17154a3..4fd3e901fc 100644 --- a/music21/stream/core.py +++ b/music21/stream/core.py @@ -403,7 +403,6 @@ def coreGuardBeforeAddElement(self, element, *, checkRedundancy=True): music21.exceptions21.StreamException: The object you tried to add to the Stream, 3.14159, is not a Music21Object. Use an ElementWrapper object if this is what you intend. - ''' if element is self: # cannot add this Stream into itself raise StreamException('this Stream cannot be contained within itself') diff --git a/music21/stream/filters.py b/music21/stream/filters.py index aee1f5553f..37c2392e95 100644 --- a/music21/stream/filters.py +++ b/music21/stream/filters.py @@ -63,7 +63,6 @@ class StreamFilter(prebase.ProtoM21Object): True >>> sf.classes ('StreamFilter', 'ProtoM21Object', 'object') - ''' derivationStr = 'streamFilter' @@ -115,7 +114,6 @@ class IsFilter(StreamFilter): ... print(el) - ''' derivationStr = 'is' @@ -193,7 +191,6 @@ class IdFilter(StreamFilter): No corresponding iterator call. Only a single ID can be passed in. Always returns a single item. - ''' derivationStr = 'getElementById' @@ -241,7 +238,6 @@ class ClassFilter(StreamFilter): ... print(x) - ''' derivationStr = 'getElementsByClass' diff --git a/music21/stream/iterator.py b/music21/stream/iterator.py index 3686214b23..898d95d4e4 100644 --- a/music21/stream/iterator.py +++ b/music21/stream/iterator.py @@ -466,7 +466,6 @@ def __bool__(self) -> bool: 0 >>> bool(iterator.getElementsByClass(chord.Chord)) False - ''' if self._len is not None: return bool(self._len) diff --git a/music21/stream/streamStatus.py b/music21/stream/streamStatus.py index 1830ec5cfc..36a4d18d19 100644 --- a/music21/stream/streamStatus.py +++ b/music21/stream/streamStatus.py @@ -138,7 +138,6 @@ def haveTupletBracketsBeenMade(self): >>> nTuplet.duration.tuplets[0].type = 'start' >>> s.streamStatus.haveTupletBracketsBeenMade() True - ''' foundTuplet = False for n in self.client.recurse(classFilter='GeneralNote', restoreActiveSites=False): diff --git a/music21/stream/tools.py b/music21/stream/tools.py index efd1f3fe6b..1fa145f8de 100644 --- a/music21/stream/tools.py +++ b/music21/stream/tools.py @@ -154,7 +154,6 @@ def removeDuplicates(thisStream: stream.Stream, >>> t = stream.tools.removeDuplicates(s, inPlace=False) >>> s.parts[0] == testInPlace True - ''' supportedClasses = (meter.TimeSignature, key.KeySignature, clef.Clef) diff --git a/music21/style.py b/music21/style.py index d4f6fb1f4b..dfdb43db8b 100644 --- a/music21/style.py +++ b/music21/style.py @@ -61,7 +61,6 @@ class Style(ProtoM21Object): >>> st.absoluteX = 20.4 >>> st.absoluteX 20.4 - ''' _DOC_ATTR: dict[str, str] = { 'hideObjectOnPrint': ''' diff --git a/music21/tempo.py b/music21/tempo.py index bba4a40a8e..0e2a6db74e 100644 --- a/music21/tempo.py +++ b/music21/tempo.py @@ -107,7 +107,6 @@ def convertTempoByReferent( >>> tempo.convertTempoByReferent(60, 1.5, common.opFrac(1/3)) 270.0 - ''' # find duration in seconds of quarter length srcDurPerBeat = 60 / numberSrc @@ -754,7 +753,6 @@ def getEquivalentByReferent(self, referent): >>> mm1.getEquivalentByReferent('longa') - ''' if common.isNum(referent): # assume quarter length quarterLength = referent @@ -1157,7 +1155,6 @@ def setEqualityByReferent(self, side=None, referent=1.0): => - ''' if side is None: if self._oldMetronome is None: diff --git a/music21/text.py b/music21/text.py index 92426e02f3..7675f7d946 100644 --- a/music21/text.py +++ b/music21/text.py @@ -291,7 +291,6 @@ class TextBox(base.Music21Object): .. image:: images/textBoxes-01.* :width: 600 - ''' _styleClass = style.TextStyle classSortOrder = -31 # text expressions are -30 diff --git a/music21/tree/core.py b/music21/tree/core.py index 5de72e4654..ec6980294d 100644 --- a/music21/tree/core.py +++ b/music21/tree/core.py @@ -378,7 +378,6 @@ def update(self) -> None: child notes of `n` then this would not fix that node's balance/height. This method assumes that children have the correct information and only updates the information for this node. - ''' leftHeight = self.leftChild.height if self.leftChild else -1 rightHeight = self.rightChild.height if self.rightChild else -1 diff --git a/music21/tree/fromStream.py b/music21/tree/fromStream.py index 46ab6da851..f1bcb407b5 100644 --- a/music21/tree/fromStream.py +++ b/music21/tree/fromStream.py @@ -207,7 +207,6 @@ def asTree( >>> etFlatNotes = tree.fromStream.asTree(score, flatten=True, classList=(note.Note,)) >>> etFlatNotes to 8.0) > - ''' def recurseGetTreeByClass( innerStream, diff --git a/music21/tree/spans.py b/music21/tree/spans.py index 36ed0e2731..4c34d892be 100644 --- a/music21/tree/spans.py +++ b/music21/tree/spans.py @@ -560,7 +560,6 @@ def pitches(self) -> tuple[pitch.Pitch, ...]: True >>> pts.pitches is c.pitches False - ''' return self.element.pitches @@ -623,7 +622,6 @@ def canMerge(self, other: Timespan) -> tuple[bool, str]: > >>> print(timespan_twoWrong.part) - ''' can, message = super().canMerge(other) if can is True: diff --git a/music21/tree/trees.py b/music21/tree/trees.py index 2cae3ecf14..c9d5b4f304 100644 --- a/music21/tree/trees.py +++ b/music21/tree/trees.py @@ -400,7 +400,6 @@ def __iter__(self): ... - ''' for node in self.iterNodes(): yield node.payload @@ -736,7 +735,6 @@ def _getPositionsFromElements(self, elements): In an ElementTree, this will be a list of .sortTuple() calls. In an OffsetTree, this will be a list of .offset calls - ''' return [self.getPositionFromElementUnsafe(el) for el in elements] @@ -1077,7 +1075,6 @@ def __iter__(self): ... - ''' for node in self.iterNodes(): for el in node.payload: @@ -1381,7 +1378,6 @@ def overlapTimePoints(self, includeStopPoints=False, returnVerticality=False): >>> otp = scoreOffsetTree.overlapTimePoints(returnVerticality=True) >>> otp[0] {0.5: } - ''' checkPoints = self.allOffsets() if includeStopPoints is False else self.allTimePoints() overlaps = [] diff --git a/music21/variant.py b/music21/variant.py index f365d25af8..552b748a6a 100644 --- a/music21/variant.py +++ b/music21/variant.py @@ -1327,7 +1327,6 @@ def mergePartAsOssia(mainPart, ossiaPart, ossiaName, {0.0} {2.0} ... - ''' if inPlace: returnObj = mainPart @@ -1588,7 +1587,6 @@ def refineVariant(s, sVariant, *, inPlace=False): {1.0} {2.0} {3.0} - ''' # stream that will be returned if sVariant not in s.getElementsByClass(Variant): @@ -1682,7 +1680,6 @@ def _mergeVariantMeasureStreamsCarefully(streamX, streamY, variantName, *, inPla ''' There seem to be some problems with this function, and it isn't well tested. It is not recommended to use it at this time. - ''' # stream that will be returned if inPlace: @@ -1922,7 +1919,6 @@ def _diffScore(measureX, measureY): >>> m2.append([note.Note('e'), note.Note('f'), note.Note('g#'), note.Note('a')]) >>> variant._diffScore(m1, m2) 0.4... - ''' hashes = getMeasureHashes([measureX, measureY]) if hashes[0] == hashes[1]: @@ -1957,7 +1953,6 @@ def _getRegionsFromStreams(streamX, streamY): ('replace', 1, 3, 1, 2), ('equal', 3, 6, 2, 5), ('insert', 6, 6, 5, 6)] - ''' hashesX = getMeasureHashes(streamX) hashesY = getMeasureHashes(streamY) @@ -2170,7 +2165,6 @@ def _generateVariant(noteList, originStream, start, variantName=None): >>> v.groups ['paris'] - ''' returnVariant = Variant() for n in noteList: @@ -2230,7 +2224,6 @@ def makeAllVariantsReplacements(streamWithVariants, (4.0, 'replacement', 4.0, 4.0) (12.0, 'elongation', 4.0, 12.0) (20.0, 'deletion', 8.0, 4.0) - ''' if inPlace: diff --git a/music21/voiceLeading.py b/music21/voiceLeading.py index 0387ac7717..61060b9a5d 100644 --- a/music21/voiceLeading.py +++ b/music21/voiceLeading.py @@ -1684,7 +1684,6 @@ def getObjectsByClass(self, classFilterList, partNums=None): , ] >>> vs1.getObjectsByClass('Note', [1, 2]) [, , ] - ''' if not common.isIterable(classFilterList): classFilterList = [classFilterList] @@ -1916,7 +1915,6 @@ def hasPassingTone(self, partNumToIdentify, unaccentedOnly=False): True >>> vt.hasPassingTone(1) False - ''' if partNumToIdentify in self.tnlsDict: ret = self.tnlsDict[partNumToIdentify].couldBePassingTone() @@ -2082,7 +2080,6 @@ class ThreeNoteLinearSegment(NNoteLinearSegment): >>> defaults.pitchOctave 4 - ''' _DOC_ORDER = ['couldBePassingTone', 'couldBeDiatonicPassingTone', diff --git a/music21/volume.py b/music21/volume.py index 6b08dcd516..85f81ba615 100644 --- a/music21/volume.py +++ b/music21/volume.py @@ -231,7 +231,6 @@ def getRealized( >>> s.notes[7].volume.velocityIsRelative = False >>> s.notes[7].volume.getRealized() 0.1574803... - ''' # velocityIsRelative might be best set at import. e.g., from MIDI, # velocityIsRelative is False, but in other applications, it may not From b0720f53ec3c17f6b85dc0eee7eab97eac49d424 Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:17:09 -1000 Subject: [PATCH 2/9] Align every continuation line to its opening bracket 383 E127/E128 continuation lines across 58 modules sat at an indent that had drifted from the bracket they belong to -- most of them badly over-indented, like serial.historicalDict's rows and scale's IntervalNetwork edge dicts, where the second line of each entry started fifteen columns right of the first. autopep8 --select=E12 did the reindent; `pycodestyle --select=E12 music21` is now silent. Four lines had to be rewrapped by hand: three that the new indent pushed past 100 characters (analysis/reduction, roman, stream/makeNotation) and one string in musicxml/test_xmlToM21 that had been hiding under an indent of 8. Also annotates the three graph.axis __init__s that returned mypy's annotation-unchecked note, which their bodies' inline annotations had earned. repeat.simplify and stream.filters.OffsetFilter.__init__ still raise it; both need a real signature rather than a bare `-> None` (simplify returns a Stream unless inPlace), so they are left alone. AI-assisted (Claude) --- music21/abcFormat/__init__.py | 12 +- music21/abcFormat/testFiles.py | 10 +- music21/abcFormat/translate.py | 4 +- music21/alpha/analysis/hasher.py | 6 +- music21/alpha/analysis/ornamentRecognizer.py | 2 +- music21/analysis/patel.py | 2 +- music21/analysis/reduction.py | 19 +- music21/base.py | 4 +- music21/braille/basic.py | 4 +- music21/braille/segment.py | 8 +- music21/braille/test.py | 10 +- music21/braille/translate.py | 32 +-- music21/dynamics.py | 34 +-- music21/expressions.py | 20 +- music21/features/base.py | 14 +- music21/figuredBass/notation.py | 4 +- music21/figuredBass/realizer.py | 8 +- music21/figuredBass/segment.py | 20 +- music21/freezeThaw.py | 6 +- music21/graph/axis.py | 6 +- music21/graph/plot.py | 28 +-- music21/humdrum/harmParser.py | 16 +- music21/humdrum/testFiles.py | 2 +- .../naturalLanguageObjects.py | 2 +- music21/mei/test_base.py | 6 +- music21/metadata/primitives.py | 6 +- music21/musedata/__init__.py | 4 +- music21/musedata/translate.py | 2 +- music21/musicxml/partStaffExporter.py | 8 +- music21/musicxml/test_xmlToM21.py | 9 +- music21/musicxml/xmlToM21.py | 8 +- music21/omr/evaluators.py | 2 +- music21/pitch.py | 14 +- music21/roman.py | 15 +- music21/romanText/translate.py | 2 +- music21/scale/__init__.py | 212 +++++++++--------- music21/scale/intervalNetwork.py | 14 +- music21/scale/scala/__init__.py | 20 +- music21/scale/test_scale_main.py | 6 +- music21/search/lyrics.py | 2 +- music21/search/serial.py | 6 +- music21/serial.py | 150 ++++++------- music21/sieve.py | 4 +- music21/spanner.py | 22 +- music21/stream/base.py | 8 +- music21/stream/makeNotation.py | 10 +- music21/stream/tests.py | 88 ++++---- music21/test/multiprocessTest.py | 2 +- music21/test/testRunner.py | 4 +- music21/test/test_chord.py | 18 +- music21/test/test_metadata.py | 2 +- music21/test/test_note.py | 2 +- music21/test/test_pitch.py | 2 +- music21/text.py | 2 +- music21/tree/verticality.py | 2 +- music21/variant.py | 58 ++--- music21/voiceLeading.py | 46 ++-- music21/volpiano.py | 4 +- 58 files changed, 521 insertions(+), 512 deletions(-) diff --git a/music21/abcFormat/__init__.py b/music21/abcFormat/__init__.py index 4adcab5256..9c52a79554 100644 --- a/music21/abcFormat/__init__.py +++ b/music21/abcFormat/__init__.py @@ -2506,12 +2506,12 @@ def tokenize(self, strSrc: str) -> None: # H is fermata # . dot may be staccato, but should be attached to pitch if self.currentCollectStr in ('w', 'u', 'v', 'v.', 'h', 'H', 'vk', - 'uk', 'U', '~', - '.', '=', 'V', 'v.', 'S', 's', - 'i', 'I', 'ui', 'u.', 'Q', 'Hy', 'Hx', - 'r', 'm', 'M', 'n', 'N', 'o', 'O', 'P', - 'l', 'L', 'R', - 'y', 'T', 't', 'x', 'Z'): + 'uk', 'U', '~', + '.', '=', 'V', 'v.', 'S', 's', + 'i', 'I', 'ui', 'u.', 'Q', 'Hy', 'Hx', + 'r', 'm', 'M', 'n', 'N', 'o', 'O', 'P', + 'l', 'L', 'R', + 'y', 'T', 't', 'x', 'Z'): pass # these are bad chords, or other problematic notations like # "D.C."x diff --git a/music21/abcFormat/testFiles.py b/music21/abcFormat/testFiles.py index 8cbd76cad9..eee14079f7 100644 --- a/music21/abcFormat/testFiles.py +++ b/music21/abcFormat/testFiles.py @@ -633,11 +633,11 @@ # ------------------------------------------------------------------------------ ALL = [fyrareprisarn, mysteryReel, fullRiggedShip, aleIsDear, kitchGirl, - williamAndNancy, morrisonsJig, hectorTheHero, kingOfTheFairies, - sicutRosa, theAleWifesDaughter, theBeggerBoy, theBattleOfTheSnaBas, - draughtOfAle, - valentineJigg, - testPrimitive, testPrimitivePolyphonic, testPrimitiveTuplet + williamAndNancy, morrisonsJig, hectorTheHero, kingOfTheFairies, + sicutRosa, theAleWifesDaughter, theBeggerBoy, theBattleOfTheSnaBas, + draughtOfAle, + valentineJigg, + testPrimitive, testPrimitivePolyphonic, testPrimitiveTuplet ] diff --git a/music21/abcFormat/translate.py b/music21/abcFormat/translate.py index 69c943a272..6e245f12a6 100644 --- a/music21/abcFormat/translate.py +++ b/music21/abcFormat/translate.py @@ -1044,9 +1044,9 @@ def testNoChord(self): score = harmony.realizeChordSymbolDurations(score) self.assertEqual(8, score.getElementsByClass(harmony.ChordSymbol) - .last().quarterLength) + .last().quarterLength) self.assertEqual(4, score.getElementsByClass(harmony.ChordSymbol) - .first().quarterLength) + .first().quarterLength) def testAbcKeyImport(self): from music21 import abcFormat diff --git a/music21/alpha/analysis/hasher.py b/music21/alpha/analysis/hasher.py index 2b271010a9..a89f0df9b1 100644 --- a/music21/alpha/analysis/hasher.py +++ b/music21/alpha/analysis/hasher.py @@ -416,16 +416,16 @@ def hashStream(self, s): if self.hashChordsAsNotes: for n in elt: singleNoteHash = [self.hashingFunctions[hashProperty](n, thisChord=elt) - for hashProperty in self.tupleList] + for hashProperty in self.tupleList] self.addHashToFinalHash(singleNoteHash, finalHash, n) elif self.hashChordsAsChords: singleNoteHash = [self.hashingFunctions[hashProperty](None, thisChord=elt) - for hashProperty in self.tupleList] + for hashProperty in self.tupleList] self.addHashToFinalHash(singleNoteHash, finalHash, elt) else: singleNoteHash = [self.hashingFunctions[hashProperty](elt) - for hashProperty in self.tupleList] + for hashProperty in self.tupleList] self.addHashToFinalHash(singleNoteHash, finalHash, elt) # TODO: don't finalHash back and forth, return it in the smaller functions return finalHash diff --git a/music21/alpha/analysis/ornamentRecognizer.py b/music21/alpha/analysis/ornamentRecognizer.py index 029f35b968..1364d2572f 100644 --- a/music21/alpha/analysis/ornamentRecognizer.py +++ b/music21/alpha/analysis/ornamentRecognizer.py @@ -543,7 +543,7 @@ def testRecognizeTrill(self): t3Notes = stream.Stream() # C B C B C D E F t3Notes.append( [t3n1, t3n2, deepcopy(t3n1), deepcopy(t3n2), deepcopy(t3n1), - nachschlagN1, nachschlagN2, nachschlagN3] + nachschlagN1, nachschlagN2, nachschlagN3] ) testConditions.append( diff --git a/music21/analysis/patel.py b/music21/analysis/patel.py index 499fed7ea7..54d019aa9c 100644 --- a/music21/analysis/patel.py +++ b/music21/analysis/patel.py @@ -92,7 +92,7 @@ def melodicIntervalVariability(streamForAnalysis, **skipKeywords): totalElements = len(intervalStream) if totalElements < 2: # this is correct. raise ValueError('need at least three notes to have ' - + 'a std-deviation of intervals (and thus a MIV)') + + 'a std-deviation of intervals (and thus a MIV)') # summation = 0 semitoneList = [myInt.chromatic.undirected for myInt in intervalStream] return 100 * (stdev(semitoneList) / mean(semitoneList)) diff --git a/music21/analysis/reduction.py b/music21/analysis/reduction.py index 5c9dfbaddb..e4bf27dcbf 100644 --- a/music21/analysis/reduction.py +++ b/music21/analysis/reduction.py @@ -733,9 +733,14 @@ def _dynamicToWeight(targets): offsetEnd = offsetStart + ds['span'] # get all targets within the contiguous region # e.g., Dynamics objects - match = flatRef.getElementsByOffset(offsetStart, offsetEnd, - includeEndBoundary=True, mustFinishInSpan=False, - mustBeginInSpan=True).getElementsByClass(target).stream() + inRegion = flatRef.getElementsByOffset( + offsetStart, + offsetEnd, + includeEndBoundary=True, + mustFinishInSpan=False, + mustBeginInSpan=True, + ) + match = inRegion.getElementsByClass(target).stream() # environLocal.printDebug(['matched elements', target, match]) # extend duration of all found dynamics match.extendDuration(target, inPlace=True) @@ -1251,7 +1256,7 @@ def testPartReductionE(self): s.insert(0, p2) # s.show() pr = analysis.reduction.PartReduction(s, fillByMeasure=True, - segmentByTarget=False, normalize=False) + segmentByTarget=False, normalize=False) pr.process() target = pr.getGraphHorizontalBarWeightedData() match = [(0, [[0.0, 4.0, 0.178571428571, '#666666'], @@ -1264,7 +1269,7 @@ def testPartReductionE(self): self._matchWeightedData(match, target) pr = analysis.reduction.PartReduction(s, fillByMeasure=False, - segmentByTarget=True, normalize=False) + segmentByTarget=True, normalize=False) pr.process() target = pr.getGraphHorizontalBarWeightedData() match = [(0, [[0.0, 2.0, 0.05, '#666666'], @@ -1281,7 +1286,7 @@ def testPartReductionE(self): pr = analysis.reduction.PartReduction(s, fillByMeasure=False, - segmentByTarget=False) + segmentByTarget=False) pr.process() target = pr.getGraphHorizontalBarWeightedData() # print(target) @@ -1295,7 +1300,7 @@ def testPartReductionE(self): pr = analysis.reduction.PartReduction(s, fillByMeasure=True, - segmentByTarget=True) + segmentByTarget=True) pr.process() target = pr.getGraphHorizontalBarWeightedData() match = [(0, [[0.0, 2.0, 0.3888888888888, '#666666'], diff --git a/music21/base.py b/music21/base.py index 2d0addf2ea..4878c13be5 100644 --- a/music21/base.py +++ b/music21/base.py @@ -2160,7 +2160,7 @@ def contextSites( offsetAdjustedCsTuple = ContextSortTuple( derivedCsTuple.site, derivedCsTuple.offset.modify(offset=derivedCsTuple[1].offset - + offsetAppend), + + offsetAppend), derivedCsTuple.recurseType) if returnSortTuples: yield offsetAdjustedCsTuple @@ -2769,7 +2769,7 @@ def sortTuple(self, insertIndex = 0 return SortTuple(atEnd, offset, self.priority, - self.classSortOrder, isNotGrace, insertIndex) + self.classSortOrder, isNotGrace, insertIndex) # ----------------------------------------------------------------- @property diff --git a/music21/braille/basic.py b/music21/braille/basic.py index acbca7bf5b..c9218a3be9 100644 --- a/music21/braille/basic.py +++ b/music21/braille/basic.py @@ -739,8 +739,8 @@ def noteToBraille( f'transcriber-added {symbols["transcriber-added_sign"]}') tupletTrans = symbols['tuplet_prefix'] # dots 4,5,6 tupletTrans += numberToBraille(allTuplets[0].numberNotesActual, - withNumberSign=False, - lower=True) + withNumberSign=False, + lower=True) tupletTrans += symbols['dot'] noteTrans.append(tupletTrans) music21Note.editorial.brailleEnglish.append( diff --git a/music21/braille/segment.py b/music21/braille/segment.py index 739c9fb824..eb493b4a65 100644 --- a/music21/braille/segment.py +++ b/music21/braille/segment.py @@ -826,8 +826,8 @@ def extractNoteGrouping(self) -> None: # hence -- let us split this noteGrouping into two noteGroupings. try: bngA, bngB = self.splitNoteGroupingAndTranscribe(noteGrouping, - showLeadingOctave, - addSpace) + showLeadingOctave, + addSpace) self.currentLine.append(bngA, addSpace=addSpace) self.addToNewLine(bngB) except BrailleSegmentException: @@ -1072,8 +1072,8 @@ def fixOneArticulation(artic, music21NoteStart, allNotes, noteIndexStart): newSegment = self.consolidate() noteGroupings = [newSegment[gpKey] - for gpKey in newSegment.keys() - if gpKey.affinity == Affinity.NOTEGROUP] + for gpKey in newSegment.keys() + if gpKey.affinity == Affinity.NOTEGROUP] for noteGrouping in noteGroupings: allNotes_outer = [n for n in noteGrouping if isinstance(n, note.Note)] for noteIndexStart_outer in range(len(allNotes_outer)): diff --git a/music21/braille/test.py b/music21/braille/test.py index ab2c0468c4..24e7fc690e 100644 --- a/music21/braille/test.py +++ b/music21/braille/test.py @@ -1848,7 +1848,7 @@ def test_example05_3(self): def test_example05_4(self): self.methodArgs = {'suppressOctaveMarks': True} bm = converter.parse('tinynotation: 4/4 E2 F2 G1 E2 D2 C1 D2 E2 F2 E2 D1 r1 ' - 'C2 D2 E1 F2 G2 A1 G2 F2 E2 D2 C1 r1') + 'C2 D2 E1 F2 G2 A1 G2 F2 E2 D2 C1 r1') bm.makeNotation(inPlace=True, cautionaryNotImmediateRepeat=False) self.s = bm self.e = ''' @@ -3622,9 +3622,9 @@ def test_example08_7a(self): (-4, '4/4', 'Andante', '⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠁⠝⠙⠁⠝⠞⠑⠲⠀⠼⠙⠣⠼⠙⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀'), (3, '3/8', 'Con moto', '⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠉⠕⠝⠀⠍⠕⠞⠕⠲⠀⠩⠩⠩⠼⠉⠦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀'), (None, '4/4', 'Andante cantabile', - '⠀⠀⠀⠀⠀⠀⠀⠀⠠⠁⠝⠙⠁⠝⠞⠑⠀⠉⠁⠝⠞⠁⠃⠊⠇⠑⠲⠀⠼⠙⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀'), + '⠀⠀⠀⠀⠀⠀⠀⠀⠠⠁⠝⠙⠁⠝⠞⠑⠀⠉⠁⠝⠞⠁⠃⠊⠇⠑⠲⠀⠼⠙⠲⠀⠀⠀⠀⠀⠀⠀⠀⠀'), (2, '7/8', 'Very brightly', - '⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠧⠑⠗⠽⠀⠃⠗⠊⠛⠓⠞⠇⠽⠲⠀⠩⠩⠼⠛⠦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀') + '⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠧⠑⠗⠽⠀⠃⠗⠊⠛⠓⠞⠇⠽⠲⠀⠩⠩⠼⠛⠦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀') ] for ks, ts, tt, r in results: if ks is not None: @@ -3637,7 +3637,7 @@ def test_example08_8(self): from music21.braille import basic self.assertEqual(basic.metronomeMarkToBraille( tempo.MetronomeMark(number=80, - referent=note.Note(type='half'))), '⠝⠶⠼⠓⠚') + referent=note.Note(type='half'))), '⠝⠶⠼⠓⠚') def test_example08_9(self): from music21.braille.basic import transcribeHeading @@ -3671,7 +3671,7 @@ def test_drill08_1(self): bm = converter.parse(''' tinynotation: 4/4 a2 g8 f8 e4 d4 e4 f8 g8 a4 g4 c'8 b8 a4 g4 f4. e8 d2 c4 e4 a4 e'4 e'4 d'4 c'8 b8 a4 a'4 g'8 f'8 e'4 d'4 c'4 a8 b8 c'2''', - makeNotation=False) + makeNotation=False) bm.replace(bm.getElementsByClass(meter.TimeSignature).first(), meter.TimeSignature('c')) bm.insert(0, tempo.TempoText('Andante maestoso')) bm.insert(0, tempo.MetronomeMark(number=92, referent=note.Note(type='quarter'))) diff --git a/music21/braille/translate.py b/music21/braille/translate.py index 1d693f551b..d7528ad4e3 100644 --- a/music21/braille/translate.py +++ b/music21/braille/translate.py @@ -244,22 +244,22 @@ def streamToBraille(music21Stream: stream.Measure|stream.Part|stream.Score|strea ''' if isinstance(music21Stream, stream.Part): return partToBraille(music21Stream, - inPlace=inPlace, - debug=debug, - cancelOutgoingKeySig=cancelOutgoingKeySig, - descendingChords=descendingChords, - dummyRestLength=dummyRestLength, - maxLineLength=maxLineLength, - segmentBreaks=segmentBreaks, - showClefSigns=showClefSigns, - showFirstMeasureNumber=showFirstMeasureNumber, - showHand=showHand, - showHeading=showHeading, - showLongSlursAndTiesTogether=showLongSlursAndTiesTogether, - showShortSlursAndTiesTogether=showShortSlursAndTiesTogether, - slurLongPhraseWithBrackets=slurLongPhraseWithBrackets, - suppressOctaveMarks=suppressOctaveMarks, - upperFirstInNoteFingering=upperFirstInNoteFingering, + inPlace=inPlace, + debug=debug, + cancelOutgoingKeySig=cancelOutgoingKeySig, + descendingChords=descendingChords, + dummyRestLength=dummyRestLength, + maxLineLength=maxLineLength, + segmentBreaks=segmentBreaks, + showClefSigns=showClefSigns, + showFirstMeasureNumber=showFirstMeasureNumber, + showHand=showHand, + showHeading=showHeading, + showLongSlursAndTiesTogether=showLongSlursAndTiesTogether, + showShortSlursAndTiesTogether=showShortSlursAndTiesTogether, + slurLongPhraseWithBrackets=slurLongPhraseWithBrackets, + suppressOctaveMarks=suppressOctaveMarks, + upperFirstInNoteFingering=upperFirstInNoteFingering, ) elif isinstance(music21Stream, stream.Measure): return measureToBraille(music21Stream, diff --git a/music21/dynamics.py b/music21/dynamics.py index a48deb15c8..b4bf812ea4 100644 --- a/music21/dynamics.py +++ b/music21/dynamics.py @@ -27,27 +27,27 @@ shortNames = ['pppppp', 'ppppp', 'pppp', 'ppp', 'pp', 'p', 'mp', - 'mf', 'f', 'fp', 'sf', 'ff', 'fff', 'ffff', 'fffff', 'ffffff'] + 'mf', 'f', 'fp', 'sf', 'ff', 'fff', 'ffff', 'fffff', 'ffffff'] longNames = {'ppp': 'pianississimo', - 'pp': 'pianissimo', - 'p': 'piano', - 'mp': 'mezzopiano', - 'mf': 'mezzoforte', - 'f': 'forte', - 'fp': 'fortepiano', - 'sf': 'sforzando', - 'ff': 'fortissimo', - 'fff': 'fortississimo'} + 'pp': 'pianissimo', + 'p': 'piano', + 'mp': 'mezzopiano', + 'mf': 'mezzoforte', + 'f': 'forte', + 'fp': 'fortepiano', + 'sf': 'sforzando', + 'ff': 'fortissimo', + 'fff': 'fortississimo'} # could be really useful for automatic description of musical events englishNames = {'ppp': 'extremely soft', - 'pp': 'very soft', - 'p': 'soft', - 'mp': 'moderately soft', - 'mf': 'moderately loud', - 'f': 'loud', - 'ff': 'very loud', - 'fff': 'extremely loud'} + 'pp': 'very soft', + 'p': 'soft', + 'mp': 'moderately soft', + 'mf': 'moderately loud', + 'f': 'loud', + 'ff': 'very loud', + 'fff': 'extremely loud'} def dynamicStrFromDecimal(n): diff --git a/music21/expressions.py b/music21/expressions.py index 95ec81cf24..fbecb96bf7 100644 --- a/music21/expressions.py +++ b/music21/expressions.py @@ -582,8 +582,8 @@ def realize( keySig: key.KeySignature|None = None, inPlace: bool = False ) -> tuple[list[note.Note|note.Unpitched], - note.Note|note.Unpitched|None, - list[note.Note|note.Unpitched]]: + note.Note|note.Unpitched|None, + list[note.Note|note.Unpitched]]: ''' Subclassable method call that takes a sourceObject and optional keySig and returns a three-element tuple of a list of notes before the @@ -911,8 +911,8 @@ def realize( keySig: key.KeySignature|None = None, inPlace: bool = False ) -> tuple[list[note.Note|note.Unpitched], - note.Note|note.Unpitched|None, - list[note.Note|note.Unpitched]]: + note.Note|note.Unpitched|None, + list[note.Note|note.Unpitched]]: ''' Realize a mordent. @@ -1576,8 +1576,8 @@ def realize( keySig: key.KeySignature|None = None, inPlace: bool = False ) -> tuple[list[note.Note|note.Unpitched], - note.Note|note.Unpitched|None, - list[note.Note|note.Unpitched]]: + note.Note|note.Unpitched|None, + list[note.Note|note.Unpitched]]: ''' Realize a trill. @@ -2449,8 +2449,8 @@ def realize( keySig: key.KeySignature|None = None, inPlace: bool = False ) -> tuple[list[note.Note|note.Unpitched], - note.Note|note.Unpitched|None, - list[note.Note|note.Unpitched]]: + note.Note|note.Unpitched|None, + list[note.Note|note.Unpitched]]: ''' Realize an appoggiatura. @@ -2597,8 +2597,8 @@ def realize( keySig: key.KeySignature|None = None, inPlace: bool = False ) -> tuple[list[note.Note|note.Unpitched], - note.Note|note.Unpitched|None, - list[note.Note|note.Unpitched]]: + note.Note|note.Unpitched|None, + list[note.Note|note.Unpitched]]: ''' Realize the ornament. diff --git a/music21/features/base.py b/music21/features/base.py index 32e5e44812..d428c8228e 100644 --- a/music21/features/base.py +++ b/music21/features/base.py @@ -1355,11 +1355,11 @@ def testStreamFormsA(self): '3-8': 2, '3-2': 2}) self.assertEqual(di['chordify.flat.getElementsByClass(Chord).typesHistogram'], - {'isMinorTriad': 6, 'isAugmentedTriad': 0, - 'isTriad': 34, 'isSeventh': 0, 'isDiminishedTriad': 4, - 'isDiminishedSeventh': 0, 'isIncompleteMajorTriad': 26, - 'isHalfDiminishedSeventh': 0, 'isMajorTriad': 24, - 'isDominantSeventh': 0, 'isIncompleteMinorTriad': 16}) + {'isMinorTriad': 6, 'isAugmentedTriad': 0, + 'isTriad': 34, 'isSeventh': 0, 'isDiminishedTriad': 4, + 'isDiminishedSeventh': 0, 'isIncompleteMajorTriad': 26, + 'isHalfDiminishedSeventh': 0, 'isMajorTriad': 24, + 'isDominantSeventh': 0, 'isIncompleteMinorTriad': 16}) self.assertEqual(di['flat.notes.quarterLengthHistogram'], {0.5: 116, 1.0: 39, 1.5: 27, 2.0: 31, 3.0: 2, 4.0: 3, @@ -1650,8 +1650,8 @@ def x_testRegionClassificationJSymbolicB(self): # pragma: no cover # features common to both collections featureExtractors = features.extractorsById( ['r31', 'r32', 'r33', 'r34', 'r35', 'p1', 'p2', 'p3', 'p4', - 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p11', 'p12', 'p13', - 'p14', 'p15', 'p16', 'p19', 'p20', 'p21'], 'jSymbolic') + 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p11', 'p12', 'p13', + 'p14', 'p15', 'p16', 'p19', 'p20', 'p21'], 'jSymbolic') # first bundle ds = features.DataSet(classLabel='Region') diff --git a/music21/figuredBass/notation.py b/music21/figuredBass/notation.py index e679f41d91..99681cc1ac 100644 --- a/music21/figuredBass/notation.py +++ b/music21/figuredBass/notation.py @@ -24,7 +24,7 @@ ''' shorthandNotation: dict[tuple[int|None, ...], tuple[int, ...]] = { - (None,): (5, 3), + (None,): (5, 3), (5,): (5, 3), (6,): (6, 3), (7,): (7, 5, 3), @@ -35,7 +35,7 @@ (4, 3): (6, 4, 3), (4, 2): (6, 4, 2), (2,): (6, 4, 2), - } +} prefixes = ['+', '#', '++', '##'] suffixes = ['\\'] diff --git a/music21/figuredBass/realizer.py b/music21/figuredBass/realizer.py index 7e2c0a2376..69e92bdb8d 100644 --- a/music21/figuredBass/realizer.py +++ b/music21/figuredBass/realizer.py @@ -367,16 +367,16 @@ def retrieveSegments( previousBassNote = bassNotes[bassNoteIndex] bassNote = t.cast(note.Note, currentMapping[allKeys[0]][-1]) previousSegment = segment.OverlaidSegment(bassNote, bassNote.editorial.notationString, - self._fbScale, - fbRules, numParts, maxPitch) + self._fbScale, + fbRules, numParts, maxPitch) previousSegment.quarterLength = previousBassNote.quarterLength segmentList.append(previousSegment) for k in allKeys[1:]: (startTime, unused_endTime) = k bassNote = t.cast(note.Note, currentMapping[k][-1]) currentSegment = segment.OverlaidSegment(bassNote, bassNote.editorial.notationString, - self._fbScale, - fbRules, numParts, maxPitch) + self._fbScale, + fbRules, numParts, maxPitch) for partNumber in range(1, len(currentMapping[k])): upperPitch = t.cast(note.Note, currentMapping[k][partNumber - 1]) currentSegment.fbRules._partPitchLimits.append((partNumber, upperPitch)) diff --git a/music21/figuredBass/segment.py b/music21/figuredBass/segment.py index ac7b183890..5bf60d4818 100644 --- a/music21/figuredBass/segment.py +++ b/music21/figuredBass/segment.py @@ -211,16 +211,16 @@ def singlePossibilityRules( singlePossibRules = [ (fbRules.forbidIncompletePossibilities, - possibility.isIncomplete, - False, - [self.pitchNamesInChord]), + possibility.isIncomplete, + False, + [self.pitchNamesInChord]), (True, - possibility.upperPartsWithinLimit, - True, - [fbRules.upperPartsMaxSemitoneSeparation]), + possibility.upperPartsWithinLimit, + True, + [fbRules.upperPartsMaxSemitoneSeparation]), (fbRules.forbidVoiceCrossing, - possibility.voiceCrossing, - False) + possibility.voiceCrossing, + False) ] return singlePossibRules @@ -856,8 +856,8 @@ def _resolveOrdinarySegment( correctB = segmentB.allCorrectSinglePossibilities() correctAB = itertools.product(correctA, correctB) return filter(lambda possibAB: self._isCorrectConsecutivePossibility(possibA=possibAB[0], - possibB=possibAB[1]), - correctAB) + possibB=possibAB[1]), + correctAB) def _resolveSpecialSegment( self, diff --git a/music21/freezeThaw.py b/music21/freezeThaw.py index c8f25caf8b..a4aa36df62 100644 --- a/music21/freezeThaw.py +++ b/music21/freezeThaw.py @@ -1206,9 +1206,9 @@ def testPickleMidi(self): from music21 import note a = str(common.getSourceFilePath() - / 'midi' - / 'testPrimitive' - / 'test03.mid') + / 'midi' + / 'testPrimitive' + / 'test03.mid') # a = 'https://github.com/ELVIS-Project/vis/raw/master/test_corpus/prolationum-sanctus.midi' c = converter.parse(a) diff --git a/music21/graph/axis.py b/music21/graph/axis.py index 807b4fcea4..b2c20cb6ea 100644 --- a/music21/graph/axis.py +++ b/music21/graph/axis.py @@ -314,7 +314,7 @@ class PitchAxis(Axis): labelDefault = 'Pitch' quantities: tuple[str, ...] = ('pitchGeneric', ) - def __init__(self, client=None, axisName='x'): + def __init__(self, client=None, axisName='x') -> None: super().__init__(client, axisName) self.showOctaves: bool|t.Literal['few'] = 'few' self.showEnharmonic = True @@ -449,7 +449,7 @@ class PitchClassAxis(PitchAxis): labelDefault = 'Pitch Class' quantities: tuple[str, ...] = ('pitchClass', 'pitchclass', 'pc') - def __init__(self, client=None, axisName='x'): + def __init__(self, client=None, axisName='x') -> None: self.showOctaves: bool|t.Literal['few'] = False super().__init__(client, axisName) self.minValue = 0 @@ -1125,7 +1125,7 @@ class QuarterLengthAxis(PositionAxis): 'duration', ) - def __init__(self, client=None, axisName='x'): + def __init__(self, client=None, axisName='x') -> None: super().__init__(client, axisName) self.useLogScale: bool|int = True self.useDurationNames = False diff --git a/music21/graph/plot.py b/music21/graph/plot.py index 9b10fbbc7d..a83d8e583b 100644 --- a/music21/graph/plot.py +++ b/music21/graph/plot.py @@ -1596,7 +1596,7 @@ def testHorizontalBarPitchClassOffset(self): a = corpus.parse('bach/bwv57.8') b = HorizontalBarPitchClassOffset(a.parts[0].measures(3, 6), - title='Bach (soprano voice, mm 3-6)') + title='Bach (soprano voice, mm 3-6)') b.run() def testScatterWeightedPitchSpaceQuarterLength(self): @@ -1792,19 +1792,19 @@ def testWindowed(self, doneAction=None): doneAction=doneAction, dpi=300) b.run() self.assertEqual(b.graphLegend.data, - [ - ['Major', - [('C#', '#f0727a'), ('D', '#ffd752'), ('E', '#eeff9a'), - ('F#', '#b9f0ff'), ('A', '#bb9aff'), ('B', '#ffb5ff') - ] - ], - ['Minor', - [('c#', '#8c0e16'), ('', '#ffffff'), ('', '#ffffff'), - ('f#', '#558caa'), ('', '#ffffff'), ('b', '#9b519b') - ] - ] - ] - ) + [ + ['Major', + [('C#', '#f0727a'), ('D', '#ffd752'), ('E', '#eeff9a'), + ('F#', '#b9f0ff'), ('A', '#bb9aff'), ('B', '#ffb5ff') + ] + ], + ['Minor', + [('c#', '#8c0e16'), ('', '#ffffff'), ('', '#ffffff'), + ('f#', '#558caa'), ('', '#ffffff'), ('b', '#9b519b') + ] + ] + ] + ) def testFeatures(self): streamList = ['bach/bwv66.6', 'schoenberg/opus19/movement2', 'corelli/opus3no1/1grave'] diff --git a/music21/humdrum/harmParser.py b/music21/humdrum/harmParser.py index 7cbc8c5a5f..7f2d76e691 100644 --- a/music21/humdrum/harmParser.py +++ b/music21/humdrum/harmParser.py @@ -186,14 +186,14 @@ class HarmDefs: ''' # The definition for a harm expr harmExpression = (r'^(' - + accidental - + roots - + attribute - + intervals - + inversion - + alternative - + secondary - + r')$') + + accidental + + roots + + attribute + + intervals + + inversion + + alternative + + secondary + + r')$') class HarmParser: diff --git a/music21/humdrum/testFiles.py b/music21/humdrum/testFiles.py index 55927f7f05..421890d9c3 100644 --- a/music21/humdrum/testFiles.py +++ b/music21/humdrum/testFiles.py @@ -93,7 +93,7 @@ ) ojibway = re.sub(r'\s\s\s\s+', '\t', - r''' + r''' !! Ojibway Indian Song !! Transcribed by Frances Densmore !! No. 84 "The Sioux Follow Me" diff --git a/music21/languageExcerpts/naturalLanguageObjects.py b/music21/languageExcerpts/naturalLanguageObjects.py index 40c8caff8b..05fbd7ed28 100644 --- a/music21/languageExcerpts/naturalLanguageObjects.py +++ b/music21/languageExcerpts/naturalLanguageObjects.py @@ -211,7 +211,7 @@ def testConvertNotes(self) -> None: self.assertEqual('', repr(toNote('Heses', 'de'))) self.assertEqual('', repr(toNote('Eisis', 'de'))) self.assertEqual('', - repr(toNote('la quadruple dièse', 'fr'))) + repr(toNote('la quadruple dièse', 'fr'))) self.assertEqual('', repr(toNote('si triple bémol', 'fr'))) def testConvertChords(self) -> None: diff --git a/music21/mei/test_base.py b/music21/mei/test_base.py index cf3e8c2258..311110bd2b 100644 --- a/music21/mei/test_base.py +++ b/music21/mei/test_base.py @@ -2652,7 +2652,7 @@ def testUnit4StaffFromElement(self, mockTrans, mockClef, mockKey, mockTime, ''' # 1.) prepare elem = ETree.Element(f'{MEI_NS}staffDef', attrib={'meter.count': '1', - 'meter.unit': '3'}) + 'meter.unit': '3'}) mockTime.return_value = 'mockTime return' mockFromString.side_effect = instrument.InstrumentException # otherwise staffDefFromElement() thinks it got a real Instrument @@ -2670,7 +2670,7 @@ def testIntegration4StaffFromElement(self): ''' # 1.) prepare elem = ETree.Element(f'{MEI_NS}staffDef', attrib={'meter.count': '1', - 'meter.unit': '3'}) + 'meter.unit': '3'}) # 2.) run actual = base.staffDefFromElement(elem) @@ -2686,7 +2686,7 @@ def testStaffGrpUnit1StaffFromElement(self, mockStaffDefFE): ''' elem = ETree.Element('staffGrp') innerElems = [ETree.Element(f'{MEI_NS}staffDef', attrib={'n': str(n)}) - for n in range(4)] + for n in range(4)] for eachElem in innerElems: elem.append(eachElem) mockStaffDefFE.side_effect = lambda x, unused_y: f"processed {x.get('n')}" diff --git a/music21/metadata/primitives.py b/music21/metadata/primitives.py index 14df0e7498..3c87afcfe2 100644 --- a/music21/metadata/primitives.py +++ b/music21/metadata/primitives.py @@ -497,9 +497,9 @@ def __eq__(self, other) -> bool: False ''' return (type(self) is type(other) - and self._data == other._data - and self._dataUncertainty == other._dataUncertainty - and self.relevance == other.relevance) + and self._data == other._data + and self._dataUncertainty == other._dataUncertainty + and self.relevance == other.relevance) def _reprInternal(self) -> str: return str(self) diff --git a/music21/musedata/__init__.py b/music21/musedata/__init__.py index 966304b88c..91a60e14aa 100644 --- a/music21/musedata/__init__.py +++ b/music21/musedata/__init__.py @@ -536,8 +536,8 @@ def getDynamicObjects(self): return post # find targets from largest to smallest targets = ('ppp', 'fff', - 'pp', 'ff', 'fp', 'mp', 'mf', - 'p', 'f', 'm', 'Z', 'Zp', 'R') + 'pp', 'ff', 'fp', 'mp', 'mf', + 'p', 'f', 'm', 'Z', 'Zp', 'R') for target in targets: pos = data.find(target) if pos < 0: diff --git a/music21/musedata/translate.py b/music21/musedata/translate.py index 6f95655db5..794f7800a8 100644 --- a/music21/musedata/translate.py +++ b/music21/musedata/translate.py @@ -366,7 +366,7 @@ def testBasic(self): from music21 import common fp1 = (common.getSourceFilePath() - / 'musedata' / 'testPrimitive' / 'test01' / '01.md') + / 'musedata' / 'testPrimitive' / 'test01' / '01.md') mdw = musedata.MuseDataWork() mdw.addFile(fp1) diff --git a/music21/musicxml/partStaffExporter.py b/music21/musicxml/partStaffExporter.py index b266576db9..00e51acd6f 100644 --- a/music21/musicxml/partStaffExporter.py +++ b/music21/musicxml/partStaffExporter.py @@ -85,7 +85,7 @@ def addStaffTags( mxStaff = Element('staff') mxStaff.text = str(staffNumber) helpers.insertBeforeElements(tag, mxStaff, - tagList=['beam', 'notations', 'lyric', 'play', + tagList=['beam', 'notations', 'lyric', 'play', 'sound']) @@ -423,8 +423,8 @@ def makeDivider(inner_sourceNumber: int|str) -> Element[t.Any]: # Or, gap in measure numbers in the subsequent part: keep iterating through target if (sourceNumber is not None - and targetNumber is not None - and helpers.measureNumberComesBefore(targetNumber, sourceNumber)): + and targetNumber is not None + and helpers.measureNumberComesBefore(targetNumber, sourceNumber)): continue # sourceMeasure is not None! # Or, gap in measure numbers in target: record necessary insertions until gap is closed @@ -587,7 +587,7 @@ def isMultiAttribute(m21Class: type[M21ObjType], mxAttributes, mxStaves, tagList=['part-symbol', 'instruments', 'clef', 'staff-details', - 'transpose', 'directive', 'measure-style'] + 'transpose', 'directive', 'measure-style'] ) if multiKey and mxAttributes is not None: diff --git a/music21/musicxml/test_xmlToM21.py b/music21/musicxml/test_xmlToM21.py index b9e5047fb0..21987c6a47 100644 --- a/music21/musicxml/test_xmlToM21.py +++ b/music21/musicxml/test_xmlToM21.py @@ -813,7 +813,8 @@ def testBarException(self): def testChordSymbolException(self): MP = MeasureParser() mxHarmony = self.EL('A' - 'add') + '' + 'add') with self.assertRaisesRegex(MusicXMLImportException, 'degree-value missing'): MP.xmlToChordSymbol(mxHarmony) @@ -1548,7 +1549,7 @@ def testDirectionPosition(self): # TextExpression s = converter.parse(testPrimitive.textExpressions) positionedEls = [el for el in s.recurse() if el.hasStyleInformation - and el.style.relativeX is not None] + and el.style.relativeX is not None] self.assertEqual(len(positionedEls), 3) self.assertEqual( list(set(type(el) for el in positionedEls)), @@ -1558,7 +1559,7 @@ def testDirectionPosition(self): # Wedge s = corpus.parse('beach') positionedEls = [el for el in s.recurse() if el.hasStyleInformation - and el.style.relativeX is not None] + and el.style.relativeX is not None] self.assertEqual(len(positionedEls), 40) self.assertEqual( sorted(set(type(el) for el in positionedEls), key=repr), @@ -1617,7 +1618,7 @@ def testClearingTuplets(self): d = duration.Duration(2 / 3) self.assertEqual(len(d.tuplets), 1) mxNoteNoType = EL('D6' - '3') + '3') MP.xmlToDuration(mxNoteNoType, inputM21=d) self.assertEqual(len(d.tuplets), 0) self.assertEqual(d.linked, True) diff --git a/music21/musicxml/xmlToM21.py b/music21/musicxml/xmlToM21.py index 6b57035eaf..ba4089cdbd 100644 --- a/music21/musicxml/xmlToM21.py +++ b/music21/musicxml/xmlToM21.py @@ -2245,8 +2245,8 @@ def adjustTimeAttributesFromMeasure(self, m: stream.Measure): # If the measure is overfull by a "round" amount, assume that it was intended # otherwise it was likely the result of malformed MusicXML. if (diff > 0.5 - or nearestMultiple(diff, 0.0625)[1] < tol - or nearestMultiple(diff, 1 / 12)[1] < tol): + or nearestMultiple(diff, 0.0625)[1] < tol + or nearestMultiple(diff, 1 / 12)[1] < tol): mOffsetShift = mHighestTime else: mOffsetShift = lastTimeSignatureQuarterLength @@ -5094,8 +5094,8 @@ def findM21VoiceFromXmlVoice( useVoice = self.lastVoice if useVoice is None: # pragma: no cover warnings.warn('Cannot put in an element with a missing voice tag when ' - + 'no previous voice tag was given. Assuming voice 1... ', - MusicXMLWarning, stacklevel=2) + + 'no previous voice tag was given. Assuming voice 1... ', + MusicXMLWarning, stacklevel=2) useVoice = 1 thisVoice: stream.Voice|None = None diff --git a/music21/omr/evaluators.py b/music21/omr/evaluators.py index fa4c91eb79..bb8a02cd5c 100644 --- a/music21/omr/evaluators.py +++ b/music21/omr/evaluators.py @@ -177,7 +177,7 @@ def minEditDist(self, target, source): distance[i][j] = min(distance[i - 1][j] + 1, distance[i][j - 1] + 1, distance[i - 1][j - 1] - + self.substCost(source[j - 1], target[i - 1])) + + self.substCost(source[j - 1], target[i - 1])) return distance[n][m] def getDifferences(self): diff --git a/music21/pitch.py b/music21/pitch.py index cda3b89d85..feb281a4da 100644 --- a/music21/pitch.py +++ b/music21/pitch.py @@ -307,9 +307,9 @@ def _convertPsToOct(ps: int|float) -> int: def _convertPsToStep( ps: int|float ) -> tuple[StepName, - Accidental, - Microtone, - int]: + Accidental, + Microtone, + int]: ''' Utility conversion; does not process internal representations. @@ -5044,7 +5044,7 @@ def set_displayStatus(newDisplayStatus: bool) -> None: otherSimultaneousPitches and cautionaryPitchClass and any(pSimult.step == self.step and pSimult.pitchClass != self.pitchClass - for pSimult in otherSimultaneousPitches) + for pSimult in otherSimultaneousPitches) ): set_displayStatus(True) return @@ -5279,9 +5279,9 @@ def set_displayStatus(newDisplayStatus: bool) -> None: # if An or A to A#: need to make sure display is set elif ((pPast.accidental is None or pPast.accidental.name == 'natural') - and acc is not None # redundant. for mypy - and pSelf.accidental is not None - and pSelf.accidental.name != 'natural'): + and acc is not None # redundant. for mypy + and pSelf.accidental is not None + and pSelf.accidental.name != 'natural'): acc.displayStatus = True setFromPitchPast = True break diff --git a/music21/roman.py b/music21/roman.py index 714f5ab4f9..52d5df146e 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -1390,8 +1390,8 @@ def romanNumeralFromChord( and chordObj.isSeventhOfType((0, 3, 7, 10))): rnString = ft.prefix + stepRoman + minorSeventhSubs[inversionString] elif (not chordHasMajorThird - and inversionString in minorMajorSeventhSubs - and chordObj.isSeventhOfType((0, 3, 7, 11))): + and inversionString in minorMajorSeventhSubs + and chordObj.isSeventhOfType((0, 3, 7, 11))): rnString = ft.prefix + stepRoman + minorMajorSeventhSubs[inversionString] elif (not noKeyGiven @@ -1434,8 +1434,9 @@ def romanNumeralFromChord( try: rn = RomanNumeral(rnString, keyObj, updatePitches=False, - # correctRNAlterationForMinor() adds cautionary - sixthMinor=Minor67Default.CAUTIONARY, seventhMinor=Minor67Default.CAUTIONARY) + # correctRNAlterationForMinor() adds cautionary + sixthMinor=Minor67Default.CAUTIONARY, + seventhMinor=Minor67Default.CAUTIONARY) except fbNotation.ModifierException as strerror: # pragma: no cover raise RomanNumeralException( 'Could not parse ' @@ -3210,7 +3211,7 @@ def _parseRNAloneAmidstAug6( and aug6type != 'It' and workingFigure[0] == '6' and (len(workingFigure) < 2 - or not workingFigure[1].isdigit())): + or not workingFigure[1].isdigit())): # Fr6 => Fr43 workingFigure = self._aug6defaultInversions[aug6type] + workingFigure[1:] @@ -3409,8 +3410,8 @@ def _updatePitches(self) -> None: for j in range(numberNotes): i = numberNotes - j - 1 thisScaleDegree = (bassScaleDegree - + t.cast(int, self.figuresNotationObj.numbers[i]) - - 1) + + t.cast(int, self.figuresNotationObj.numbers[i]) + - 1) newPitch = t.cast(pitch.Pitch, useScale.pitchFromDegree( thisScaleDegree, direction=scale.Direction.ASCENDING)) pitchName = self.figuresNotationObj.modifiers[i].modifyPitchName(newPitch.name) diff --git a/music21/romanText/translate.py b/music21/romanText/translate.py index 0add263098..c21f3b1145 100644 --- a/music21/romanText/translate.py +++ b/music21/romanText/translate.py @@ -548,7 +548,7 @@ def translateMeasureLineToken(self, measureLineToken: rtObjects.RTMeasure) -> No ''' p = self.p skipsPriorMeasures = ((measureLineToken.number[0] > self.lastMeasureNumber + 1) - and (self.previousRn is not None)) + and (self.previousRn is not None)) isSingleMeasureCopy = (len(measureLineToken.number) == 1 and measureLineToken.isCopyDefinition) isMultipleMeasureCopy = (len(measureLineToken.number) > 1) diff --git a/music21/scale/__init__.py b/music21/scale/__init__.py index 27f0af1815..20ead29ffa 100644 --- a/music21/scale/__init__.py +++ b/music21/scale/__init__.py @@ -629,13 +629,13 @@ def nextPitch(self, ''' net = t.cast('intervalNetwork.IntervalNetwork', self._net) post = net.nextPitch(pitchReference=pitchReference, - nodeName=nodeName, - pitchOrigin=pitchOrigin, - direction=direction, - stepSize=stepSize, - alteredDegrees=self._alteredDegrees, - getNeighbor=getNeighbor - ) + nodeName=nodeName, + pitchOrigin=pitchOrigin, + direction=direction, + stepSize=stepSize, + alteredDegrees=self._alteredDegrees, + getNeighbor=getNeighbor + ) return copy.deepcopy(post) def getNewTonicPitch(self, @@ -1061,54 +1061,54 @@ def buildNetwork(self, mode: t.Any = None) -> None: edges = ( # ascending {'interval': 'M2', - 'connections': ( - [Terminus.LOW, 0, Direction.ASCENDING], # c to d - )}, + 'connections': ( + [Terminus.LOW, 0, Direction.ASCENDING], # c to d + )}, {'interval': 'm3', - 'connections': ( - [0, 1, Direction.ASCENDING], # d to f - )}, + 'connections': ( + [0, 1, Direction.ASCENDING], # d to f + )}, {'interval': 'M2', - 'connections': ( - [1, 2, Direction.ASCENDING], # f to g - )}, + 'connections': ( + [1, 2, Direction.ASCENDING], # f to g + )}, {'interval': 'm2', - 'connections': ( - [2, 3, Direction.ASCENDING], # g to a- - )}, + 'connections': ( + [2, 3, Direction.ASCENDING], # g to a- + )}, {'interval': 'M3', - 'connections': ( - [3, Terminus.HIGH, Direction.ASCENDING], # a- to c - )}, + 'connections': ( + [3, Terminus.HIGH, Direction.ASCENDING], # a- to c + )}, # descending {'interval': 'M2', - 'connections': ( - [Terminus.HIGH, 4, Direction.DESCENDING], # c to b- - )}, + 'connections': ( + [Terminus.HIGH, 4, Direction.DESCENDING], # c to b- + )}, {'interval': 'M2', - 'connections': ( - [4, 5, Direction.DESCENDING], # b- to a- - )}, + 'connections': ( + [4, 5, Direction.DESCENDING], # b- to a- + )}, {'interval': 'm2', - 'connections': ( - [5, 6, Direction.DESCENDING], # a- to g - )}, + 'connections': ( + [5, 6, Direction.DESCENDING], # a- to g + )}, {'interval': 'M2', - 'connections': ( - [6, 7, Direction.DESCENDING], # g to f - )}, + 'connections': ( + [6, 7, Direction.DESCENDING], # g to f + )}, {'interval': 'M2', - 'connections': ( - [7, 8, Direction.DESCENDING], # f to e- - )}, + 'connections': ( + [7, 8, Direction.DESCENDING], # f to e- + )}, {'interval': 'm2', - 'connections': ( - [8, 9, Direction.DESCENDING], # e- to d - )}, + 'connections': ( + [8, 9, Direction.DESCENDING], # e- to d + )}, {'interval': 'M2', - 'connections': ( - [9, Terminus.LOW, Direction.DESCENDING], # d to c - )}, + 'connections': ( + [9, Terminus.LOW, Direction.DESCENDING], # d to c + )}, ) self._net = intervalNetwork.IntervalNetwork( @@ -1231,33 +1231,33 @@ def buildNetwork(self, mode: t.Any = None) -> None: edges = ( # all bidirectional {'interval': 'm3', - 'connections': ( - [Terminus.LOW, 0, Direction.BI], # c to e- - )}, + 'connections': ( + [Terminus.LOW, 0, Direction.BI], # c to e- + )}, {'interval': 'M2', - 'connections': ( - [0, 1, Direction.BI], # e- to f - )}, + 'connections': ( + [0, 1, Direction.BI], # e- to f + )}, {'interval': 'M2', - 'connections': ( - [1, 3, Direction.BI], # f to g - )}, + 'connections': ( + [1, 3, Direction.BI], # f to g + )}, {'interval': 'a1', - 'connections': ( - [1, 2, Direction.BI], # f to f# - )}, + 'connections': ( + [1, 2, Direction.BI], # f to f# + )}, {'interval': 'm2', - 'connections': ( - [2, 3, Direction.BI], # f# to g - )}, + 'connections': ( + [2, 3, Direction.BI], # f# to g + )}, {'interval': 'm3', - 'connections': ( - [3, 4, Direction.BI], # g to b- - )}, + 'connections': ( + [3, 4, Direction.BI], # g to b- + )}, {'interval': 'M2', - 'connections': ( - [4, Terminus.HIGH, Direction.BI], # b- to c - )}, + 'connections': ( + [4, Terminus.HIGH, Direction.BI], # b- to c + )}, ) self._net = intervalNetwork.IntervalNetwork( @@ -1992,45 +1992,45 @@ def getScaleDegreeAndAccidentalFromPitch( # noinspection SpellCheckingInspection _solfegSyllables = {1: {-2: 'def', -1: 'de', - 0: 'do', - 1: 'di', - 2: 'dis', + 0: 'do', + 1: 'di', + 2: 'dis', }, 2: {-2: 'raf', -1: 'ra', - 0: 're', - 1: 'ri', - 2: 'ris', + 0: 're', + 1: 'ri', + 2: 'ris', }, 3: {-2: 'mef', -1: 'me', - 0: 'mi', - 1: 'mis', - 2: 'mish', + 0: 'mi', + 1: 'mis', + 2: 'mish', }, 4: {-2: 'fef', -1: 'fe', - 0: 'fa', - 1: 'fi', - 2: 'fis', + 0: 'fa', + 1: 'fi', + 2: 'fis', }, 5: {-2: 'sef', -1: 'se', - 0: 'sol', - 1: 'si', - 2: 'sis', + 0: 'sol', + 1: 'si', + 2: 'sis', }, 6: {-2: 'lef', -1: 'le', - 0: 'la', - 1: 'li', - 2: 'lis', + 0: 'la', + 1: 'li', + 2: 'lis', }, 7: {-2: 'tef', -1: 'te', - 0: 'ti', - 1: 'tis', - 2: 'tish', + 0: 'ti', + 1: 'tis', + 2: 'tish', }, } # TOO SLOW! @@ -2042,45 +2042,45 @@ def getScaleDegreeAndAccidentalFromPitch( _humdrumSolfegSyllables = { 1: {-2: 'def', -1: 'de', - 0: 'do', - 1: 'di', - 2: 'dis', + 0: 'do', + 1: 'di', + 2: 'dis', }, 2: {-2: 'raf', -1: 'ra', - 0: 're', - 1: 'ri', - 2: 'ris', + 0: 're', + 1: 'ri', + 2: 'ris', }, 3: {-2: 'mef', -1: 'me', - 0: 'mi', - 1: 'my', - 2: 'mish', + 0: 'mi', + 1: 'my', + 2: 'mish', }, 4: {-2: 'fef', -1: 'fe', - 0: 'fa', - 1: 'fi', - 2: 'fis', + 0: 'fa', + 1: 'fi', + 2: 'fis', }, 5: {-2: 'sef', -1: 'se', - 0: 'so', - 1: 'si', - 2: 'sis', + 0: 'so', + 1: 'si', + 2: 'sis', }, 6: {-2: 'lef', -1: 'le', - 0: 'la', - 1: 'li', - 2: 'lis', + 0: 'la', + 1: 'li', + 2: 'lis', }, 7: {-2: 'tef', -1: 'te', - 0: 'ti', - 1: 'ty', - 2: 'tish', + 0: 'ti', + 1: 'ty', + 2: 'tish', }, } diff --git a/music21/scale/intervalNetwork.py b/music21/scale/intervalNetwork.py index 15bcf218f1..db91d356bc 100644 --- a/music21/scale/intervalNetwork.py +++ b/music21/scale/intervalNetwork.py @@ -1402,9 +1402,9 @@ def nextPitch( else: p = self.transposePitchAndApplySimplification(intervalObj.reverse(), p) pCollect = self.processAlteredNodes(alteredDegrees=alteredDegrees, - n=n, - p=p, - direction=direction) + n=n, + p=p, + direction=direction) return pCollect @@ -1588,9 +1588,9 @@ def realizeAscending( p = self.transposePitchAndApplySimplification(intervalObj, p) pCollect = p pCollect = self.processAlteredNodes(alteredDegrees=alteredDegrees, - n=n, - p=p, - direction=Direction.ASCENDING) + n=n, + p=p, + direction=Direction.ASCENDING) if attempts >= maxAttempts: raise IntervalNetworkException( @@ -2716,7 +2716,7 @@ def getPitchFromNodeDegree( # only match this generously if we are equating termini if equateTermini: if ((realizedNId in (Terminus.HIGH, Terminus.LOW)) - and (nodeTargetId.id in (Terminus.HIGH, Terminus.LOW))): + and (nodeTargetId.id in (Terminus.HIGH, Terminus.LOW))): return realizedPitch[i] # environLocal.printDebug(['getPitchFromNodeDegree() on trial', trial, ', diff --git a/music21/scale/scala/__init__.py b/music21/scale/scala/__init__.py index e96f7eb7f3..221473e185 100644 --- a/music21/scale/scala/__init__.py +++ b/music21/scale/scala/__init__.py @@ -657,21 +657,21 @@ def testScalaScaleB(self) -> None: '699.997698171', '800.909593096', '900.026096390', - '1000.020156709', - '1088.268714730', - '1200.000000000']) + '1000.020156709', + '1088.268714730', + '1200.000000000']) self.assertEqual([f'{x:.9f}' for x in ss.getAdjacentCents()], ['100.099209825', - '99.880633466', - '99.994060319', + '99.880633466', + '99.994060319', '100.134576860', - '97.936518664', + '97.936518664', '102.043324627', - '99.909374409', + '99.909374409', '100.911894925', - '99.116503294', - '99.994060319', - '88.248558022', + '99.116503294', + '99.994060319', + '88.248558022', '111.731285270']) self.assertEqual([str(x) for x in ss.getIntervalSequence()], diff --git a/music21/scale/test_scale_main.py b/music21/scale/test_scale_main.py index 587056715c..bc3826c0fa 100644 --- a/music21/scale/test_scale_main.py +++ b/music21/scale/test_scale_main.py @@ -894,9 +894,9 @@ def testDerivedScaleNoOctaves(self): e = d.deriveRanked(['C', 'E', 'G'], comparisonAttribute='name') self.assertEqual(str(e), ''.join(['[(3, ), ', - '(3, ), ', - '(2, ), ', - '(2, )]']), + '(3, ), ', + '(2, ), ', + '(2, )]']), str(e) ) diff --git a/music21/search/lyrics.py b/music21/search/lyrics.py index ca0f886841..8623c1b940 100644 --- a/music21/search/lyrics.py +++ b/music21/search/lyrics.py @@ -206,7 +206,7 @@ def index(self, s: stream.Stream|None = None) -> list[IndexedLyric]: indexByIdentifier: OrderedDict[str|int, list[IndexedLyric]] = OrderedDict() iTextByIdentifier: OrderedDict[str|int, str] = OrderedDict() lastSyllabicByIdentifier: OrderedDict[str|int, - str|None] = OrderedDict() + str|None] = OrderedDict() for n in s.recurse().notes: ls: list[note.Lyric] = n.lyrics diff --git a/music21/search/serial.py b/music21/search/serial.py index d7b8cd79eb..b820fda448 100644 --- a/music21/search/serial.py +++ b/music21/search/serial.py @@ -852,9 +852,9 @@ def searchRowsOnlyInclude(self, n: note.NotRest, partNumber: int | None) -> None rowSuperset = csn.readPitchClassesFromBottom() lowerBound = max([0, len(rowSuperset) - - self.searchLength - - len(self.activeChordList[-1].pitches) - + 1]) + - self.searchLength + - len(self.activeChordList[-1].pitches) + + 1]) upperBound = min([len(self.activeChordList[0].pitches), len(rowSuperset) - self.searchLength + 1]) for j in range(lowerBound, upperBound): diff --git a/music21/serial.py b/music21/serial.py index 940696a981..b98c6f7da4 100644 --- a/music21/serial.py +++ b/music21/serial.py @@ -99,151 +99,151 @@ def _reprInternal(self): # noinspection SpellCheckingInspection historicalDict = { 'WebernOp29': ('Webern', 'Op. 29', 'Cantata I', - [3, 11, 2, 1, 5, 4, 7, 6, 10, 9, 0, 8]), + [3, 11, 2, 1, 5, 4, 7, 6, 10, 9, 0, 8]), 'WebernOp28': ('Webern', 'Op. 28', 'String Quartet', - [1, 0, 3, 2, 6, 7, 4, 5, 9, 8, 11, 10]), + [1, 0, 3, 2, 6, 7, 4, 5, 9, 8, 11, 10]), 'SchoenbergOp24Mvmt5': ('Schoenberg', 'Op. 24', 'Serenade, Mvt. 5, "Tanzscene"', - [9, 10, 0, 3, 4, 6, 5, 7, 8, 11, 1, 2]), + [9, 10, 0, 3, 4, 6, 5, 7, 8, 11, 1, 2]), 'SchoenbergOp24Mvmt4': ('Schoenberg', 'Op. 24', 'Serenade, Mvt. 4, "Sonett"', - [4, 2, 3, 11, 0, 1, 8, 6, 9, 5, 7, 10]), + [4, 2, 3, 11, 0, 1, 8, 6, 9, 5, 7, 10]), 'SchoenbergJakobsleiter': ('Schoenberg', None, 'Die Jakobsleiter', - [1, 2, 5, 4, 8, 7, 0, 3, 11, 10, 6, 9]), + [1, 2, 5, 4, 8, 7, 0, 3, 11, 10, 6, 9]), 'SchoenbergOp27No4': ('Schoenberg', 'Op. 27 No. 4', 'Four Pieces for Mixed Chorus, No. 4', - [1, 3, 10, 6, 8, 4, 11, 0, 2, 9, 5, 7]), + [1, 3, 10, 6, 8, 4, 11, 0, 2, 9, 5, 7]), 'WebernOp23': ('Webern', 'Op. 23', 'Three Songs', - [8, 3, 7, 4, 10, 6, 2, 5, 1, 0, 9, 11]), + [8, 3, 7, 4, 10, 6, 2, 5, 1, 0, 9, 11]), 'BergLuluActIIScene1': ('Berg', 'Lulu, Act II, Scene 1', - 'Perm. (Every 5th Note Of Transposed Primary Row)', - [10, 7, 1, 0, 9, 2, 4, 11, 5, 8, 3, 6]), + 'Perm. (Every 5th Note Of Transposed Primary Row)', + [10, 7, 1, 0, 9, 2, 4, 11, 5, 8, 3, 6]), 'SchoenbergOp27No1': ('Schoenberg', 'Op. 27 No. 1', 'Four Pieces for Mixed Chorus, No. 1', - [6, 5, 2, 8, 7, 1, 3, 4, 10, 9, 11, 0]), + [6, 5, 2, 8, 7, 1, 3, 4, 10, 9, 11, 0]), 'BergLuluActIScene20': ('Berg', 'Lulu, Act I , Scene XX', - 'Perm. (Every 7th Note Of Transposed Primary Row)', - [10, 6, 3, 8, 5, 11, 4, 2, 9, 0, 1, 7]), + 'Perm. (Every 7th Note Of Transposed Primary Row)', + [10, 6, 3, 8, 5, 11, 4, 2, 9, 0, 1, 7]), 'SchoenbergOp27No3': ('Schoenberg', 'Op. 27 No. 3', 'Four Pieces for Mixed Chorus, No. 3', - [7, 6, 2, 4, 5, 3, 11, 0, 8, 10, 9, 1]), + [7, 6, 2, 4, 5, 3, 11, 0, 8, 10, 9, 1]), 'SchoenbergOp27No2': ('Schoenberg', 'Op. 27 No. 2', 'Four Pieces for Mixed Chorus, No. 2', - [0, 11, 4, 10, 2, 8, 3, 7, 6, 5, 9, 1]), + [0, 11, 4, 10, 2, 8, 3, 7, 6, 5, 9, 1]), 'SchoenbergFragPiano': ('Schoenberg', None, 'Fragment For Piano', - [6, 9, 0, 7, 1, 2, 8, 11, 5, 10, 4, 3]), + [6, 9, 0, 7, 1, 2, 8, 11, 5, 10, 4, 3]), 'SchoenbergOp50B': ('Schoenberg', 'Op. 50B', 'De Profundis', - [3, 9, 8, 4, 2, 10, 7, 11, 0, 6, 5, 1]), + [3, 9, 8, 4, 2, 10, 7, 11, 0, 6, 5, 1]), 'SchoenbergOp50C': ('Schoenberg', 'Op. 50C', 'Modern Psalms, The First Psalm', - [4, 3, 0, 8, 11, 7, 5, 9, 6, 10, 1, 2]), + [4, 3, 0, 8, 11, 7, 5, 9, 6, 10, 1, 2]), 'SchoenbergOp50A': ('Schoenberg', 'Op. 50A', 'Three Times A Thousand Years', - [7, 9, 6, 4, 5, 11, 10, 2, 0, 1, 3, 8]), + [7, 9, 6, 4, 5, 11, 10, 2, 0, 1, 3, 8]), 'SchoenbergMosesAron': ('Schoenberg', None, 'Moses And Aron', - [9, 10, 4, 2, 3, 1, 7, 5, 6, 8, 11, 0]), + [9, 10, 4, 2, 3, 1, 7, 5, 6, 8, 11, 0]), 'WebernOp25': ('Webern', 'Op. 25', 'Three Songs', - [7, 4, 3, 6, 1, 5, 2, 11, 10, 0, 9, 8]), + [7, 4, 3, 6, 1, 5, 2, 11, 10, 0, 9, 8]), 'SchoenbergOp23No5': ('Schoenberg', 'Op. 23, No. 5', 'Five Piano Pieces', - [1, 9, 11, 7, 8, 6, 10, 2, 4, 3, 0, 5]), + [1, 9, 11, 7, 8, 6, 10, 2, 4, 3, 0, 5]), 'SchoenbergOp28No1': ('Schoenberg', 'Op. 28 No. 1', - 'Three Satires for Mixed Chorus, No. 1', - [0, 4, 7, 1, 9, 11, 5, 3, 2, 6, 8, 10]), + 'Three Satires for Mixed Chorus, No. 1', + [0, 4, 7, 1, 9, 11, 5, 3, 2, 6, 8, 10]), 'SchoenbergOp28No3': ('Schoenberg', 'Op. 28 No. 3', - 'Three Satires for Mixed Chorus, No. 3', - [5, 6, 4, 8, 2, 10, 7, 9, 3, 11, 1, 0]), + 'Three Satires for Mixed Chorus, No. 3', + [5, 6, 4, 8, 2, 10, 7, 9, 3, 11, 1, 0]), 'WebernOp21': ('Webern', 'Op. 21', 'Chamber Symphony', - [5, 8, 7, 6, 10, 9, 3, 4, 0, 1, 2, 11]), + [5, 8, 7, 6, 10, 9, 3, 4, 0, 1, 2, 11]), 'SchoenbergIsraelExists': ('Schoenberg', None, 'Israel Exists Again', - [0, 3, 4, 9, 11, 5, 2, 1, 10, 8, 6, 7]), + [0, 3, 4, 9, 11, 5, 2, 1, 10, 8, 6, 7]), 'SchoenbergOp35No2': ('Schoenberg', 'Op. 35', 'Six Pieces for Male Chorus, No. 2', - [6, 9, 7, 1, 0, 2, 5, 11, 10, 3, 4, 8]), + [6, 9, 7, 1, 0, 2, 5, 11, 10, 3, 4, 8]), 'SchoenbergOp35No3': ('Schoenberg', 'Op. 35', 'Six Pieces for Male Chorus, No. 3', - [3, 6, 7, 8, 5, 0, 9, 10, 4, 11, 2, 1]), + [3, 6, 7, 8, 5, 0, 9, 10, 4, 11, 2, 1]), 'SchoenbergOp35No1': ('Schoenberg', 'Op. 35', 'Six Pieces for Male Chorus, No. 1', - [2, 11, 3, 5, 4, 1, 8, 10, 9, 6, 0, 7]), + [2, 11, 3, 5, 4, 1, 8, 10, 9, 6, 0, 7]), 'SchoenbergOp48No1': ('Schoenberg', 'Op. 48', 'Three Songs, No. 1, "Sommermud"', - [1, 2, 0, 6, 3, 5, 4, 10, 11, 7, 9, 8]), + [1, 2, 0, 6, 3, 5, 4, 10, 11, 7, 9, 8]), 'SchoenbergOp35No5': ('Schoenberg', 'Op. 35', 'Six Pieces for Male Chorus, No. 5', - [1, 7, 10, 2, 3, 11, 8, 4, 0, 6, 5, 9]), + [1, 7, 10, 2, 3, 11, 8, 4, 0, 6, 5, 9]), 'SchoenbergOp29': ('Schoenberg', 'Op. 29', 'Suite', - [3, 7, 6, 10, 2, 11, 0, 9, 8, 4, 5, 1]), + [3, 7, 6, 10, 2, 11, 0, 9, 8, 4, 5, 1]), 'BergLyricSuitePerm': ('Berg', None, 'Lyric Suite, Last Mvt. Permutation', - [5, 6, 10, 4, 1, 9, 2, 8, 7, 3, 0, 11]), + [5, 6, 10, 4, 1, 9, 2, 8, 7, 3, 0, 11]), 'WebernOp20': ('Webern', 'Op. 20', 'String Trio', - [8, 7, 2, 1, 6, 5, 9, 10, 3, 4, 0, 11]), + [8, 7, 2, 1, 6, 5, 9, 10, 3, 4, 0, 11]), 'SchoenbergOp46': ('Schoenberg', 'Op. 46', 'A Survivor From Warsaw', - [6, 7, 0, 8, 4, 3, 11, 10, 5, 9, 1, 2]), + [6, 7, 0, 8, 4, 3, 11, 10, 5, 9, 1, 2]), 'SchoenbergFragOrganSonata': ('Schoenberg', None, 'Fragment of Sonata For Organ', - [1, 7, 11, 3, 9, 2, 8, 6, 10, 5, 0, 4]), + [1, 7, 11, 3, 9, 2, 8, 6, 10, 5, 0, 4]), 'SchoenbergOp44': ('Schoenberg', 'Op. 44', 'Prelude To A Suite From "Genesis"', - [10, 6, 2, 5, 4, 0, 11, 8, 1, 3, 9, 7]), + [10, 6, 2, 5, 4, 0, 11, 8, 1, 3, 9, 7]), 'SchoenbergOp45': ('Schoenberg', 'Op. 45', 'String Trio', - [2, 10, 3, 9, 4, 1, 11, 8, 6, 7, 5, 0]), + [2, 10, 3, 9, 4, 1, 11, 8, 6, 7, 5, 0]), 'SchoenbergOp33A': ('Schoenberg', 'Op. 33A', 'Two Piano Pieces, No. 1', - [10, 5, 0, 11, 9, 6, 1, 3, 7, 8, 2, 4]), + [10, 5, 0, 11, 9, 6, 1, 3, 7, 8, 2, 4]), 'SchoenbergOp25': ('Schoenberg', 'Op.25', 'Suite for Piano', - [4, 5, 7, 1, 6, 3, 8, 2, 11, 0, 9, 10]), + [4, 5, 7, 1, 6, 3, 8, 2, 11, 0, 9, 10]), 'SchoenbergOp26': ('Schoenberg', 'Op. 26', 'Wind Quintet', - [3, 7, 9, 11, 1, 0, 10, 2, 4, 6, 8, 5]), + [3, 7, 9, 11, 1, 0, 10, 2, 4, 6, 8, 5]), 'SchoenbergOp33B': ('Schoenberg', 'Op. 33B', 'Two Piano Pieces, No. 2', - [11, 1, 5, 3, 9, 8, 6, 10, 7, 4, 0, 2]), + [11, 1, 5, 3, 9, 8, 6, 10, 7, 4, 0, 2]), 'BergViolinConcerto': ('Berg', None, 'Concerto For Violin And Orchestra', - [7, 10, 2, 6, 9, 0, 4, 8, 11, 1, 3, 5]), + [7, 10, 2, 6, 9, 0, 4, 8, 11, 1, 3, 5]), 'WebernOp22': ('Webern', 'Op. 22', 'Quartet For Violin, Clarinet, Tenor Sax, And Piano', - [6, 3, 2, 5, 4, 8, 9, 10, 11, 1, 7, 0]), + [6, 3, 2, 5, 4, 8, 9, 10, 11, 1, 7, 0]), 'BergLulu': ('Berg', None, 'Lulu: Primary Row', - [0, 4, 5, 2, 7, 9, 6, 8, 11, 10, 3, 1]), + [0, 4, 5, 2, 7, 9, 6, 8, 11, 10, 3, 1]), 'WebernOp30': ('Webern', 'Op. 30', 'Variations For Orchestra', - [9, 10, 1, 0, 11, 2, 3, 6, 5, 4, 7, 8]), + [9, 10, 1, 0, 11, 2, 3, 6, 5, 4, 7, 8]), 'WebernOp31': ('Webern', 'Op. 31', 'Cantata II', - [6, 9, 5, 4, 8, 3, 7, 11, 10, 2, 1, 0]), + [6, 9, 5, 4, 8, 3, 7, 11, 10, 2, 1, 0]), 'WebernOpNo17No1': ('Webern', 'Op. 17, No. 1', '"Armer Sunder, Du"', - [11, 10, 5, 6, 3, 4, 7, 8, 9, 0, 1, 2]), + [11, 10, 5, 6, 3, 4, 7, 8, 9, 0, 1, 2]), 'WebernOp24': ('Webern', 'Op. 24', 'Concerto For Nine Instruments', - [11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9]), + [11, 10, 2, 3, 7, 6, 8, 4, 5, 0, 1, 9]), 'SchoenbergOp48No2': ('Schoenberg', 'Op. 48', 'Three Songs, No. 2, "Tot"', - [2, 3, 9, 1, 10, 4, 8, 7, 0, 11, 5, 6]), + [2, 3, 9, 1, 10, 4, 8, 7, 0, 11, 5, 6]), 'WebernOp27': ('Webern', 'Op. 27', 'Variations For Piano', - [3, 11, 10, 2, 1, 0, 6, 4, 7, 5, 9, 8]), + [3, 11, 10, 2, 1, 0, 6, 4, 7, 5, 9, 8]), 'SchoenbergOp47': ('Schoenberg', 'Op. 47', 'Fantasy For Violin And Piano', - [10, 9, 1, 11, 5, 7, 3, 4, 0, 2, 8, 6]), + [10, 9, 1, 11, 5, 7, 3, 4, 0, 2, 8, 6]), 'WebernOp19No2': ('Webern', 'Op. 19, No. 2', '"Ziehn Die Schafe"', - [8, 4, 9, 6, 7, 0, 11, 5, 3, 2, 10, 1]), + [8, 4, 9, 6, 7, 0, 11, 5, 3, 2, 10, 1]), 'WebernOp19No1': ('Webern', 'Op. 19, No. 1', '"Weiss Wie Lilien"', - [7, 10, 6, 5, 3, 9, 8, 1, 2, 11, 4, 0]), + [7, 10, 6, 5, 3, 9, 8, 1, 2, 11, 4, 0]), 'WebernOp26': ('Webern', 'Op. 26', 'Das Augenlicht', - [8, 10, 9, 0, 11, 3, 4, 1, 5, 2, 6, 7]), + [8, 10, 9, 0, 11, 3, 4, 1, 5, 2, 6, 7]), 'SchoenbergFragPianoPhantasia': ('Schoenberg', None, 'Fragment of Phantasia For Piano', - [1, 5, 3, 6, 4, 8, 0, 11, 2, 9, 10, 7]), + [1, 5, 3, 6, 4, 8, 0, 11, 2, 9, 10, 7]), 'BergDerWein': ('Berg', None, 'Der Wein', - [2, 4, 5, 7, 9, 10, 1, 6, 8, 0, 11, 3]), + [2, 4, 5, 7, 9, 10, 1, 6, 8, 0, 11, 3]), 'BergWozzeckPassacaglia': ('Berg', None, 'Wozzeck, Act I, Scene 4 "Passacaglia"', - [3, 11, 7, 1, 0, 6, 4, 10, 9, 5, 8, 2]), + [3, 11, 7, 1, 0, 6, 4, 10, 9, 5, 8, 2]), 'WebernOp18No1': ('Webern', 'Op. 18, No. 1', '"Schatzerl Klein"', - [0, 11, 5, 8, 10, 9, 3, 4, 1, 7, 2, 6]), + [0, 11, 5, 8, 10, 9, 3, 4, 1, 7, 2, 6]), 'WebernOp18No2': ('Webern', 'Op. 18, No. 2', '"Erlosung"', - [6, 9, 5, 8, 4, 7, 3, 11, 2, 10, 1, 0]), + [6, 9, 5, 8, 4, 7, 3, 11, 2, 10, 1, 0]), 'WebernOp18No3': ('Webern', 'Op. 18, No. 3', '"Ave, Regina Coelorum"', - [4, 3, 7, 6, 5, 11, 10, 2, 1, 0, 9, 8]), + [4, 3, 7, 6, 5, 11, 10, 2, 1, 0, 9, 8]), 'SchoenbergOp42': ('Schoenberg', 'Op. 42', 'Concerto For Piano And Orchestra', - [3, 10, 2, 5, 4, 0, 6, 8, 1, 9, 11, 7]), + [3, 10, 2, 5, 4, 0, 6, 8, 1, 9, 11, 7]), 'SchoenbergOp48No3': ('Schoenberg', 'Op. 48', 'Three Songs, No, 3, "Madchenlied"', - [1, 7, 9, 11, 3, 5, 10, 6, 4, 0, 8, 2]), + [1, 7, 9, 11, 3, 5, 10, 6, 4, 0, 8, 2]), 'SchoenbergOp37': ('Schoenberg', 'Op. 37', 'Fourth String Quartet', - [2, 1, 9, 10, 5, 3, 4, 0, 8, 7, 6, 11]), + [2, 1, 9, 10, 5, 3, 4, 0, 8, 7, 6, 11]), 'SchoenbergOp36': ('Schoenberg', 'Op. 36', 'Concerto for Violin and Orchestra', - [9, 10, 3, 11, 4, 6, 0, 1, 7, 8, 2, 5]), + [9, 10, 3, 11, 4, 6, 0, 1, 7, 8, 2, 5]), 'SchoenbergOp34': ('Schoenberg', 'Op. 34', 'Accompaniment to a Film Scene', - [3, 6, 2, 4, 1, 0, 9, 11, 10, 8, 5, 7]), + [3, 6, 2, 4, 1, 0, 9, 11, 10, 8, 5, 7]), 'BergChamberConcerto': ('Berg', None, 'Chamber Concerto', - [11, 7, 5, 9, 2, 3, 6, 8, 0, 1, 4, 10]), + [11, 7, 5, 9, 2, 3, 6, 8, 0, 1, 4, 10]), 'SchoenbergOp32': ('Schoenberg', 'Op. 32', 'Von Heute Auf Morgen', - [2, 3, 9, 1, 11, 5, 8, 7, 4, 0, 10, 6]), + [2, 3, 9, 1, 11, 5, 8, 7, 4, 0, 10, 6]), 'SchoenbergOp31': ('Schoenberg', 'Op. 31', 'Variations for Orchestra', - [10, 4, 6, 3, 5, 9, 2, 1, 7, 8, 11, 0]), + [10, 4, 6, 3, 5, 9, 2, 1, 7, 8, 11, 0]), 'SchoenbergOp30': ('Schoenberg', 'Op. 30', 'Third String Quartet', - [7, 4, 3, 9, 0, 5, 6, 11, 10, 1, 8, 2]), + [7, 4, 3, 9, 0, 5, 6, 11, 10, 1, 8, 2]), 'BergLyricSuite': ('Berg', None, 'Lyric Suite Primary Row', - [5, 4, 0, 9, 7, 2, 8, 1, 3, 6, 10, 11]), + [5, 4, 0, 9, 7, 2, 8, 1, 3, 6, 10, 11]), 'SchoenbergOp41': ('Schoenberg', 'Op. 41', 'Ode To Napoleon', - [1, 0, 4, 5, 9, 8, 3, 2, 6, 7, 11, 10]), + [1, 0, 4, 5, 9, 8, 3, 2, 6, 7, 11, 10]), 'WebernOp17No3': ('Webern', 'Op. 17, No. 3', '"Heiland, Unsere Missetaten..."', - [8, 5, 4, 3, 7, 6, 0, 1, 2, 11, 10, 9]), + [8, 5, 4, 3, 7, 6, 0, 1, 2, 11, 10, 9]), 'WebernOp17No2': ('Webern', 'Op. 17, No. 2', '"Liebste Jungfrau"', - [1, 0, 11, 7, 8, 2, 3, 6, 5, 4, 9, 10]) + [1, 0, 11, 7, 8, 2, 3, 6, 5, 4, 9, 10]) } # ------------------------------------------------------------------------------ diff --git a/music21/sieve.py b/music21/sieve.py index 5f4605495b..a5466e1ec7 100644 --- a/music21/sieve.py +++ b/music21/sieve.py @@ -203,7 +203,7 @@ def rabinMiller(n): # primes up to 100; 2, 3 handled by mod 6 primes = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, - 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] + 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] if n <= 100: if n in primes: @@ -484,7 +484,7 @@ def _fillRange(self): segNeg = [-x for x in segNeg] # make negative if len(segNeg) < self.length: segPos = self._fillRabinMiller(0, self.length - len(segNeg), - None, 'up') + None, 'up') self.seg = segNeg + segPos else: # add positive values self.seg = segNeg diff --git a/music21/spanner.py b/music21/spanner.py index ea6f9423d0..c4e035f3c4 100644 --- a/music21/spanner.py +++ b/music21/spanner.py @@ -698,16 +698,16 @@ def fill( endOffsetInHierarchy = opFrac(startOffsetInHierarchy + startElement.quarterLength) matchIterator = (searchStream - .recurse() - .getElementsByOffsetInHierarchy( - startOffsetInHierarchy, - endOffsetInHierarchy, - includeEndBoundary=includeEndBoundary, - mustFinishInSpan=mustFinishInSpan, - mustBeginInSpan=mustBeginInSpan, - includeElementsThatEndAtStart=includeElementsThatEndAtStart) - .getElementsByClass(self.fillElementTypes) - ) + .recurse() + .getElementsByOffsetInHierarchy( + startOffsetInHierarchy, + endOffsetInHierarchy, + includeEndBoundary=includeEndBoundary, + mustFinishInSpan=mustFinishInSpan, + mustBeginInSpan=mustBeginInSpan, + includeElementsThatEndAtStart=includeElementsThatEndAtStart) + .getElementsByClass(self.fillElementTypes) + ) for foundElement in matchIterator: if foundElement is startElement: @@ -2965,7 +2965,7 @@ def testLineA(self): n3 = s.notes[-1] sp1 = Line(n1, n2, startTick='up', lineType='dotted') sp2 = Line(n2, n3, startTick='down', lineType='dashed', - endHeight=40) + endHeight=40) s.append(sp1) s.append(sp2) # s.show('t') diff --git a/music21/stream/base.py b/music21/stream/base.py index baea9a99bb..f5f0036add 100644 --- a/music21/stream/base.py +++ b/music21/stream/base.py @@ -4409,13 +4409,13 @@ def hasMeasureNumberInformation(measureIterator: iterator.StreamIterator[Measure matches = [m for m in mStreamIter if m.number in matchingMeasureNumbers] else: matches = [m for i, m in enumerate(mStreamIter) - if i + 1 in matchingMeasureNumbers] + if i + 1 in matchingMeasureNumbers] else: if hasUniqueMeasureNumbers: matches = [m for m in mStreamIter if m.number >= numberStart] else: matches = [m for i, m in enumerate(mStreamIter) - if i + 1 >= numberStart] + if i + 1 >= numberStart] if startSuffix is not None: oldMatches = matches @@ -6253,7 +6253,7 @@ def _uniqueOffsetsAndEndTimes(self, offsetsOnly=False, endTimesOnly=False): endTimes = set() else: endTimes = {opFrac(v[0] + v[1].duration.quarterLength) - for v in offsetDictValues} + for v in offsetDictValues} return sorted(offsets.union(endTimes)) def chordify( @@ -11559,7 +11559,7 @@ def doOneMeasureWithVoices(mInner): mEmpty.mergeAttributes(m) # Propagate bar, meter, key elements to lower parts mEmpty.mergeElements(m, classFilterList=('Barline', - 'TimeSignature', 'KeySignature')) + 'TimeSignature', 'KeySignature')) s.parts[i].insert(self.elementOffset(m), mEmpty) # if part has no measures but has voices, contents of each voice go into the part elif self.hasVoices(): diff --git a/music21/stream/makeNotation.py b/music21/stream/makeNotation.py index b3523a4404..c681463fbb 100644 --- a/music21/stream/makeNotation.py +++ b/music21/stream/makeNotation.py @@ -1701,9 +1701,11 @@ def makeAccidentalsInMeasureStream( # just get the chromatic pitches from previous measure # G-naturals in C major following G-flats in F major need cautionary # G-naturals in C major following G-flats in Db major don't - pitchPastMeasure = [p for p in - measuresOnly[i - 1].pitches + ornamentalPitches(measuresOnly[i - 1]) - if p.name not in ksLastDiatonic] + previousMeasure = measuresOnly[i - 1] + pitchPastMeasure = [ + p for p in previousMeasure.pitches + ornamentalPitches(previousMeasure) + if p.name not in ksLastDiatonic + ] # Get tiePitchSet from previous measure try: previousNoteOrChord = measuresOnly[i - 1][note.NotRest][-1] @@ -2319,7 +2321,7 @@ def testStreamExceptions(self): with self.assertRaises(stream.StreamException) as cm: p.makeMeasures(meterStream=duration.Duration()) self.assertEqual(str(cm.exception), - 'meterStream is neither a Stream nor a TimeSignature!') + 'meterStream is neither a Stream nor a TimeSignature!') def testMakeTiesChangingTimeSignatures(self): ''' diff --git a/music21/stream/tests.py b/music21/stream/tests.py index 0686170f98..8006c018fa 100644 --- a/music21/stream/tests.py +++ b/music21/stream/tests.py @@ -526,8 +526,8 @@ def testStreamSortRecursion(self): offsets = [a.offset for a in fs_fs] # safer is a.getOffsetBySite(fs_fs) offsetsBrief = offsets[:20] self.assertEqual(offsetsBrief, - [0, 2, 4, 5, 6, 7, 9, 10, - 11, 12, 13, 14, 15, 15, 16, 17, 17, 18, 19, 19]) + [0, 2, 4, 5, 6, 7, 9, 10, + 11, 12, 13, 14, 15, 15, 16, 17, 17, 18, 19, 19]) def testOverlapsA(self): a = Stream() @@ -1046,17 +1046,17 @@ def testFindConsecutiveNotes(self): consec = m.findConsecutiveNotes() self.assertEqual([repr(x) for x in consec], - ['', - '', - '', - '', - 'None', - '', - '', - '', - '', - ] - ) + ['', + '', + '', + '', + 'None', + '', + '', + '', + '', + ] + ) # with voices in each of two measures m.insert(meter.TimeSignature('2/4')) @@ -1356,13 +1356,13 @@ def testStripTiesClearBeaming(self): p = p.splitAtDurations(recurse=True)[0] p.makeBeams(inPlace=True) self.assertEqual([repr(el.beams) for el in p[note.Note]], - ['', - '>', - '>', - '>', - '>' - ] - ) + ['', + '>', + '>', + '>', + '>' + ] + ) def testStripTiesStopTieChordFollowsRest(self): ''' @@ -2220,16 +2220,16 @@ def testMakeRestsB(self): match = str(list(s.flatten().notesAndRests)) self.assertEqual(match, '[, , ' - + ', , ' - + ', ]') + + ', , ' + + ', ]') match = str([(n, n.duration) for n in s.flatten().notesAndRests]) self.assertEqual(match, '[(, ), ' - + '(, ), ' - + '(, ), ' - + '(, ), ' - + '(, ), ' - + '(, )]') + + '(, ), ' + + '(, ), ' + + '(, ), ' + + '(, ), ' + + '(, )]') GEX = m21ToXml.GeneralObjectExporter() unused_mx = GEX.parse(s).decode('utf-8') @@ -2738,7 +2738,7 @@ def testMakeAccidentalsB(self): c = m34.getElementsByClass(chord.Chord) # assuming not showing accidental b/c of key self.assertEqual(str(c[1].pitches), '(, ' - + ', )') + + ', )') # because of key self.assertEqual(str(c[1].pitches[0].accidental.displayStatus), 'False') @@ -2748,7 +2748,7 @@ def testMakeAccidentalsB(self): # has correct pitches but natural not showing on C self.assertEqual(str(c[0].pitches), '(, , ' - + ')') + + ')') self.assertEqual(str(c[0].pitches[0].accidental), 'None') def testMakeAccidentalsC(self): @@ -4140,7 +4140,7 @@ def testAnalyze(self): s = corpus.parse('bach/bwv66.6') sub = [s.parts[0], s.parts[1], s.measures(4, 5), - s.parts[2].measures(4, 5)] + s.parts[2].measures(4, 5)] matchAmbitus = [interval.Interval(12), interval.Interval(15), @@ -4866,11 +4866,11 @@ def testMakeChordsBuiltC(self): sMod = s1.chordify(removeRedundantPitches=True) self.assertEqual([p.nameWithOctave for p in sMod.getElementsByClass(chord.Chord)[0].pitches], - ['C2', 'G2']) + ['C2', 'G2']) self.assertEqual([p.nameWithOctave for p in sMod.getElementsByClass(chord.Chord)[1].pitches], - ['E4', 'F#4']) + ['E4', 'F#4']) # without redundant pitch gathering sMod = s1.chordify(removeRedundantPitches=False) @@ -5529,8 +5529,8 @@ def testChordifyImported(self): 21.0, 21.5, 22.0, 22.5, 23.0, 23.5, 24.0, 24.5, 25.0, 25.5, 26.0, 26.5, 27.0, 30.0, 33.0, 34.5, 35.5, 36.0, 37.5, 38.0, 39.0, 40.0, 40.5, 41.0, 42.0, 43.5, 45.0, 45.5, 46.0, 46.5, - 47.0, 47.5, 48.0, 49.5, 51.0, 51.5, 52.0, 52.5, 53.0, 53.5, - 54.0, 54.5, 55.0, 55.5, 56.0, 56.5, 57.0, 58.5, 59.5]) + 47.0, 47.5, 48.0, 49.5, 51.0, 51.5, 52.0, 52.5, 53.0, 53.5, + 54.0, 54.5, 55.0, 55.5, 56.0, 56.5, 57.0, 58.5, 59.5]) self.assertEqual(len(post[chord.Chord]), 71) # Careful! one version of the caching is screwing up m. 20 which definitely should # not have rests in it -- was creating 69 notes, not 71. @@ -6341,7 +6341,7 @@ def testStripTiesBuiltB(self): self.assertEqual([n.offset for n in first_m_notesAndRests], [0.0, 1.0, 3.0]) self.assertEqual([n.quarterLength - for n in first_m_notesAndRests], + for n in first_m_notesAndRests], [1.0, 2.0, 2.0]) self.assertEqual([n.beatStr for n in first_m_notesAndRests], ['1', '2', '4']) @@ -6440,7 +6440,7 @@ def testDerivationA(self): m4 = p1.measure(4) self.assertIs(m4.flatten().notesAndRests.stream().derivation.rootDerivation, m4, - list(m4.flatten().notesAndRests.stream().derivation.chain())) + list(m4.flatten().notesAndRests.stream().derivation.chain())) # part is the root derivation of a measures() call mRange = p1.measures(4, 6) @@ -7549,12 +7549,12 @@ def testTransposeByPitchB(self): self.assertEqual([str(p) for p in s.parts[0].pitches], ['D4', 'E4', 'F#4', 'G4', 'A4', 'B4', 'C#5', 'D5']) self.assertEqual([None if p.accidental is None else p.accidental.displayStatus - for p in s.parts[0].pitches], + for p in s.parts[0].pitches], [True, None, False, None, None, None, False, None]) self.assertEqual([str(p) for p in s.parts[1].pitches], ['A4', 'B4', 'C#5', 'D5', 'E5', 'F#5', 'G#5', 'A5']) self.assertEqual([None if p.accidental is None else p.accidental.displayStatus - for p in s.parts[1].pitches], + for p in s.parts[1].pitches], [True, None, False, None, None, False, False, None]) self.assertEqual(s.atSoundingPitch, 'unknown') @@ -7563,12 +7563,12 @@ def testTransposeByPitchB(self): self.assertEqual([str(p) for p in s.parts[0].pitches], ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5']) self.assertEqual([None if p.accidental is None else p.accidental.displayStatus - for p in s.parts[0].pitches], + for p in s.parts[0].pitches], [True, None, None, None, None, None, None, None]) self.assertEqual([str(p) for p in s.parts[1].pitches], ['C4', 'D4', 'E4', 'F4', 'G4', 'A4', 'B4', 'C5']) self.assertEqual([None if p.accidental is None else p.accidental.displayStatus - for p in s.parts[1].pitches], + for p in s.parts[1].pitches], [True, None, None, None, None, None, None, None]) def testTransposeByPitchC(self): @@ -7609,9 +7609,9 @@ def testExtendTiesA(self): '' ], '', - ['None', - '' - ] + ['None', + '' + ] ]) def testExtendTiesB(self): @@ -7889,7 +7889,7 @@ def testChordifyF(self): self.maxDiff = None self.assertMultiLineEqual( s.parts[0].getElementsByClass(Measure)[0]._reprText(addEndTimes=True, - useMixedNumerals=True), + useMixedNumerals=True), '''{0 - 0} {0 - 0} {0 - 0} diff --git a/music21/test/multiprocessTest.py b/music21/test/multiprocessTest.py index bfec2e3dea..f45cbaa144 100644 --- a/music21/test/multiprocessTest.py +++ b/music21/test/multiprocessTest.py @@ -158,7 +158,7 @@ def mainPoolRunner(testGroup=('test',), restoreEnvironmentDefaults=False, leaveO # unordered says that results can RETURN in any order; not that # they'd be pooled out in any order. res = pool.imap_unordered(runOneModuleWithoutImp, - ((modGather, fp) for fp in pathsToRun)) + ((modGather, fp) for fp in pathsToRun)) continueIt = True timeouts = 0 diff --git a/music21/test/testRunner.py b/music21/test/testRunner.py index 62c822ba4f..f5539daab8 100644 --- a/music21/test/testRunner.py +++ b/music21/test/testRunner.py @@ -253,8 +253,8 @@ def testHello(self): # search all names for case-insensitive match for name in dir(tObj): if (name.lower() == runThisTest.lower() - or name.lower() == ('test' + runThisTest.lower()) - or name.lower() == ('xtest' + runThisTest.lower())): + or name.lower() == ('test' + runThisTest.lower()) + or name.lower() == ('xtest' + runThisTest.lower())): runThisTest = name break if hasattr(tObj, runThisTest): diff --git a/music21/test/test_chord.py b/music21/test/test_chord.py index 3c06f08ac4..caa50790e5 100644 --- a/music21/test/test_chord.py +++ b/music21/test/test_chord.py @@ -619,15 +619,15 @@ def testVolumePerPitchC(self): amps = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] for accent in [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 0.5, 0.5, - 1, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, - None, None, None, None, - None, None, None, None, - None, None, None, None, - None, None, None, None, - 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 1, 0.5, 0.5, 0.5, 0.5, - 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, - 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 1, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, + None, None, None, None, + None, None, None, None, + None, None, None, None, + None, None, None, None, + 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 1, 0.5, 0.5, 0.5, 0.5, + 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, ]: cNew = copy.deepcopy(c) if accent is not None: diff --git a/music21/test/test_metadata.py b/music21/test/test_metadata.py index 3784dd4e36..06e21df60e 100644 --- a/music21/test/test_metadata.py +++ b/music21/test/test_metadata.py @@ -430,7 +430,7 @@ def checkUniqueNamedItem( # self.assertIsInstance isn't sufficient, apparently. assert isinstance(itemNamespaceName, metadata.Contributor) self.assertEqual(itemNamespaceName.role, - contributorRole if contributorRole else uniqueName) + contributorRole if contributorRole else uniqueName) def testUniqueNameAccess(self): self.checkUniqueNamedItem('abstract', 'dcterms') diff --git a/music21/test/test_note.py b/music21/test/test_note.py index 35fa34cc66..7c039df7ae 100644 --- a/music21/test/test_note.py +++ b/music21/test/test_note.py @@ -246,7 +246,7 @@ def testNoteEquality(self): articulations.StrongAccent()] for a, b, c, d, match in [(n1, n4, a1, a1, True), - (n1, n2, a1, a1, False), (n1, n3, a1, a1, False), + (n1, n2, a1, a1, False), (n1, n3, a1, a1, False), # same pitch different orderings (n1, n4, a2, a3, True), (n1, n4, a4, a5, True), # different pitch same orderings diff --git a/music21/test/test_pitch.py b/music21/test/test_pitch.py index 309fe3f3cb..fbd4379bb8 100644 --- a/music21/test/test_pitch.py +++ b/music21/test/test_pitch.py @@ -266,7 +266,7 @@ def compare(_past, _result): pList = [Pitch('f#3'), Pitch('f3'), Pitch('f#3'), Pitch('g3'), Pitch('f#4'), Pitch('f#4')] result = [('sharp', False), ('natural', True), ('sharp', True), - (None, None), ('sharp', True), ('sharp', False)] + (None, None), ('sharp', True), ('sharp', False)] # no 4 is a dicey affair; could go either way ks = key.KeySignature(1) proc(pList, [], ks.alteredPitches) diff --git a/music21/text.py b/music21/text.py index 7675f7d946..28a6dfab09 100644 --- a/music21/text.py +++ b/music21/text.py @@ -416,7 +416,7 @@ def readExcerpts(cls): ''' for languageCode in cls.languageCodes: thisExcerpt = (common.getSourceFilePath() / 'languageExcerpts' - / 'trainingData' / (languageCode + '.txt')) + / 'trainingData' / (languageCode + '.txt')) with thisExcerpt.open(encoding='utf-8') as f: excerptWords = f.read().split() diff --git a/music21/tree/verticality.py b/music21/tree/verticality.py index 789d6466a6..07d6f1f920 100644 --- a/music21/tree/verticality.py +++ b/music21/tree/verticality.py @@ -1064,7 +1064,7 @@ def getAllVoiceLeadingQuartets( if ((verticalityStreamParts[pp[0]] == thisQuartetTopPart or verticalityStreamParts[pp[0]] == thisQuartetBottomPart) and (verticalityStreamParts[pp[1]] == thisQuartetTopPart - or verticalityStreamParts[pp[1]] == thisQuartetBottomPart)): + or verticalityStreamParts[pp[1]] == thisQuartetBottomPart)): isAppropriate = True break if not isAppropriate: diff --git a/music21/variant.py b/music21/variant.py index 552b748a6a..8c30a75b76 100644 --- a/music21/variant.py +++ b/music21/variant.py @@ -470,10 +470,10 @@ def replacedElements(self, contextStream=None, classList=None, if classList is not None: classes.extend(classList) returnStream = contextStream.getElementsByOffset(vStart, vEnd, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=classes).stream() + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=classes).stream() elif self.lengthType == 'deletion': vMiddle = vStart + self.containedHighestTime @@ -484,14 +484,14 @@ def replacedElements(self, contextStream=None, classList=None, if classList is not None: classes.extend(classList) returnPart1 = contextStream.getElementsByOffset(vStart, vMiddle, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=classes).stream() + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=classes).stream() returnPart2 = contextStream.getElementsByOffset(vMiddle, vEnd, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True).stream() + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True).stream() returnStream = returnPart1 for e in returnPart2.elements: @@ -1860,7 +1860,7 @@ def _getBestListAndScore(streamX, streamY, badnessDict, listDict, # Check the added bar case: kList, kBadness = _getBestListAndScore(streamX, streamY, badnessDict, listDict, - isNone=True, streamXIndex=streamXIndex, streamYIndex=streamYIndex + 1) + isNone=True, streamXIndex=streamXIndex, streamYIndex=streamYIndex + 1) if kList is None: kList = [] if kList: @@ -2427,22 +2427,22 @@ def _getNextElements(s, v, numberOfElements=1): if lengthType == 'elongation': variantOffset = v.getOffsetBySite(s) potentialTargets = s.getElementsByOffset(variantOffset, - offsetEnd=s.highestTime, - includeEndBoundary=True, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=[vClass]) + offsetEnd=s.highestTime, + includeEndBoundary=True, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=[vClass]) returnElement = potentialTargets.first() else: replacementDuration = v.replacementQuarterLength variantOffset = v.getOffsetBySite(s) potentialTargets = s.getElementsByOffset(variantOffset + replacementDuration, - offsetEnd=s.highestTime, - includeEndBoundary=True, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=[vClass]) + offsetEnd=s.highestTime, + includeEndBoundary=True, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=[vClass]) returnElement = potentialTargets.first() @@ -2643,19 +2643,19 @@ def testDeepCopyVariantA(self): # normal in-place variant functionality s.insert(5, v1) self.assertEqual(self.pitchOut(s.pitches), - '[G4, G4, G4, G4, G4, G4, G4, G4]') + '[G4, G4, G4, G4, G4, G4, G4, G4]') sv = s.activateVariants(inPlace=False) self.assertEqual(self.pitchOut(sv.pitches), - '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') + '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') # test functionality on a deepcopy sCopy = copy.deepcopy(s) self.assertEqual(len(sCopy.getElementsByClass(Variant)), 1) self.assertEqual(self.pitchOut(sCopy.pitches), - '[G4, G4, G4, G4, G4, G4, G4, G4]') + '[G4, G4, G4, G4, G4, G4, G4, G4]') sCopy.activateVariants(inPlace=True) self.assertEqual(self.pitchOut(sCopy.pitches), - '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') + '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') def testDeepCopyVariantB(self): s = stream.Stream() @@ -2671,11 +2671,11 @@ def testDeepCopyVariantB(self): sCopy = copy.deepcopy(s) sCopy.activateVariants(inPlace=True) self.assertEqual(self.pitchOut(sCopy.pitches), - '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') + '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') # can transpose the note in place sCopy.notes[5].transpose(12, inPlace=True) self.assertEqual(self.pitchOut(sCopy.pitches), - '[G4, G4, G4, G4, G4, F#5, A-4, G4, G4]') + '[G4, G4, G4, G4, G4, F#5, A-4, G4, G4]') # however, if the Variant deepcopy still references the original # notes it had, then when we try to activate the variant in the @@ -2683,7 +2683,7 @@ def testDeepCopyVariantB(self): s.activateVariants(inPlace=True) self.assertEqual(self.pitchOut(s.pitches), - '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') + '[G4, G4, G4, G4, G4, F#4, A-4, G4, G4]') class TestExternal(unittest.TestCase): diff --git a/music21/voiceLeading.py b/music21/voiceLeading.py index 61060b9a5d..7a137cf302 100644 --- a/music21/voiceLeading.py +++ b/music21/voiceLeading.py @@ -577,15 +577,15 @@ def parallelMotion( if isinstance(requiredInterval, str): requiredInterval = interval.Interval(requiredInterval) intervalsAreValid = (vInt0.semiSimpleName - == requiredInterval.semiSimpleName + == requiredInterval.semiSimpleName and vInt1.semiSimpleName - == requiredInterval.semiSimpleName) + == requiredInterval.semiSimpleName) elif isinstance(requiredInterval, (interval.Interval, interval.DiatonicInterval)): intervalsAreValid = (vInt0.semiSimpleName - == requiredInterval.semiSimpleName + == requiredInterval.semiSimpleName and vInt1.semiSimpleName - == requiredInterval.semiSimpleName) + == requiredInterval.semiSimpleName) return intervalsAreValid @@ -1161,7 +1161,7 @@ def isProperResolution(self) -> bool: if keyScale and n2degree != 3: return False return (self.outwardContraryMotion() - and secondHarmony == 6) + and secondHarmony == 6) elif firstHarmony == 'd5': if keyScale and n1degree != 7: @@ -1169,7 +1169,7 @@ def isProperResolution(self) -> bool: if keyScale and n2degree != 1: return False return (self.inwardContraryMotion() - and secondHarmony == 3) + and secondHarmony == 3) elif firstHarmony == 'm7': if keyScale and n1degree != 5: @@ -1291,9 +1291,9 @@ def modalOpening(self) -> bool: openingIntervals = ('P1', 'P5') openingFunctions = ('I', 'V') return ((v0.simpleName in openingIntervals - or v1.simpleName in openingIntervals) - and (r1[0].upper() in openingFunctions if r1 is not False else False - or r2[0].upper() in openingFunctions if r2 is not False else False)) + or v1.simpleName in openingIntervals) + and (r1[0].upper() in openingFunctions if r1 is not False else False + or r2[0].upper() in openingFunctions if r2 is not False else False)) @common.decorators.deprecated( 'June 2026', 'v12', 'Use `not vlq.modalOpening()` instead.' @@ -1367,10 +1367,10 @@ def clausulaVera(self) -> bool: tonicName = self.key.tonic.name hIntervalNames = {self.hIntervals[0].name, self.hIntervals[1].name} return (hIntervalNames == {'m2', 'M2'} - and self.contraryMotion() - and self.vIntervals[1].name in ('P1', 'P8') - and self.v1n2.name == tonicName - and self.v2n2.name == tonicName) + and self.contraryMotion() + and self.vIntervals[1].name in ('P1', 'P8') + and self.v1n2.name == tonicName + and self.v2n2.name == tonicName) @common.decorators.deprecated( 'June 2026', 'v12', 'Use `not vlq.clausulaVera()` instead.' @@ -1882,8 +1882,8 @@ def _calcTNLS(self): Calculates the three note linear segments if only three Verticalities provided. ''' for partNum in range(min(len(self.verticalities[0].getObjectsByClass(note.Note)), - len(self.verticalities[1].getObjectsByClass(note.Note)), - len(self.verticalities[2].getObjectsByClass(note.Note))) + len(self.verticalities[1].getObjectsByClass(note.Note)), + len(self.verticalities[2].getObjectsByClass(note.Note))) ): self.tnlsDict[partNum] = ThreeNoteLinearSegment( [ @@ -2339,10 +2339,10 @@ def couldBeDiatonicNeighborTone(self) -> bool: ''' return (self._isComplete() - and self.n1.nameWithOctave == self.n3.nameWithOctave - and self.iLeft.chromatic.undirected == 2 - and self.iRight.chromatic.undirected == 2 - and self.iLeft.direction * self.iRight.direction == -1) + and self.n1.nameWithOctave == self.n3.nameWithOctave + and self.iLeft.chromatic.undirected == 2 + and self.iRight.chromatic.undirected == 2 + and self.iLeft.direction * self.iRight.direction == -1) def couldBeChromaticNeighborTone(self) -> bool: @@ -2360,10 +2360,10 @@ def couldBeChromaticNeighborTone(self) -> bool: False ''' return (self._isComplete() - and (self.n1.nameWithOctave == self.n3.nameWithOctave - and self.iLeft.isChromaticStep - and self.iRight.isChromaticStep - and (self.iLeft.direction * self.iRight.direction == -1))) + and (self.n1.nameWithOctave == self.n3.nameWithOctave + and self.iLeft.isChromaticStep + and self.iRight.isChromaticStep + and (self.iLeft.direction * self.iRight.direction == -1))) # Below: beginnings of an implementation for any object segments, diff --git a/music21/volpiano.py b/music21/volpiano.py index 58f8b30e95..2c12459ee6 100644 --- a/music21/volpiano.py +++ b/music21/volpiano.py @@ -392,8 +392,8 @@ def setAccFromPitch(dist, setNatural=False): continue if n.notehead == 'x' or (n.hasEditorialInformation - and 'liquescence' in n.editorial - and n.editorial.liquescence): + and 'liquescence' in n.editorial + and n.editorial.liquescence): tokenName = liquescentPitches[indexInPitchString] else: tokenName = normalPitches[indexInPitchString] From c064d120c7aa8f23b6caa67f4bda73cd95247dde Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:20:05 -1000 Subject: [PATCH 3/9] Hang the abcFormat articulation tuple off its own line Aligned to the opening bracket, the tuple of articulation strings started at column 46 and every row after the first was mostly leading whitespace. Break after the paren instead and indent the strings one step, closing on its own line. Also restores repeat.py's continuation fix, lost when the file was reverted. AI-assisted (Claude) --- music21/abcFormat/__init__.py | 16 +++++++++------- music21/repeat.py | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/music21/abcFormat/__init__.py b/music21/abcFormat/__init__.py index 9c52a79554..b84ec42818 100644 --- a/music21/abcFormat/__init__.py +++ b/music21/abcFormat/__init__.py @@ -2505,13 +2505,15 @@ def tokenize(self, strSrc: str) -> None: # v is up bow; might be: "^Segno"v which also should be dropped # H is fermata # . dot may be staccato, but should be attached to pitch - if self.currentCollectStr in ('w', 'u', 'v', 'v.', 'h', 'H', 'vk', - 'uk', 'U', '~', - '.', '=', 'V', 'v.', 'S', 's', - 'i', 'I', 'ui', 'u.', 'Q', 'Hy', 'Hx', - 'r', 'm', 'M', 'n', 'N', 'o', 'O', 'P', - 'l', 'L', 'R', - 'y', 'T', 't', 'x', 'Z'): + if self.currentCollectStr in ( + 'w', 'u', 'v', 'v.', 'h', 'H', 'vk', + 'uk', 'U', '~', + '.', '=', 'V', 'v.', 'S', 's', + 'i', 'I', 'ui', 'u.', 'Q', 'Hy', 'Hx', + 'r', 'm', 'M', 'n', 'N', 'o', 'O', 'P', + 'l', 'L', 'R', + 'y', 'T', 't', 'x', 'Z', + ): pass # these are bad chords, or other problematic notations like # "D.C."x diff --git a/music21/repeat.py b/music21/repeat.py index b136311504..4ba93d5b6b 100644 --- a/music21/repeat.py +++ b/music21/repeat.py @@ -2214,7 +2214,7 @@ def _getSimilarMeasuresHelper(self, measures, source, compare, resDict, useDict) # we have a repeated section at least 2 measures in length; # check to see how far it goes nextOne = self._getSimilarMeasuresHelper(measures, source + 1, compare + 1, - resDict, useDict) + resDict, useDict) # make sure we don't have overlap res = ([source], [compare]) res[0].extend(nextOne[0]) From 8353a29dd0fd65ab5c3f1a7b22d661331cc26c2b Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:23:54 -1000 Subject: [PATCH 4/9] Align shorthandNotation's entries with its first one Every entry after `(None,)` sat at column 21, aligned to nothing -- the dict opens with a hanging indent, so pycodestyle's E12 checks accept whatever the rows do as long as the first one is indented. AI-assisted (Claude) --- music21/figuredBass/notation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/music21/figuredBass/notation.py b/music21/figuredBass/notation.py index 99681cc1ac..563b24c2a2 100644 --- a/music21/figuredBass/notation.py +++ b/music21/figuredBass/notation.py @@ -25,16 +25,16 @@ shorthandNotation: dict[tuple[int|None, ...], tuple[int, ...]] = { (None,): (5, 3), - (5,): (5, 3), - (6,): (6, 3), - (7,): (7, 5, 3), - (9,): (9, 7, 5, 3), - (11,): (11, 9, 7, 5, 3), - (13,): (13, 11, 9, 7, 5, 3), - (6, 5): (6, 5, 3), - (4, 3): (6, 4, 3), - (4, 2): (6, 4, 2), - (2,): (6, 4, 2), + (5,): (5, 3), + (6,): (6, 3), + (7,): (7, 5, 3), + (9,): (9, 7, 5, 3), + (11,): (11, 9, 7, 5, 3), + (13,): (13, 11, 9, 7, 5, 3), + (6, 5): (6, 5, 3), + (4, 3): (6, 4, 3), + (4, 2): (6, 4, 2), + (2,): (6, 4, 2), } prefixes = ['+', '#', '++', '##'] From cfa8de976312dd55074411a822bb32902e235e8d Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:25:52 -1000 Subject: [PATCH 5/9] Hang testWindowed's assertEqual off its own line Aligning to the opening bracket pushed the expected legend out to column 25 and its rows past that. Break after `assertEqual(` so both arguments sit one step in, which is where the list was before. AI-assisted (Claude) --- music21/graph/plot.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/music21/graph/plot.py b/music21/graph/plot.py index a83d8e583b..0584280628 100644 --- a/music21/graph/plot.py +++ b/music21/graph/plot.py @@ -1791,20 +1791,21 @@ def testWindowed(self, doneAction=None): minWindow=1, windowStep=windowStep, doneAction=doneAction, dpi=300) b.run() - self.assertEqual(b.graphLegend.data, - [ - ['Major', - [('C#', '#f0727a'), ('D', '#ffd752'), ('E', '#eeff9a'), - ('F#', '#b9f0ff'), ('A', '#bb9aff'), ('B', '#ffb5ff') - ] - ], - ['Minor', - [('c#', '#8c0e16'), ('', '#ffffff'), ('', '#ffffff'), - ('f#', '#558caa'), ('', '#ffffff'), ('b', '#9b519b') - ] - ] - ] - ) + self.assertEqual( + b.graphLegend.data, + [ + ['Major', + [('C#', '#f0727a'), ('D', '#ffd752'), ('E', '#eeff9a'), + ('F#', '#b9f0ff'), ('A', '#bb9aff'), ('B', '#ffb5ff') + ] + ], + ['Minor', + [('c#', '#8c0e16'), ('', '#ffffff'), ('', '#ffffff'), + ('f#', '#558caa'), ('', '#ffffff'), ('b', '#9b519b') + ] + ] + ] + ) def testFeatures(self): streamList = ['bach/bwv66.6', 'schoenberg/opus19/movement2', 'corelli/opus3no1/1grave'] From ca3d76093dbc961eab43bec78b558ca7e5ee715d Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:30:16 -1000 Subject: [PATCH 6/9] Bring stray continuation rows back onto their siblings' column 'sound' in partStaffExporter's tagList sat eight columns right of the other four tags. Five multi-line `if` conditions had the same drift in a different form: the first `and` at the opening paren's column, the next one four further in, so neither row lined up with anything. Put every row of each on one column -- the +8 the rest of the codebase uses for a wrapped condition. pycodestyle's E12 checks pass either way; they accept several alternative indents once brackets nest, and only look at a row in isolation. AI-assisted (Claude) --- music21/interval.py | 2 +- music21/musicxml/partStaffExporter.py | 4 ++-- music21/musicxml/xmlToM21.py | 2 +- music21/stream/base.py | 2 +- music21/test/testRunner.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/music21/interval.py b/music21/interval.py index 3dde7bc268..2390cdaa1b 100644 --- a/music21/interval.py +++ b/music21/interval.py @@ -1736,7 +1736,7 @@ def __eq__(self, other): # if self.direction != other.direction: # return False if (self.generic == other.generic - and self.specifier == other.specifier + and self.specifier == other.specifier and self.direction == other.direction): return True else: diff --git a/music21/musicxml/partStaffExporter.py b/music21/musicxml/partStaffExporter.py index 00e51acd6f..3cce7b8b34 100644 --- a/music21/musicxml/partStaffExporter.py +++ b/music21/musicxml/partStaffExporter.py @@ -86,7 +86,7 @@ def addStaffTags( mxStaff.text = str(staffNumber) helpers.insertBeforeElements(tag, mxStaff, tagList=['beam', 'notations', 'lyric', 'play', - 'sound']) + 'sound']) class PartStaffExporterMixin: @@ -423,7 +423,7 @@ def makeDivider(inner_sourceNumber: int|str) -> Element[t.Any]: # Or, gap in measure numbers in the subsequent part: keep iterating through target if (sourceNumber is not None - and targetNumber is not None + and targetNumber is not None and helpers.measureNumberComesBefore(targetNumber, sourceNumber)): continue # sourceMeasure is not None! diff --git a/music21/musicxml/xmlToM21.py b/music21/musicxml/xmlToM21.py index ba4089cdbd..df091660f3 100644 --- a/music21/musicxml/xmlToM21.py +++ b/music21/musicxml/xmlToM21.py @@ -2245,7 +2245,7 @@ def adjustTimeAttributesFromMeasure(self, m: stream.Measure): # If the measure is overfull by a "round" amount, assume that it was intended # otherwise it was likely the result of malformed MusicXML. if (diff > 0.5 - or nearestMultiple(diff, 0.0625)[1] < tol + or nearestMultiple(diff, 0.0625)[1] < tol or nearestMultiple(diff, 1 / 12)[1] < tol): mOffsetShift = mHighestTime else: diff --git a/music21/stream/base.py b/music21/stream/base.py index f5f0036add..d9c9190151 100644 --- a/music21/stream/base.py +++ b/music21/stream/base.py @@ -5810,7 +5810,7 @@ def getInstruments(self, if searchActiveSite: # if isinstance(self.activeSite, Stream) and self.activeSite != self: if (self.activeSite is not None - and self.activeSite.isStream + and self.activeSite.isStream and self.activeSite is not self): # environLocal.printDebug(['searching activeSite Stream', # self, self.activeSite]) diff --git a/music21/test/testRunner.py b/music21/test/testRunner.py index f5539daab8..190256e017 100644 --- a/music21/test/testRunner.py +++ b/music21/test/testRunner.py @@ -253,7 +253,7 @@ def testHello(self): # search all names for case-insensitive match for name in dir(tObj): if (name.lower() == runThisTest.lower() - or name.lower() == ('test' + runThisTest.lower()) + or name.lower() == ('test' + runThisTest.lower()) or name.lower() == ('xtest' + runThisTest.lower())): runThisTest = name break From e510d5430dc4809a177a869f1c3dd421f507fba7 Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:31:13 -1000 Subject: [PATCH 7/9] Drop searchStream onto its own line in Spanner.fill Aligned to the opening paren, the method chain started at column 25 and its arguments ran out past 29. Break after the paren so the whole chain sits one step in, which is the spacing it had. AI-assisted (Claude) --- music21/spanner.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/music21/spanner.py b/music21/spanner.py index c4e035f3c4..c12c6aab66 100644 --- a/music21/spanner.py +++ b/music21/spanner.py @@ -697,17 +697,18 @@ def fill( else: endOffsetInHierarchy = opFrac(startOffsetInHierarchy + startElement.quarterLength) - matchIterator = (searchStream - .recurse() - .getElementsByOffsetInHierarchy( - startOffsetInHierarchy, - endOffsetInHierarchy, - includeEndBoundary=includeEndBoundary, - mustFinishInSpan=mustFinishInSpan, - mustBeginInSpan=mustBeginInSpan, - includeElementsThatEndAtStart=includeElementsThatEndAtStart) - .getElementsByClass(self.fillElementTypes) - ) + matchIterator = ( + searchStream + .recurse() + .getElementsByOffsetInHierarchy( + startOffsetInHierarchy, + endOffsetInHierarchy, + includeEndBoundary=includeEndBoundary, + mustFinishInSpan=mustFinishInSpan, + mustBeginInSpan=mustBeginInSpan, + includeElementsThatEndAtStart=includeElementsThatEndAtStart) + .getElementsByClass(self.fillElementTypes) + ) for foundElement in matchIterator: if foundElement is startElement: From bb911da4eb7f93038257fe0d8bb962f1bcb7ade3 Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:36:59 -1000 Subject: [PATCH 8/9] Drop the first argument down where the visual indent ran deep Aligning to the opening bracket only pays when there is room to the right of it. scala's two cents assertions were aligned at column 73, leaving eight characters of usable width; variant's getElementsByOffset calls at 49-61. Break after the paren in those, so the arguments start one step in. Covers every call in the branch whose visual indent passed 40, plus the two stream/tests assertions and testMakeRestsB. variant's eight getElementsByOffset calls now share one shape, one argument per row. AI-assisted (Claude) --- music21/scale/intervalNetwork.py | 18 ++++---- music21/scale/scala/__init__.py | 54 ++++++++++++----------- music21/stream/tests.py | 45 +++++++++++--------- music21/variant.py | 73 ++++++++++++++++++-------------- 4 files changed, 104 insertions(+), 86 deletions(-) diff --git a/music21/scale/intervalNetwork.py b/music21/scale/intervalNetwork.py index db91d356bc..384b181a55 100644 --- a/music21/scale/intervalNetwork.py +++ b/music21/scale/intervalNetwork.py @@ -1401,10 +1401,11 @@ def nextPitch( p = self.transposePitchAndApplySimplification(intervalObj, p) else: p = self.transposePitchAndApplySimplification(intervalObj.reverse(), p) - pCollect = self.processAlteredNodes(alteredDegrees=alteredDegrees, - n=n, - p=p, - direction=direction) + pCollect = self.processAlteredNodes( + alteredDegrees=alteredDegrees, + n=n, + p=p, + direction=direction) return pCollect @@ -1587,10 +1588,11 @@ def realizeAscending( p = self.transposePitchAndApplySimplification(intervalObj, p) pCollect = p - pCollect = self.processAlteredNodes(alteredDegrees=alteredDegrees, - n=n, - p=p, - direction=Direction.ASCENDING) + pCollect = self.processAlteredNodes( + alteredDegrees=alteredDegrees, + n=n, + p=p, + direction=Direction.ASCENDING) if attempts >= maxAttempts: raise IntervalNetworkException( diff --git a/music21/scale/scala/__init__.py b/music21/scale/scala/__init__.py index 221473e185..f161224540 100644 --- a/music21/scale/scala/__init__.py +++ b/music21/scale/scala/__init__.py @@ -648,31 +648,35 @@ def testScalaScaleB(self) -> None: self.assertEqual(ss.description, 'Franck Jedrzejewski continued fractions approx. of 12-tet') - self.assertEqual([f'{x:.9f}' for x in ss.getCentsAboveTonic()], ['100.099209825', - '199.979843291', - '299.973903610', - '400.108480470', - '498.044999135', - '600.088323762', - '699.997698171', - '800.909593096', - '900.026096390', - '1000.020156709', - '1088.268714730', - '1200.000000000']) - - self.assertEqual([f'{x:.9f}' for x in ss.getAdjacentCents()], ['100.099209825', - '99.880633466', - '99.994060319', - '100.134576860', - '97.936518664', - '102.043324627', - '99.909374409', - '100.911894925', - '99.116503294', - '99.994060319', - '88.248558022', - '111.731285270']) + self.assertEqual( + [f'{x:.9f}' for x in ss.getCentsAboveTonic()], + ['100.099209825', + '199.979843291', + '299.973903610', + '400.108480470', + '498.044999135', + '600.088323762', + '699.997698171', + '800.909593096', + '900.026096390', + '1000.020156709', + '1088.268714730', + '1200.000000000']) + + self.assertEqual( + [f'{x:.9f}' for x in ss.getAdjacentCents()], + ['100.099209825', + '99.880633466', + '99.994060319', + '100.134576860', + '97.936518664', + '102.043324627', + '99.909374409', + '100.911894925', + '99.116503294', + '99.994060319', + '88.248558022', + '111.731285270']) self.assertEqual([str(x) for x in ss.getIntervalSequence()], ['', diff --git a/music21/stream/tests.py b/music21/stream/tests.py index 8006c018fa..6e49f36179 100644 --- a/music21/stream/tests.py +++ b/music21/stream/tests.py @@ -1045,18 +1045,19 @@ def testFindConsecutiveNotes(self): consec = m.findConsecutiveNotes() - self.assertEqual([repr(x) for x in consec], - ['', - '', - '', - '', - 'None', - '', - '', - '', - '', - ] - ) + self.assertEqual( + [repr(x) for x in consec], + ['', + '', + '', + '', + 'None', + '', + '', + '', + '', + ] + ) # with voices in each of two measures m.insert(meter.TimeSignature('2/4')) @@ -1355,14 +1356,15 @@ def testStripTiesClearBeaming(self): self.assertEqual(p.streamStatus.beams, False) p = p.splitAtDurations(recurse=True)[0] p.makeBeams(inPlace=True) - self.assertEqual([repr(el.beams) for el in p[note.Note]], - ['', - '>', - '>', - '>', - '>' - ] - ) + self.assertEqual( + [repr(el.beams) for el in p[note.Note]], + ['', + '>', + '>', + '>', + '>' + ] + ) def testStripTiesStopTieChordFollowsRest(self): ''' @@ -2219,7 +2221,8 @@ def testMakeRestsB(self): # m2.show() match = str(list(s.flatten().notesAndRests)) - self.assertEqual(match, '[, , ' + self.assertEqual(match, + '[, , ' + ', , ' + ', ]') match = str([(n, n.duration) for n in s.flatten().notesAndRests]) diff --git a/music21/variant.py b/music21/variant.py index 8c30a75b76..77f997c8cf 100644 --- a/music21/variant.py +++ b/music21/variant.py @@ -469,11 +469,13 @@ def replacedElements(self, contextStream=None, classList=None, classes.append(e.classes[0]) if classList is not None: classes.extend(classList) - returnStream = contextStream.getElementsByOffset(vStart, vEnd, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=classes).stream() + returnStream = contextStream.getElementsByOffset( + vStart, + vEnd, + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=classes).stream() elif self.lengthType == 'deletion': vMiddle = vStart + self.containedHighestTime @@ -483,15 +485,19 @@ def replacedElements(self, contextStream=None, classList=None, classes.append(e.classes[0]) if classList is not None: classes.extend(classList) - returnPart1 = contextStream.getElementsByOffset(vStart, vMiddle, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=classes).stream() - returnPart2 = contextStream.getElementsByOffset(vMiddle, vEnd, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True).stream() + returnPart1 = contextStream.getElementsByOffset( + vStart, + vMiddle, + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=classes).stream() + returnPart2 = contextStream.getElementsByOffset( + vMiddle, + vEnd, + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True).stream() returnStream = returnPart1 for e in returnPart2.elements: @@ -2426,23 +2432,25 @@ def _getNextElements(s, v, numberOfElements=1): # Get next element in s after v which is of type vClass if lengthType == 'elongation': variantOffset = v.getOffsetBySite(s) - potentialTargets = s.getElementsByOffset(variantOffset, - offsetEnd=s.highestTime, - includeEndBoundary=True, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=[vClass]) + potentialTargets = s.getElementsByOffset( + variantOffset, + offsetEnd=s.highestTime, + includeEndBoundary=True, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=[vClass]) returnElement = potentialTargets.first() else: replacementDuration = v.replacementQuarterLength variantOffset = v.getOffsetBySite(s) - potentialTargets = s.getElementsByOffset(variantOffset + replacementDuration, - offsetEnd=s.highestTime, - includeEndBoundary=True, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=[vClass]) + potentialTargets = s.getElementsByOffset( + variantOffset + replacementDuration, + offsetEnd=s.highestTime, + includeEndBoundary=True, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=[vClass]) returnElement = potentialTargets.first() @@ -2528,12 +2536,13 @@ def makeVariantBlocks(s): for v in variantsToBeDone: startOffset = s.elementOffset(v) endOffset = v.replacementQuarterLength + startOffset - conflictingVariants = s.getElementsByOffset(offsetStart=startOffset, - offsetEnd=endOffset, - includeEndBoundary=False, - mustFinishInSpan=False, - mustBeginInSpan=True, - classList=[Variant]) + conflictingVariants = s.getElementsByOffset( + offsetStart=startOffset, + offsetEnd=endOffset, + includeEndBoundary=False, + mustFinishInSpan=False, + mustBeginInSpan=True, + classList=[Variant]) for cV in conflictingVariants: oldReplacementDuration = cV.replacementQuarterLength if s.elementOffset(cV) == startOffset: From 866fe6c3a9cc06aa55de42aac8fc530ceffb136f Mon Sep 17 00:00:00 2001 From: Michael Scott Asato Cuthbert Date: Fri, 28 Aug 2026 13:40:17 -1000 Subject: [PATCH 9/9] running-tests: name multiprocessTest as the one to reach for Both runners were listed as equals, with testSingleCoreAll marked "use before pushing to a PR" -- so it got run routinely, at 45 seconds against multiprocessTest's 10. That is a long time to leave someone waiting for an answer the parallel runner gives just as well. Says which one to use and confines the single-core runner to what it alone can tell you: a release check, a CI failure that will not reproduce, one core. AI-assisted (Claude) --- .agents/skills/running-tests/SKILL.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.agents/skills/running-tests/SKILL.md b/.agents/skills/running-tests/SKILL.md index 92601b045a..dc1538c1c3 100644 --- a/.agents/skills/running-tests/SKILL.md +++ b/.agents/skills/running-tests/SKILL.md @@ -75,17 +75,25 @@ pytest is for a module. For the whole suite use the runners, and note that a green pytest run does not mean CI will be green -- they gather and order modules differently. +Use `multiprocessTest` -- it runs on n-1 cores and finishes in about 10 seconds, +against roughly 45 for the single-core runner: + ```bash -# everyday full run, on n-1 cores uv run python music21/test/multiprocessTest.py +``` -# exactly what GitHub Actions runs (~1 minute); use before pushing to a PR +That gap is the whole story when someone is waiting on the answer. Reach for +`testSingleCoreAll` only for what `multiprocessTest` cannot tell you: it is what +GitHub Actions runs, so it is the one to check before a release, when chasing a +CI failure that will not reproduce, or on a single-core machine. + +```bash uv run python -c 'from music21.test.testSingleCoreAll import ciMain as ci; ci()' ``` The two runners see slightly different sets of modules -- `multiprocessTest` walks the package tree for modules reachable from `import music21`, while -`testSingleCoreAll` gathers module files from disk. Run both before a release. +`testSingleCoreAll` gathers module files from disk. Module **order** differs between the two runners and again from pytest. `multiprocessTest` goes in reverse-alphabetical order (with the known-slow