Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations; opFrac speedup #1278

Merged
merged 10 commits into from
Apr 25, 2022
3 changes: 3 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions documentation/nbvalNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import sys
import subprocess
# noinspection PyPackageRequirements
import pytest # @UnusedImport # pylint: disable=unused-import,import-error
import pytest # pylint: disable=unused-import,import-error
# noinspection PyPackageRequirements
import nbval # @UnusedImport # pylint: disable=unused-import,import-error
import nbval # pylint: disable=unused-import,import-error

from music21 import environment
from music21 import common
Expand Down
2 changes: 1 addition & 1 deletion documentation/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
project = 'music21'
# pylint: disable=redefined-builtin
# noinspection PyShadowingBuiltins
copyright = '2006-2021, Michael Scott Cuthbert and cuthbertLab' # @ReservedAssignment
copyright = '2006-2021, Michael Scott Cuthbert and cuthbertLab'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
6 changes: 3 additions & 3 deletions music21/alpha/analysis/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def fix(self):
for (midiRef, omrRef, op) in self.changes:
if self.checkIfNoteInstance(midiRef, omrRef) is False:
continue
# if the are the same, don't bother to try changing it
# if they are the same, don't bother to try changing it
# 3 is the number of noChange Ops
if isinstance(op, aligner.ChangeOps) and op == aligner.ChangeOps.NoChange:
continue
Expand Down Expand Up @@ -246,7 +246,7 @@ def fix(self):
# if they're not notes, don't bother with rest
if self.checkIfNoteInstance(midiRef, omrRef) is False:
continue
# if the are the same, don't bother to try changing it
# if they are the same, don't bother to try changing it
# 3 is the number of noChange Ops
if isinstance(op, aligner.ChangeOps) and op == aligner.ChangeOps.NoChange:
continue
Expand Down Expand Up @@ -394,7 +394,7 @@ def addOrnament(self,

def fix(self: _T, *, show=False, inPlace=True) -> Optional[_T]:
'''
Corrects missed ornaments in omr stream according to mid stream
Corrects missed ornaments in omrStream according to midiStream
:param show: Whether to show results
:param inPlace: Whether to make changes to own omr stream or
return a new OrnamentFixer with changes
Expand Down
73 changes: 36 additions & 37 deletions music21/analysis/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from music21 import exceptions21

from music21 import chord
from music21 import clef
from music21 import common
from music21 import expressions
from music21 import instrument
Expand Down Expand Up @@ -952,42 +951,42 @@ def testExtractionB(self):
self.assertEqual(len(match), 3)
# post.show()

def testExtractionC(self):
from music21 import analysis
from music21 import corpus
# http://solomonsmusic.net/schenker.htm
# shows extracting an Ursatz line

# BACH pre;ide !, WTC

src = corpus.parse('bwv846')
import warnings
with warnings.catch_warnings(): # catch deprecation warning
warnings.simplefilter('ignore', category=exceptions21.Music21DeprecationWarning)
chords = src.flattenParts().makeChords(minimumWindowSize=4,
makeRests=False)
for c in chords.flatten().notes:
c.quarterLength = 4
for m in chords.getElementsByClass('Measure'):
m.clef = clef.bestClef(m, recurse=True)

chords.measure(1).notes[0].addLyric('::/p:e/o:5/nf:no/ta:3/g:Ursatz')
chords.measure(1).notes[0].addLyric('::/p:c/o:4/nf:no/tb:I')

chords.measure(24).notes[0].addLyric('::/p:d/o:5/nf:no/ta:2')
chords.measure(24).notes[0].addLyric('::/p:g/o:3/nf:no/tb:V')

chords.measure(30).notes[0].addLyric('::/p:f/o:4/tb:7')

chords.measure(34).notes[0].addLyric('::/p:c/o:5/nf:no/v:1/ta:1')
chords.measure(34).notes[0].addLyric('::/p:g/o:4/nf:no/v:2')
chords.measure(34).notes[0].addLyric('::/p:c/o:4/nf:no/v:1/tb:I')

sr = analysis.reduction.ScoreReduction()
sr.chordReduction = chords
# sr.score = src
unused_post = sr.reduce()
# unused_post.show()
# def testExtractionC(self):
# from music21 import analysis
# from music21 import corpus
# # http://solomonsmusic.net/schenker.htm
# # shows extracting an Ursatz line
#
# # BACH pre;ide !, WTC
#
# src = corpus.parse('bwv846')
# import warnings
# with warnings.catch_warnings(): # catch deprecation warning
# warnings.simplefilter('ignore', category=exceptions21.Music21DeprecationWarning)
# chords = src.flattenParts().makeChords(minimumWindowSize=4,
# makeRests=False)
# for c in chords.flatten().notes:
# c.quarterLength = 4
# for m in chords.getElementsByClass('Measure'):
# m.clef = clef.bestClef(m, recurse=True)
#
# chords.measure(1).notes[0].addLyric('::/p:e/o:5/nf:no/ta:3/g:Ursatz')
# chords.measure(1).notes[0].addLyric('::/p:c/o:4/nf:no/tb:I')
#
# chords.measure(24).notes[0].addLyric('::/p:d/o:5/nf:no/ta:2')
# chords.measure(24).notes[0].addLyric('::/p:g/o:3/nf:no/tb:V')
#
# chords.measure(30).notes[0].addLyric('::/p:f/o:4/tb:7')
#
# chords.measure(34).notes[0].addLyric('::/p:c/o:5/nf:no/v:1/ta:1')
# chords.measure(34).notes[0].addLyric('::/p:g/o:4/nf:no/v:2')
# chords.measure(34).notes[0].addLyric('::/p:c/o:4/nf:no/v:1/tb:I')
#
# sr = analysis.reduction.ScoreReduction()
# sr.chordReduction = chords
# # sr.score = src
# unused_post = sr.reduce()
# # unused_post.show()


def testExtractionD(self):
Expand Down
2 changes: 1 addition & 1 deletion music21/audioSearch/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def samplesFromRecording(seconds=10.0, storeFile=True,
Returns a list of samples.
'''
# noinspection PyPackageRequirements
import pyaudio # @UnresolvedImport # pylint: disable=import-error
import pyaudio # pylint: disable=import-error
recordFormatDefault = pyaudio.paInt16

if recordFormat is None:
Expand Down
2 changes: 1 addition & 1 deletion music21/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Barline(base.Music21Object):
classSortOrder = -5

def __init__(self,
type=None, # @ReservedAssignment # pylint: disable=redefined-builtin
type=None, # pylint: disable=redefined-builtin
location=None):
super().__init__()

Expand Down
45 changes: 0 additions & 45 deletions music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,6 @@ def getOffsetBySite(
site: 'music21.stream.Stream',
*,
returnSpecial=False,
stringReturns=False,
) -> Union[float, fractions.Fraction, str]:
'''
If this class has been registered in a container such as a Stream,
Expand Down Expand Up @@ -913,10 +912,6 @@ def getOffsetBySite(

Changed in v7. -- stringReturns renamed to returnSpecial. Returns an OffsetSpecial Enum.
'''
if stringReturns and not returnSpecial: # pragma: no cover
returnSpecial = stringReturns
environLocal.warn('stringReturns is deprecated: use returnSpecial instead')

if site is None:
return self._naiveOffset

Expand Down Expand Up @@ -4019,48 +4014,8 @@ def __getattr__(self, name: str) -> Any:
raise AttributeError(f'Could not get attribute {name!r} in an object-less element')
return object.__getattribute__(storedObj, name)

def isTwin(self, other: 'ElementWrapper') -> bool:
'''
DEPRECATED: Just run::

(wrapper1.obj == wrapper2.obj)

A weaker form of equality. a.isTwin(b) is true if
a and b store either the same object OR objects that are equal.
In other words, it is essentially the same object in a different context

>>> import copy
>>> import music21

>>> aE = music21.ElementWrapper(obj='hello')

>>> bE = copy.copy(aE)
>>> aE is bE
False
>>> aE == bE
True
>>> aE.isTwin(bE)
True

>>> bE.offset = 14.0
>>> bE.priority = -4
>>> aE == bE
False
>>> aE.isTwin(bE)
True
'''
if not hasattr(other, 'obj'):
return False

if self.obj is other.obj or self.obj == other.obj:
return True
else:
return False


# -----------------------------------------------------------------------------


class TestMock(Music21Object):
pass

Expand Down
87 changes: 44 additions & 43 deletions music21/braille/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
New International Manual of Braille Music Notation (by Bettye Krolick), which we will cite as
"Krolick" or "krolick".
'''

from typing import Dict, Union
import itertools

_DOC_IGNORE_MODULE_OR_PACKAGE = True
Expand Down Expand Up @@ -280,48 +280,49 @@ def makePitchNameToNotes():
'decresc.': _B[345] + _B[145] + _B[15] + _B[14] + _B[1235] + _B[3],
'decr.': _B[345] + _B[145] + _B[15] + _B[14] + _B[1235] + _B[3]}

alphabet = {'a': _B[1],
'b': _B[12],
'c': _B[14],
'd': _B[145],
'e': _B[15],
'f': _B[124],
'g': _B[1245],
'h': _B[125],
'i': _B[24],
'j': _B[245],
'k': _B[13],
'l': _B[123],
'm': _B[134],
'n': _B[1345],
'o': _B[135],
'p': _B[1234],
'q': _B[12345],
'r': _B[1235],
's': _B[234],
't': _B[2345],
'u': _B[136],
'v': _B[1236],
'w': _B[2456],
'x': _B[1346],
'y': _B[13456],
'z': _B[1356],
' ': _B[0],
'!': _B[235],
"'": _B[3],
',': _B[2],
'-': _B[356],
'.': _B[256],
'/': _B[34],
':': _B[25],
'?': _B[236],
'(': _B[2356],
')': _B[2356],
'^': _B[4], # substitute for accent mark
'[': _B[6] + _B[2356],
']': _B[2356] + _B[3],
'*': _B[35] + _B[35],
}
alphabet: Dict[Union[str, int], str] = {
'a': _B[1],
'b': _B[12],
'c': _B[14],
'd': _B[145],
'e': _B[15],
'f': _B[124],
'g': _B[1245],
'h': _B[125],
'i': _B[24],
'j': _B[245],
'k': _B[13],
'l': _B[123],
'm': _B[134],
'n': _B[1345],
'o': _B[135],
'p': _B[1234],
'q': _B[12345],
'r': _B[1235],
's': _B[234],
't': _B[2345],
'u': _B[136],
'v': _B[1236],
'w': _B[2456],
'x': _B[1346],
'y': _B[13456],
'z': _B[1356],
' ': _B[0],
'!': _B[235],
"'": _B[3],
',': _B[2],
'-': _B[356],
'.': _B[256],
'/': _B[34],
':': _B[25],
'?': _B[236],
'(': _B[2356],
')': _B[2356],
'^': _B[4], # substitute for accent mark
'[': _B[6] + _B[2356],
']': _B[2356] + _B[3],
'*': _B[35] + _B[35],
}
alphabet.update(numbersUpper)

chordSymbols = {
Expand Down
2 changes: 1 addition & 1 deletion music21/braille/noteGrouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def transcribeNoteGrouping(brailleElementGrouping, showLeadingOctave=True):
'''
transcribe a group of notes, possibly excluding certain attributes.

To be DEPRECATED -- called only be BrailleGrandSegment now.
To be DEPRECATED -- called only by BrailleGrandSegment now.
'''
ngt = NoteGroupingTranscriber()
ngt.showLeadingOctave = showLeadingOctave
Expand Down
Loading