nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cuthbertLab/music21
Pull request #1193 (2022-01-10 18:17:04)

Respect Accidental.displayType option 'never'
Portion of #1148 to get this small piece in faster.


Patch:
diff --git a/.gitignore b/.gitignore
index d1c020241..86eccc1d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,6 +62,7 @@ nosetests.xml
 
 # VS Code
 /.vscode
+*.code-workspace
 
 # remove all from autogenerated except conf.py
 documentation/autogenerated/**/*
diff --git a/music21/pitch.py b/music21/pitch.py
index 3cf5f684e..f0025d421 100644
--- a/music21/pitch.py
+++ b/music21/pitch.py
@@ -4659,6 +4659,10 @@ class Pitch(prebase.ProtoM21Object):
             elif self.accidental.displayStatus in (True, False):
                 return  # exit: already set, do not override
 
+        if self.accidental is not None and self.accidental.displayType == 'never':
+            self.accidental.displayStatus = False
+            return
+
         if lastNoteWasTied is True:
             if self.accidental is not None:
                 if self.accidental.displayType != 'even-tied':


Test patch:
diff --git a/music21/stream/tests.py b/music21/stream/tests.py
index a7a99ad10..7030a64b5 100644
--- a/music21/stream/tests.py
+++ b/music21/stream/tests.py
@@ -2807,6 +2807,16 @@ class Test(unittest.TestCase):
                              '%s failed, %s != %s' %
                                 (i, allNotes[i].pitch.accidental.displayStatus, ds[i]))
 
+    def testMakeAccidentalsRespectsDisplayType(self):
+        n = note.Note('D#')
+        n.pitch.accidental.displayType = 'never'
+        s = Stream(n)
+        self.assertIsNone(n.pitch.accidental.displayStatus)
+        s.makeAccidentals(inPlace=True)
+        self.assertIs(n.pitch.accidental.displayStatus, False)
+
+        # TODO: other types
+
     def testMakeNotationTiesKeyless(self):
         from music21 import converter
         p = converter.parse('tinynotation: 4/4 f#1~ f#1')
Repository: cuthbertLab/music21
Pull request #1521 (2023-01-30 07:44:02)

Tiny change to make .accidental
Make p.accidental = 2 a bit faster.


Patch:
diff --git a/music21/pitch.py b/music21/pitch.py
index 100dde4d1..b707c86ac 100644
--- a/music21/pitch.py
+++ b/music21/pitch.py
@@ -1253,7 +1253,6 @@ class Accidental(prebase.ProtoM21Object, style.StyleMixin):
 
         This is needed when transposing Pitches: we need to retain accidental display properties.
 
-
         >>> a = pitch.Accidental('double-flat')
         >>> a.displayType = 'always'
         >>> b = pitch.Accidental('sharp')
@@ -2103,7 +2102,10 @@ class Pitch(prebase.ProtoM21Object):
         elif isinstance(value, str):
             # int version is used in interval.py which cannot import Pitch directly
             self._accidental = Accidental(value)
-        elif isinstance(value, (int, float)):
+        elif isinstance(value, int):
+            self._accidental = Accidental(value)
+            self._microtone = None
+        elif isinstance(value, float):
             # check and add any microtones
             alter, cents = _convertCentsToAlterAndCents(value * 100.0)
             self._accidental = Accidental(alter)
@@ -3937,7 +3939,7 @@ class Pitch(prebase.ProtoM21Object):
 
         >>> p4.getHigherEnharmonic()
         Traceback (most recent call last):
-        music21.pitch.AccidentalException: -5.0 is not a supported accidental type
+        music21.pitch.AccidentalException: -5 is not a supported accidental type
 
         Note that half accidentals (~ = half-sharp, ` = half-flat)
         get converted to microtones:


Test patch:
diff --git a/music21/test/test_interval.py b/music21/test/test_interval.py
index d222181f7..da17bb5b3 100644
--- a/music21/test/test_interval.py
+++ b/music21/test/test_interval.py
@@ -393,7 +393,7 @@ class Test(unittest.TestCase):
              ]
         )
         with self.assertRaisesRegex(pitch.AccidentalException,
-                                    '5.0 is not a supported accidental type'):
+                                    '5 is not a supported accidental type'):
             intv.transposePitch(p, maxAccidental=None)
         p2 = intv.transposePitch(p)
         self.assertEqual(p2.nameWithOctave, 'B-20')