Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
TimFelixBeyer committed Jul 25, 2023
1 parent 2b4cf5d commit 1bc59ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions music21/musicxml/test_xmlToM21.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,9 +1504,9 @@ def testImportImplicitMeasureNumber(self):
m = s[stream.Measure].first()
self.assertIs(m.showNumber, stream.enums.ShowNumber.NEVER)

def testAdjustTimeAttributesFromMeasure(self):
def testAdjustTimeAttributesFromMeasure(self):
# Ignore import artifacts:
d = duration.Duration(3 + 3/480)
d = duration.Duration(3 + 3 / 480)
m = stream.Measure([meter.TimeSignature('6/8'), note.Note(duration=d)])
PP = PartParser()
PP.lastMeasureOffset = 21.0
Expand All @@ -1533,6 +1533,7 @@ def testAdjustTimeAttributesFromMeasure(self):
PP.adjustTimeAttributesFromMeasure(m)
self.assertEqual(PP.lastMeasureOffset, 25.0)


if __name__ == '__main__':
import music21
music21.mainTest(Test)
14 changes: 8 additions & 6 deletions music21/musicxml/xmlToM21.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,15 +2198,17 @@ def adjustTimeAttributesFromMeasure(self, m: stream.Measure):
tol = 1e-6
# 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, opFrac(1/12))[1] < tol):
if (diff > 0.5
or nearestMultiple(diff, 0.0625)[1] < tol
or nearestMultiple(diff, opFrac(1 / 12))[1] < tol):
mOffsetShift = mHighestTime
else:
mOffsetShift = lastTimeSignatureQuarterLength
warnings.warn(f"""Warning: measure {m.number} in part {self.stream.partName}
is overfull: {mHighestTime} > {lastTimeSignatureQuarterLength},
assuming {mOffsetShift} is correct.""")
warnings.warn(
f"Warning: measure {m.number} in part {self.stream.partName}"
f"is overfull: {mHighestTime} > {lastTimeSignatureQuarterLength},"
f"assuming {mOffsetShift} is correct."
)
elif (mHighestTime == 0.0
and not m.recurse().notesAndRests.getElementsNotOfClass('Harmony')
):
Expand Down

0 comments on commit 1bc59ab

Please sign in to comment.