diff --git a/music21/_version.py b/music21/_version.py index 5a22573d8e..7ddb9bef43 100644 --- a/music21/_version.py +++ b/music21/_version.py @@ -41,7 +41,7 @@ Changing this number invalidates old pickles -- do it if the old pickles create a problem. ''' -__version_info__ = (8, 0, 0, 'a10') # can be 3-tuple or 4+-tuple: (7, 0, 5, 'a2') +__version_info__ = (8, 0, 0, 'a11') # can be 3-tuple or 4+-tuple: (7, 0, 5, 'a2') v = '.'.join(str(x) for x in __version_info__[0:3]) if len(__version_info__) > 3 and __version_info__[3]: # type: ignore diff --git a/music21/analysis/discrete.py b/music21/analysis/discrete.py index 52e104b954..ad257095c3 100644 --- a/music21/analysis/discrete.py +++ b/music21/analysis/discrete.py @@ -22,6 +22,8 @@ (for algorithmic key detection) and :class:`music21.analysis.discrete.Ambitus` (for pitch range analysis) provide examples. ''' +from __future__ import annotations + # TODO: make an analysis.base for the Discrete and analyzeStream aspects, then create # range and key modules in analysis @@ -1287,7 +1289,6 @@ def getSolution(self, sStream): def analyzeStream( streamObj: 'music21.stream.Stream', method: str, - *args, **keywords ): ''' @@ -1327,10 +1328,10 @@ def analyzeStream( # this synonym is being added for compatibility method = 'span' - match: t.Optional[t.Callable] = analysisClassFromMethodName(method) + analysisClassName: t.Optional[t.Type[DiscreteAnalysis]] = analysisClassFromMethodName(method) - if match is not None: - obj = match() # NOTE: Cuthbert, this was previously analysisClassName()? - out of scope + if analysisClassName is not None: + obj = analysisClassName() # environLocal.printDebug(['analysis method used:', obj]) return obj.getSolution(streamObj) @@ -1339,7 +1340,7 @@ def analyzeStream( # noinspection SpellCheckingInspection -def analysisClassFromMethodName(method: str): +def analysisClassFromMethodName(method: str) -> t.Optional[t.Type[DiscreteAnalysis]]: ''' Returns an analysis class given a method name, or None if none can be found @@ -1360,7 +1361,7 @@ def analysisClassFromMethodName(method: str): >>> print(repr(acfmn('unknown-format'))) None ''' - analysisClasses = [ + analysisClasses: t.List[t.Type[DiscreteAnalysis]] = [ Ambitus, KrumhanslSchmuckler, AardenEssen, @@ -1368,7 +1369,7 @@ def analysisClassFromMethodName(method: str): BellmanBudge, TemperleyKostkaPayne, ] - match = None + match: t.Optional[t.Type[DiscreteAnalysis]] = None for analysisClass in analysisClasses: # this is a very loose matching, as there are few classes now if (method.lower() in analysisClass.__name__.lower() diff --git a/music21/analysis/patel.py b/music21/analysis/patel.py index e464662ada..2ed7dade3f 100644 --- a/music21/analysis/patel.py +++ b/music21/analysis/patel.py @@ -59,35 +59,31 @@ def nPVI(streamForAnalysis): final = summation * 100 / (totalElements - 1) return final -def melodicIntervalVariability(streamForAnalysis, *skipArgs, **skipKeywords): +def melodicIntervalVariability(streamForAnalysis, **skipKeywords): ''' - gives the Melodic Interval Variability (MIV) for a Stream, + Gives the Melodic Interval Variability (MIV) for a Stream, as defined by Aniruddh D. Patel in "Music, Language, and the Brain" p. 223, as 100 x the coefficient of variation (standard deviation/mean) of the interval size (measured in semitones) between consecutive elements. + The multiplication by 100x exists to put it in the same range as nPVI. - the 100x is designed to put it in the same range as nPVI + Keywords are passed on to + Stream.findConsecutiveNotes() via Stream.melodicIntervals for + determining how to find consecutive intervals. - - this method takes the same arguments of skipArgs and skipKeywords as - Stream.melodicIntervals() for determining how to find consecutive - intervals. - - - - >>> s2 = converter.parse('tinynotation: 4/4 C4 D E F# G#').flatten().notesAndRests.stream() + >>> s2 = converter.parse('tinynotation: 4/4 C4 D E F# G#')[note.Note].stream() >>> analysis.patel.melodicIntervalVariability(s2) 0.0 - >>> s3 = converter.parse('tinynotation: 4/4 C4 D E F G C').flatten().notesAndRests.stream() + >>> s3 = converter.parse('tinynotation: 4/4 C4 D E F G C')[note.Note].stream() >>> analysis.patel.melodicIntervalVariability(s3) 85.266688... - >>> s4 = corpus.parse('bwv66.6').parts[0].flatten().notesAndRests.stream() + >>> s4 = corpus.parse('bwv66.6').parts[0][note.GeneralNote].stream() >>> analysis.patel.melodicIntervalVariability(s4) 65.287... ''' s = streamForAnalysis # shorter - intervalStream = s.melodicIntervals(skipArgs, skipKeywords) + intervalStream = s.melodicIntervals(**skipKeywords) totalElements = len(intervalStream) if totalElements < 2: raise PatelException('need at least three notes to have ' diff --git a/music21/analysis/reduction.py b/music21/analysis/reduction.py index 5ccf835924..d90d51b62d 100644 --- a/music21/analysis/reduction.py +++ b/music21/analysis/reduction.py @@ -113,7 +113,7 @@ def _reprInternal(self): def __getitem__(self, key): return self._parameters[key] - def _parseSpecification(self, spec): + def _parseSpecification(self, spec: str): # start with the defaults self._parameters = copy.deepcopy(self._defaultParameters) spec = spec.strip() @@ -133,7 +133,7 @@ def _parseSpecification(self, spec): self._parameters[attr] = value self._isParsed = True - def isParsed(self): + def isParsed(self) -> bool: return self._isParsed def getNoteAndTextExpression(self): @@ -199,7 +199,7 @@ class ScoreReduction: ''' An object to reduce a score. ''' - def __init__(self, *args, **keywords): + def __init__(self, **keywords): # store a list of one or more reductions self._reductiveNotes = {} self._reductiveVoices = [] @@ -464,7 +464,7 @@ class PartReduction: ''' def __init__(self, srcScore=None, - *args, + *, partGroups: t.Optional[t.List[t.Dict[str, t.Any]]] = None, fillByMeasure: bool = True, segmentByTarget: bool = True, diff --git a/music21/base.py b/music21/base.py index 05209e07b7..c3f971927e 100644 --- a/music21/base.py +++ b/music21/base.py @@ -28,7 +28,7 @@ >>> music21.VERSION_STR -'8.0.0a10' +'8.0.0a11' Alternatively, after doing a complete import, these classes are available under the module "base": @@ -341,7 +341,6 @@ class Music21Object(prebase.ProtoM21Object): } def __init__(self, - *arguments, id: t.Union[str, int, None] = None, # pylint: disable=redefined-builtin groups: t.Optional[Groups] = None, sites: t.Optional[Sites] = None, @@ -1161,11 +1160,11 @@ def getSpannerSites(self, if obj is None: # pragma: no cover continue if spannerClassList is None: - post.append(obj.spannerParent) + post.append(obj.client) else: for spannerClass in spannerClassList: - if spannerClass in obj.spannerParent.classSet: - post.append(obj.spannerParent) + if spannerClass in obj.client.classSet: + post.append(obj.client) break return post @@ -1800,7 +1799,6 @@ def contextSites( offset=0.0, recurseType='elementsFirst') - >>> partIterator = c.parts >>> m3 = partIterator[1].measure(3) >>> for csTuple in m3.contextSites(): @@ -2366,7 +2364,7 @@ def offset(self) -> OffsetQL: thus the place where `.offset` looks to find its number. >>> m2 = stream.Measure() - >>> m2.insert(3.0/5, n1) + >>> m2.insert(3/5, n1) >>> m2.number = 5 >>> n1.offset Fraction(3, 5) @@ -2387,20 +2385,17 @@ def offset(self) -> OffsetQL: >>> n1.offset 10.0 - The property can also set the offset for the object if no container has been set: - >>> n1 = note.Note() >>> n1.id = 'hi' - >>> n1.offset = 20/3. + >>> n1.offset = 20/3 >>> n1.offset Fraction(20, 3) >>> float(n1.offset) 6.666... - >>> s1 = stream.Stream() >>> s1.append(n1) >>> n1.offset diff --git a/music21/braille/segment.py b/music21/braille/segment.py index dc2ee44418..6f1bfa4bfe 100644 --- a/music21/braille/segment.py +++ b/music21/braille/segment.py @@ -167,9 +167,9 @@ class BrailleElementGrouping(ProtoM21Object): 'withHyphen': 'If True, this grouping will end with a music hyphen.', 'numRepeats': 'The number of times this grouping is repeated.' } - def __init__(self, *args): + def __init__(self, *listElements): ''' - A BrailleElementGrouping is a superclass of list of objects which should be displayed + A BrailleElementGrouping mimics a list of objects which should be displayed without a space in braille. >>> from music21.braille import segment @@ -209,8 +209,7 @@ def __init__(self, *args): >>> bg.numRepeats 0 ''' - super().__init__() - self.internalList = list(*args) + self.internalList = list(*listElements) setGroupingGlobals() self.keySignature = GROUPING_GLOBALS['keySignature'] diff --git a/music21/braille/test.py b/music21/braille/test.py index b4a7f45309..5a3c010f28 100644 --- a/music21/braille/test.py +++ b/music21/braille/test.py @@ -2706,7 +2706,10 @@ def test_example13_2(self): def xtest_example13_3(self): # Problem: How to plug in wedges into music21? - bm = converter.parse('tinynotation: a1 a1 a1 a1', 'c').flatten() + bm = converter.parse('tinynotation: 4/4 a1 a1 a1 a1').flatten() + commonTime = bm[meter.TimeSignature].first() + if commonTime is not None: # it is not None, but for typing + commonTime.symbol = 'common' bm.makeNotation(inPlace=True, cautionaryNotImmediateRepeat=False) ml = bm.getElementsByClass(stream.Measure) ml[-1].rightBarline = None diff --git a/music21/chord/__init__.py b/music21/chord/__init__.py index e009fa6cfa..f334f1caeb 100644 --- a/music21/chord/__init__.py +++ b/music21/chord/__init__.py @@ -3597,6 +3597,8 @@ def isTriad(self) -> bool: False >>> incorrectlySpelled.pitches[1].getEnharmonic(inPlace=True) + >>> incorrectlySpelled + >>> incorrectlySpelled.isTriad() True diff --git a/music21/common/decorators.py b/music21/common/decorators.py index 7da0cf3a2e..fee23a4b68 100644 --- a/music21/common/decorators.py +++ b/music21/common/decorators.py @@ -26,27 +26,27 @@ def optional_arg_decorator(fn): a decorator for decorators. Allows them to either have or not have arguments. ''' @wraps(fn) - def wrapped_decorator(*args, **keywords): - is_bound_method = hasattr(args[0], fn.__name__) if args else False + def wrapped_decorator(*arguments, **keywords): + is_bound_method = hasattr(arguments[0], fn.__name__) if arguments else False klass = None if is_bound_method: - klass = args[0] - args = args[1:] + klass = arguments[0] + arguments = arguments[1:] # If no arguments were passed... - if len(args) == 1 and not keywords and callable(args[0]): + if len(arguments) == 1 and not keywords and callable(arguments[0]): if is_bound_method: - return fn(klass, args[0]) + return fn(klass, arguments[0]) else: - return fn(args[0]) + return fn(arguments[0]) else: def real_decorator(toBeDecorated): if is_bound_method: - return fn(klass, toBeDecorated, *args, **keywords) + return fn(klass, toBeDecorated, *arguments, **keywords) else: - return fn(toBeDecorated, *args, **keywords) + return fn(toBeDecorated, *arguments, **keywords) return real_decorator return wrapped_decorator @@ -129,11 +129,12 @@ def deprecated(method, startDate=None, removeDate=None, message=None): 'message': m} @wraps(method) - def func_wrapper(*args, **keywords): - if len(args) > 1 and args[1] in ('_ipython_canary_method_should_not_exist_', - '_repr_mimebundle_', - '_is_coroutine', - ): + def func_wrapper(*arguments, **keywords): + if len(arguments) > 1 and arguments[1] in ( + '_ipython_canary_method_should_not_exist_', + '_repr_mimebundle_', + '_is_coroutine' + ): # false positive from IPython for StreamIterator.__getattr__ # can remove after v9. falsePositive = True @@ -147,7 +148,7 @@ def func_wrapper(*args, **keywords): exceptions21.Music21DeprecationWarning, stacklevel=2) callInfo['calledAlready'] = True - return method(*args, **keywords) + return method(*arguments, **keywords) return func_wrapper @@ -175,11 +176,11 @@ def cacheMethod(method): funcName = method.__name__ @wraps(method) - def inner(instance, *args, **keywords): + def inner(instance, *arguments, **keywords): if funcName in instance._cache: return instance._cache[funcName] - instance._cache[funcName] = method(instance, *args, **keywords) + instance._cache[funcName] = method(instance, *arguments, **keywords) return instance._cache[funcName] return inner diff --git a/music21/common/stringTools.py b/music21/common/stringTools.py index 0bc05a8f52..57f4301f89 100644 --- a/music21/common/stringTools.py +++ b/music21/common/stringTools.py @@ -262,10 +262,11 @@ def getMd5(value=None) -> str: def formatStr(msg, - *args, - format: t.Optional[str] = None, # pylint: disable=redefined-builtin + *rest_of_message, **keywords) -> str: ''' + DEPRECATED: do not use. May be removed at any time. + Format one or more data elements into string suitable for printing straight to stderr or other outputs @@ -274,8 +275,7 @@ def formatStr(msg, test 1 2 3 ''' - - msg = [msg] + list(args) + msg = [msg, *rest_of_message] for i in range(len(msg)): x = msg[i] if isinstance(x, bytes): @@ -288,10 +288,7 @@ def formatStr(msg, msg[i] = x.decode('utf-8') except AttributeError: msg[i] = '' - if format == 'block': - return '\n*** '.join(msg) + '\n' - else: # catch all others - return ' '.join(msg) + '\n' + return ' '.join(msg) + '\n' def stripAccents(inputString: str) -> str: diff --git a/music21/converter/__init__.py b/music21/converter/__init__.py index cec88f40b3..b548754dfb 100644 --- a/music21/converter/__init__.py +++ b/music21/converter/__init__.py @@ -1192,7 +1192,7 @@ def parseURL(url, def parse(value: t.Union[bundles.MetadataEntry, bytes, str, pathlib.Path], - *args, + *, forceSource: bool = False, number: t.Optional[int] = None, format: t.Optional[str] = None, # pylint: disable=redefined-builtin diff --git a/music21/derivation.py b/music21/derivation.py index 797065d048..5a83722178 100644 --- a/music21/derivation.py +++ b/music21/derivation.py @@ -52,8 +52,8 @@ def derivationMethod(function): from via 'allGreen'> ''' @functools.wraps(function) - def wrapper(self, *args, **keywords): - result = function(self, *args, **keywords) + def wrapper(self, *arguments, **keywords): + result = function(self, *arguments, **keywords) result.derivation.origin = self result.derivation.method = function.__name__ return result diff --git a/music21/duration.py b/music21/duration.py index 2a2ced0316..f76527f250 100644 --- a/music21/duration.py +++ b/music21/duration.py @@ -3089,8 +3089,10 @@ class GraceDuration(Duration): ) # INITIALIZER # - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, + typeOrDuration: t.Union[str, OffsetQLIn, DurationTuple, None] = None, + **keywords): + super().__init__(typeOrDuration, **keywords) # update components to derive types; this sets ql, but this # will later be removed if self._componentsNeedUpdating: @@ -3100,7 +3102,7 @@ def __init__(self, *arguments, **keywords): newComponents = [] for c in self.components: newComponents.append(DurationTuple(c.type, c.dots, 0.0)) - self.components = newComponents # set new components + self.components = tuple(newComponents) # set new components # make time is encoded in musicxml as divisions; here it can # be encoded as a duration; but should it be the duration suggested by the grace? @@ -3154,8 +3156,10 @@ class AppoggiaturaDuration(GraceDuration): # INITIALIZER # - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, + typeOrDuration: t.Union[str, OffsetQLIn, DurationTuple, None] = None, + **keywords): + super().__init__(typeOrDuration, **keywords) self.slash = False # can be True, False, or None; make None go to True? self.makeTime = True diff --git a/music21/dynamics.py b/music21/dynamics.py index 420b152ec6..4eb48f048e 100644 --- a/music21/dynamics.py +++ b/music21/dynamics.py @@ -355,11 +355,12 @@ def _setVolumeScalar(self, value): # ------------------------------------------------------------------------------ class DynamicWedge(spanner.Spanner): - '''Common base-class for Crescendo and Diminuendo. + ''' + Common base-class for Crescendo and Diminuendo. ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self.type = None # crescendo or diminuendo self.placement = 'below' # can above or below, after musicxml @@ -368,7 +369,8 @@ def __init__(self, *arguments, **keywords): class Crescendo(DynamicWedge): - '''A spanner crescendo wedge. + ''' + A spanner crescendo wedge. >>> from music21 import dynamics >>> d = dynamics.Crescendo() @@ -381,13 +383,14 @@ class Crescendo(DynamicWedge): 'crescendo' ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self.type = 'crescendo' class Diminuendo(DynamicWedge): - '''A spanner diminuendo wedge. + ''' + A spanner diminuendo wedge. >>> from music21 import dynamics >>> d = dynamics.Diminuendo() @@ -396,8 +399,8 @@ class Diminuendo(DynamicWedge): 20 ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self.type = 'diminuendo' # ------------------------------------------------------------------------------ @@ -412,7 +415,8 @@ def testSingle(self): a.show() def testBasic(self): - '''present each dynamic in a single measure + ''' + present each dynamic in a single measure ''' from music21 import stream a = stream.Stream() @@ -429,7 +433,8 @@ def testBasic(self): class Test(unittest.TestCase): def testCopyAndDeepcopy(self): - '''Test copying all objects defined in this module + ''' + Test copying all objects defined in this module ''' import copy import sys @@ -511,7 +516,6 @@ def testDynamicsPositionB(self): d = Dynamic('mf') d.style.absoluteY = 20 m.insert(o, d) - # s.show() @@ -522,4 +526,3 @@ def testDynamicsPositionB(self): if __name__ == '__main__': import music21 music21.mainTest(Test) - diff --git a/music21/environment.py b/music21/environment.py index 03db684519..ab00c7df14 100644 --- a/music21/environment.py +++ b/music21/environment.py @@ -1059,7 +1059,7 @@ def formatToApp(self, m21Format): def formatToKey(self, m21Format): return envSingleton().formatToKey(m21Format) - def printDebug(self, msg, statusLevel=common.DEBUG_USER, debugFormat=None): + def printDebug(self, msg, statusLevel=common.DEBUG_USER): ''' Format one or more data elements into string, and print it to stderr. The first arg can be a list of strings or a string; lists are @@ -1071,7 +1071,7 @@ def printDebug(self, msg, statusLevel=common.DEBUG_USER, debugFormat=None): if msg[0] != self.modNameParent and self.modNameParent is not None: msg = [self.modNameParent + ':'] + msg # pass list to common.formatStr - msg = common.formatStr(*msg, format=debugFormat) + msg = common.formatStr(*msg) sys.stderr.write(msg) def read(self, filePath=None): diff --git a/music21/expressions.py b/music21/expressions.py index e4bed3077b..1f3eb95ea8 100644 --- a/music21/expressions.py +++ b/music21/expressions.py @@ -1440,8 +1440,8 @@ class TrillExtension(spanner.Spanner): # We will try to avoid "continue". # N.B. this extension always includes a trill symbol - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self._placement = None # can above or below or None, after musicxml def _getPlacement(self): @@ -1487,8 +1487,8 @@ class TremoloSpanner(spanner.Spanner): # musicxml defines a "start", "stop", and a "continue" type. # We will try to avoid using the "continue" type. - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self.placement = None self.measured = True self._numberOfMarks = 3 @@ -1564,11 +1564,11 @@ class ArpeggioMarkSpanner(spanner.Spanner): > ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) - arpeggioType: t.Optional[str] = keywords.get('arpeggioType', None) - if arpeggioType is None: - arpeggioType = 'normal' + def __init__(self, + *spannedElements, + arpeggioType: str = 'normal', + **keywords): + super().__init__(*spannedElements, **keywords) if arpeggioType not in ('normal', 'up', 'down', 'non-arpeggio'): raise ValueError( 'Arpeggio type must be "normal", "up", "down", or "non-arpeggio"' diff --git a/music21/features/base.py b/music21/features/base.py index e6fc1b2aff..9620ed4aa2 100644 --- a/music21/features/base.py +++ b/music21/features/base.py @@ -11,15 +11,16 @@ # ------------------------------------------------------------------------------ from __future__ import annotations +from collections import Counter +from collections.abc import KeysView import os import pathlib import pickle import typing as t import unittest -from collections import Counter - from music21 import common +from music21.common.types import StreamType from music21 import converter from music21 import corpus from music21 import exceptions21 @@ -139,7 +140,7 @@ class FeatureExtractor: Usage of a DataInstance offers significant performance advantages, as common forms of the Stream are cached for easy processing. ''' - def __init__(self, dataOrStream=None, *arguments, **keywords): + def __init__(self, dataOrStream=None, **keywords): self.stream = None # the original Stream, or None self.data: t.Optional[DataInstance] = None # a DataInstance object: use to get data self.setData(dataOrStream) @@ -179,8 +180,8 @@ def setData(self, dataOrStream): self.data = dataOrStream def getAttributeLabels(self): - '''Return a list of string in a form that is appropriate for data storage. - + ''' + Return a list of string in a form that is appropriate for data storage. >>> fe = features.jSymbolic.AmountOfArpeggiationFeature() >>> fe.getAttributeLabels() @@ -236,13 +237,15 @@ def prepareFeature(self): self.feature.prepareVectors() # will vector with necessary zeros def process(self): - '''Do processing necessary, storing result in _feature. + ''' + Do processing necessary, storing result in _feature. ''' # do work in subclass, calling on self.data pass def extract(self, source=None): - '''Extract the feature and return the result. + ''' + Extract the feature and return the result. ''' if source is not None: self.stream = source @@ -293,10 +296,8 @@ class StreamForms: of the stream which is the main power of this routine, making it simple to add additional feature extractors at low additional time cost. - ''' - - def __init__(self, streamObj, prepareStream=True): + def __init__(self, streamObj: stream.Stream, prepareStream=True): self.stream = streamObj if self.stream is not None: if prepareStream: @@ -307,13 +308,13 @@ def __init__(self, streamObj, prepareStream=True): self.prepared = None # basic data storage is a dictionary - self.forms = {} + self.forms: t.Dict[str, stream.Stream] = {} - def keys(self): + def keys(self) -> KeysView[str]: # will only return forms that are established return self.forms.keys() - def _prepareStream(self, streamObj): + def _prepareStream(self, streamObj: StreamType) -> StreamType: ''' Common routines done on Streams prior to processing. Returns a new Stream @@ -323,7 +324,7 @@ def _prepareStream(self, streamObj): streamObj = streamObj.stripTies(inPlace=False) return streamObj - def __getitem__(self, key): + def __getitem__(self, key: str) -> stream.Stream: ''' Get a form of this Stream, using a cached version if available. ''' @@ -349,19 +350,20 @@ def __getitem__(self, key): prepared = self.keysToMethods[lastKey](self, prepared) elif lastKey.startswith('getElementsByClass('): classToGet: str = lastKey[len('getElementsByClass('):-1] - prepared = prepared.getElementsByClass(classToGet) + prepared = prepared.getElementsByClass(classToGet).stream() else: raise AttributeError(f'no such attribute: {lastKey} in {key}') self.forms[subKey] = prepared return prepared - def _getIntervalHistogram(self, algorithm='midi'): + def _getIntervalHistogram(self, algorithm='midi') -> t.List[int]: # note that this does not optimize and cache part presentations histo = [0] * 128 # if we have parts, must add one at a time - if self.prepared.hasPartLikeStreams(): - parts = self.prepared.parts + parts: t.List[stream.Stream] + if isinstance(self.prepared, stream.Score): + parts = list(self.prepared.parts) else: parts = [self.prepared] # emulate a list for p in parts: @@ -369,7 +371,10 @@ def _getIntervalHistogram(self, algorithm='midi'): # noNone means that we will see all connections, even w/ a gap post = p.findConsecutiveNotes(skipRests=True, - skipChords=True, skipGaps=True, noNone=True) + skipChords=True, + skipGaps=True, + noNone=True) + for i, n in enumerate(post): if i < len(post) - 1: # if not last iNext = i + 1 @@ -384,7 +389,7 @@ def _getIntervalHistogram(self, algorithm='midi'): return histo # ---------------------------------------------------------------------------- - def formPartitionByInstrument(self, prepared): + def formPartitionByInstrument(self, prepared: stream.Stream): from music21 import instrument return instrument.partitionByInstrument(prepared) diff --git a/music21/features/jSymbolic.py b/music21/features/jSymbolic.py index 32aa88544a..1832df9fde 100644 --- a/music21/features/jSymbolic.py +++ b/music21/features/jSymbolic.py @@ -51,8 +51,8 @@ class MelodicIntervalHistogramFeature(featuresModule.FeatureExtractor): ''' id = 'M1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Interval Histogram' self.description = ('A features array with bins corresponding to ' @@ -80,8 +80,8 @@ class AverageMelodicIntervalFeature(featuresModule.FeatureExtractor): ''' id = 'M2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Melodic Interval' self.description = 'Average melodic interval (in semitones).' @@ -113,8 +113,8 @@ class MostCommonMelodicIntervalFeature(featuresModule.FeatureExtractor): ''' id = 'M3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Melodic Interval' self.description = 'Melodic interval with the highest frequency.' @@ -143,8 +143,8 @@ class DistanceBetweenMostCommonMelodicIntervalsFeature( ''' id = 'M4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Distance Between Most Common Melodic Intervals' self.description = ('Absolute value of the difference between the ' @@ -180,8 +180,8 @@ class MostCommonMelodicIntervalPrevalenceFeature( ''' id = 'M5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Melodic Interval Prevalence' self.description = 'Fraction of melodic intervals that belong to the most common interval.' @@ -212,8 +212,8 @@ class RelativeStrengthOfMostCommonIntervalsFeature( ''' id = 'M6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Relative Strength of Most Common Intervals' self.description = ('Fraction of melodic intervals that belong ' @@ -250,8 +250,8 @@ class NumberOfCommonMelodicIntervalsFeature(featuresModule.FeatureExtractor): ''' id = 'M7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Common Melodic Intervals' self.description = ('Number of melodic intervals that represent ' @@ -288,8 +288,8 @@ class AmountOfArpeggiationFeature(featuresModule.FeatureExtractor): ''' id = 'M8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Amount of Arpeggiation' self.description = ('Fraction of horizontal intervals that are repeated notes, ' @@ -328,8 +328,8 @@ class RepeatedNotesFeature(featuresModule.FeatureExtractor): ''' id = 'M9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Repeated Notes' self.description = 'Fraction of notes that are repeated melodically.' @@ -366,8 +366,8 @@ class ChromaticMotionFeature(featuresModule.FeatureExtractor): ''' id = 'm10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Chromatic Motion' self.description = 'Fraction of melodic intervals corresponding to a semi-tone.' @@ -401,8 +401,8 @@ class StepwiseMotionFeature(featuresModule.FeatureExtractor): ''' id = 'M11' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Stepwise Motion' self.description = ('Fraction of melodic intervals that corresponded ' @@ -437,8 +437,8 @@ class MelodicThirdsFeature(featuresModule.FeatureExtractor): ''' id = 'M12' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Thirds' self.description = 'Fraction of melodic intervals that are major or minor thirds.' @@ -472,8 +472,8 @@ class MelodicFifthsFeature(featuresModule.FeatureExtractor): ''' id = 'M13' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Fifths' self.description = 'Fraction of melodic intervals that are perfect fifths.' @@ -507,8 +507,8 @@ class MelodicTritonesFeature(featuresModule.FeatureExtractor): ''' id = 'M14' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Tritones' self.description = 'Fraction of melodic intervals that are tritones.' @@ -542,8 +542,8 @@ class MelodicOctavesFeature(featuresModule.FeatureExtractor): ''' id = 'M15' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Octaves' self.description = 'Fraction of melodic intervals that are octaves.' @@ -578,8 +578,8 @@ class DirectionOfMotionFeature(featuresModule.FeatureExtractor): ''' id = 'm17' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Direction of Motion' self.description = 'Fraction of melodic intervals that are rising rather than falling.' @@ -636,8 +636,8 @@ class DurationOfMelodicArcsFeature(featuresModule.FeatureExtractor): ''' id = 'M18' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Duration of Melodic Arcs' self.description = ('Average number of notes that separate melodic ' @@ -726,8 +726,8 @@ class SizeOfMelodicArcsFeature(featuresModule.FeatureExtractor): ''' id = 'M19' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Size of Melodic Arcs' self.description = ('Average span (in semitones) between melodic peaks ' @@ -818,8 +818,8 @@ class MostCommonPitchPrevalenceFeature(featuresModule.FeatureExtractor): ''' id = 'P1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Pitch Prevalence' self.description = 'Fraction of Note Ons corresponding to the most common pitch.' @@ -852,8 +852,8 @@ class MostCommonPitchClassPrevalenceFeature(featuresModule.FeatureExtractor): ''' id = 'P2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Pitch Class Prevalence' self.description = 'Fraction of Note Ons corresponding to the most common pitch class.' @@ -886,8 +886,8 @@ class RelativeStrengthOfTopPitchesFeature(featuresModule.FeatureExtractor): ''' id = 'P3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Relative Strength of Top Pitches' self.description = ('The frequency of the 2nd most common pitch ' @@ -921,8 +921,8 @@ class RelativeStrengthOfTopPitchClassesFeature(featuresModule.FeatureExtractor): ''' id = 'P4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Relative Strength of Top Pitch Classes' self.description = ('The frequency of the 2nd most common pitch class ' @@ -961,8 +961,8 @@ class IntervalBetweenStrongestPitchesFeature(featuresModule.FeatureExtractor): ''' id = 'P5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Interval Between Strongest Pitches' self.description = ('Absolute value of the difference between ' @@ -995,8 +995,8 @@ class IntervalBetweenStrongestPitchClassesFeature( ''' id = 'P6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Interval Between Strongest Pitch Classes' self.description = ('Absolute value of the difference between the pitch ' @@ -1030,8 +1030,8 @@ class NumberOfCommonPitchesFeature(featuresModule.FeatureExtractor): ''' id = 'P7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Common Pitches' self.description = ('Number of pitches that account individually ' @@ -1062,8 +1062,8 @@ class PitchVarietyFeature(featuresModule.FeatureExtractor): ''' id = 'P8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Pitch Variety' self.description = 'Number of pitches used at least once.' @@ -1092,8 +1092,8 @@ class PitchClassVarietyFeature(featuresModule.FeatureExtractor): ''' id = 'P9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Pitch Class Variety' self.description = 'Number of pitch classes used at least once.' @@ -1122,8 +1122,8 @@ class RangeFeature(featuresModule.FeatureExtractor): ''' id = 'P10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Range' self.description = 'Difference between highest and lowest pitches.' @@ -1153,8 +1153,8 @@ class MostCommonPitchFeature(featuresModule.FeatureExtractor): ''' id = 'P11' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Pitch' self.description = 'Bin label of the most common pitch.' @@ -1184,8 +1184,8 @@ class PrimaryRegisterFeature(featuresModule.FeatureExtractor): ''' id = 'P12' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Primary Register' self.description = 'Average MIDI pitch.' @@ -1214,8 +1214,8 @@ class ImportanceOfBassRegisterFeature(featuresModule.FeatureExtractor): ''' id = 'P13' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Importance of Bass Register' self.description = 'Fraction of Note Ons between MIDI pitches 0 and 54.' @@ -1250,8 +1250,8 @@ class ImportanceOfMiddleRegisterFeature(featuresModule.FeatureExtractor): ''' id = 'P14' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Importance of Middle Register' self.description = 'Fraction of Note Ons between MIDI pitches 55 and 72.' @@ -1286,8 +1286,8 @@ class ImportanceOfHighRegisterFeature(featuresModule.FeatureExtractor): ''' id = 'P15' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Importance of High Register' self.description = 'Fraction of Note Ons between MIDI pitches 73 and 127.' @@ -1322,8 +1322,8 @@ class MostCommonPitchClassFeature(featuresModule.FeatureExtractor): ''' id = 'P16' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Pitch Class' self.description = 'Bin label of the most common pitch class.' @@ -1347,8 +1347,8 @@ class DominantSpreadFeature(featuresModule.FeatureExtractor): ''' id = 'P17' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Dominant Spread' self.description = ('Largest number of consecutive pitch classes separated by ' @@ -1370,8 +1370,8 @@ class StrongTonalCentresFeature(featuresModule.FeatureExtractor): ''' id = 'P18' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Strong Tonal Centres' self.description = ('Number of peaks in the fifths pitch histogram that each account ' @@ -1408,8 +1408,8 @@ class BasicPitchHistogramFeature(featuresModule.FeatureExtractor): ''' id = 'P19' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Basic Pitch Histogram' self.description = ('A features array with bins corresponding to the ' @@ -1441,8 +1441,8 @@ class PitchClassDistributionFeature(featuresModule.FeatureExtractor): ''' id = 'P20' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Pitch Class Distribution' self.description = ('A feature array with 12 entries where the first holds ' @@ -1487,8 +1487,8 @@ class FifthsPitchHistogramFeature(featuresModule.FeatureExtractor): ''' id = 'P21' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Fifths Pitch Histogram' self.description = ('A feature array with bins corresponding to the values of the ' @@ -1533,8 +1533,8 @@ class QualityFeature(featuresModule.FeatureExtractor): ''' id = 'P22' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Quality' self.description = ''' @@ -1572,8 +1572,8 @@ class GlissandoPrevalenceFeature(featuresModule.FeatureExtractor): ''' id = 'P23' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Glissando Prevalence' self.description = ('Number of Note Ons that have at least one MIDI Pitch Bend ' @@ -1597,8 +1597,8 @@ class AverageRangeOfGlissandosFeature(featuresModule.FeatureExtractor): ''' id = 'P24' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Range Of Glissandos' self.description = ('Average range of MIDI Pitch Bends, where "range" is ' @@ -1624,8 +1624,8 @@ class VibratoPrevalenceFeature(featuresModule.FeatureExtractor): ''' id = 'P25' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Vibrato Prevalence' self.description = ('Number of notes for which Pitch Bend messages change ' @@ -1649,9 +1649,9 @@ class PrevalenceOfMicrotonesFeature(featuresModule.FeatureExtractor): ''' id = 'P26' - def __init__(self, dataOrStream=None, *arguments, **keywords): + def __init__(self, dataOrStream=None, **keywords): super().__init__(dataOrStream=dataOrStream, - *arguments, **keywords) + **keywords) self.name = 'Prevalence Of Microtones' self.description = ('Number of Note Ons that are preceded by isolated MIDI Pitch ' @@ -1688,8 +1688,8 @@ class StrongestRhythmicPulseFeature(featuresModule.FeatureExtractor): id = 'R1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Strongest Rhythmic Pulse' self.description = 'Bin label of the beat bin with the highest frequency.' @@ -1722,8 +1722,8 @@ class SecondStrongestRhythmicPulseFeature(featuresModule.FeatureExtractor): ''' id = 'R2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Second Strongest Rhythmic Pulse' self.description = ('Bin label of the beat bin of the peak ' @@ -1762,8 +1762,8 @@ class HarmonicityOfTwoStrongestRhythmicPulsesFeature( ''' id = 'R3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Harmonicity of Two Strongest Rhythmic Pulses' self.description = ('The bin label of the higher (in terms of bin label) of the ' @@ -1794,8 +1794,8 @@ class StrengthOfStrongestRhythmicPulseFeature(featuresModule.FeatureExtractor): ''' id = 'R4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Strength of Strongest Rhythmic Pulse' self.description = 'Frequency of the beat bin with the highest frequency.' @@ -1821,8 +1821,8 @@ class StrengthOfSecondStrongestRhythmicPulseFeature( ''' id = 'R5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Strength of Second Strongest Rhythmic Pulse' self.description = ('Frequency of the beat bin of the peak ' @@ -1858,8 +1858,8 @@ class StrengthRatioOfTwoStrongestRhythmicPulsesFeature( ''' id = 'R6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Strength Ratio of Two Strongest Rhythmic Pulses' self.description = ('The frequency of the higher (in terms of frequency) of the two ' @@ -1893,8 +1893,8 @@ class CombinedStrengthOfTwoStrongestRhythmicPulsesFeature( ''' id = 'R7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Combined Strength of Two Strongest Rhythmic Pulses' self.description = ('The sum of the frequencies of the two beat bins ' @@ -1923,8 +1923,8 @@ class NumberOfStrongPulsesFeature(featuresModule.FeatureExtractor): ''' id = 'R8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Strong Pulses' self.description = 'Number of beat peaks with normalized frequencies over 0.1.' @@ -1944,8 +1944,8 @@ class NumberOfModeratePulsesFeature(featuresModule.FeatureExtractor): ''' id = 'R9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Moderate Pulses' self.description = 'Number of beat peaks with normalized frequencies over 0.01.' @@ -1966,8 +1966,8 @@ class NumberOfRelativelyStrongPulsesFeature(featuresModule.FeatureExtractor): ''' id = 'R10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Relatively Strong Pulses' self.description = '''Number of beat peaks with frequencies at least 30% as high as @@ -1987,8 +1987,8 @@ class RhythmicLoosenessFeature(featuresModule.FeatureExtractor): ''' id = 'R11' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Rhythmic Looseness' self.description = '''Average width of beat histogram peaks (in beats per minute). @@ -2016,10 +2016,10 @@ class PolyrhythmsFeature(featuresModule.FeatureExtractor): ''' id = 'R12' - def __init__(self, dataOrStream=None, *arguments, **keywords): + def __init__(self, dataOrStream=None, **keywords): featuresModule.FeatureExtractor.__init__(self, dataOrStream=dataOrStream, - *arguments, **keywords) + **keywords) self.name = 'Polyrhythms' self.description = ''' @@ -2045,8 +2045,8 @@ class RhythmicVariabilityFeature(featuresModule.FeatureExtractor): ''' id = 'R13' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Rhythmic Variability' self.description = 'Standard deviation of the bin values (except the first 40 empty ones).' @@ -2069,8 +2069,8 @@ class BeatHistogramFeature(featuresModule.FeatureExtractor): ''' id = 'R14' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Beat Histogram' self.description = ('A feature array with entries corresponding to the ' @@ -2101,8 +2101,8 @@ class NoteDensityFeature(featuresModule.FeatureExtractor): ''' id = 'R15' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Note Density' self.description = 'Average number of notes per second.' @@ -2142,8 +2142,8 @@ class AverageNoteDurationFeature(featuresModule.FeatureExtractor): id = 'R17' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Note Duration' self.description = 'Average duration of notes in seconds.' @@ -2180,8 +2180,8 @@ class VariabilityOfNoteDurationFeature(featuresModule.FeatureExtractor): ''' id = 'R18' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variability of Note Duration' self.description = 'Standard deviation of note durations in seconds.' @@ -2211,8 +2211,8 @@ class MaximumNoteDurationFeature(featuresModule.FeatureExtractor): id = 'R19' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Maximum Note Duration' self.description = 'Duration of the longest note (in seconds).' @@ -2242,8 +2242,8 @@ class MinimumNoteDurationFeature(featuresModule.FeatureExtractor): ''' id = 'R20' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Minimum Note Duration' self.description = 'Duration of the shortest note (in seconds).' @@ -2276,8 +2276,8 @@ class StaccatoIncidenceFeature(featuresModule.FeatureExtractor): id = 'R21' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Staccato Incidence' self.description = ('Number of notes with durations of less than a 10th ' @@ -2311,8 +2311,8 @@ class AverageTimeBetweenAttacksFeature(featuresModule.FeatureExtractor): id = 'R22' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Time Between Attacks' self.description = 'Average time in seconds between Note On events (regardless of channel).' @@ -2352,8 +2352,8 @@ class VariabilityOfTimeBetweenAttacksFeature(featuresModule.FeatureExtractor): id = 'R23' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variability of Time Between Attacks' self.description = ('Standard deviation of the times, in seconds, ' @@ -2396,8 +2396,8 @@ class AverageTimeBetweenAttacksForEachVoiceFeature( ''' id = 'R24' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Time Between Attacks For Each Voice' self.description = ('Average of average times in seconds between Note On events ' @@ -2454,8 +2454,8 @@ class AverageVariabilityOfTimeBetweenAttacksForEachVoiceFeature( id = 'R25' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Variability of Time Between Attacks For Each Voice' self.description = ('Average standard deviation, in seconds, of time between ' @@ -2502,9 +2502,9 @@ def process(self): # Not implemented in jSymbolic # # ''' -# def __init__(self, dataOrStream=None, *arguments, **keywords): +# def __init__(self, dataOrStream=None, **keywords): # super().__init__(dataOrStream=dataOrStream, -# *arguments, **keywords) +# **keywords) # # self.name = 'Incidence Of Complete Rests' # self.description = ('Total amount of time in seconds in which no notes are sounding' @@ -2517,9 +2517,9 @@ def process(self): # Not implemented in jSymbolic # # ''' -# def __init__(self, dataOrStream=None, *arguments, **keywords): +# def __init__(self, dataOrStream=None, **keywords): # super().__init__(dataOrStream=dataOrStream, -# *arguments, **keywords) +# **keywords) # # self.name = 'Maximum Complete Rest Duration' # self.description = ('Maximum amount of time in seconds in which no notes ' @@ -2532,9 +2532,9 @@ def process(self): # Not implemented in jSymbolic # # ''' -# def __init__(self, dataOrStream=None, *arguments, **keywords): +# def __init__(self, dataOrStream=None, **keywords): # super().__init__(dataOrStream=dataOrStream, -# *arguments, **keywords) +# **keywords) # # self.name = 'Average Rest Duration Per Voice' # self.description = ('Average, in seconds, of the average amounts of time in each ' @@ -2548,9 +2548,9 @@ def process(self): # Not implemented in jSymbolic # # ''' -# def __init__(self, dataOrStream=None, *arguments, **keywords): +# def __init__(self, dataOrStream=None, **keywords): # super().__init__(dataOrStream=dataOrStream, -# *arguments, **keywords) +# **keywords) # # self.name = 'Average Variability Of Rest Durations Across Voices' # self.description = ('Standard deviation, in seconds, of the average amounts of time ' @@ -2575,8 +2575,8 @@ class InitialTempoFeature(featuresModule.FeatureExtractor): id = 'R30' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Initial Tempo' self.description = 'Tempo in beats per minute at the start of the recording.' @@ -2612,8 +2612,8 @@ class InitialTimeSignatureFeature(featuresModule.FeatureExtractor): id = 'R31' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Initial Time Signature' self.description = ('A feature array with two elements. ' @@ -2660,8 +2660,8 @@ class CompoundOrSimpleMeterFeature(featuresModule.FeatureExtractor): id = 'R32' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Compound Or Simple Meter' self.description = ('Set to 1 if the initial meter is compound ' @@ -2708,8 +2708,8 @@ class TripleMeterFeature(featuresModule.FeatureExtractor): id = 'R33' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Triple Meter' self.description = ('Set to 1 if numerator of initial time signature is 3, ' @@ -2749,8 +2749,8 @@ class QuintupleMeterFeature(featuresModule.FeatureExtractor): id = 'R34' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Quintuple Meter' self.description = ('Set to 1 if numerator of initial time signature is 5, ' @@ -2789,8 +2789,8 @@ class ChangesOfMeterFeature(featuresModule.FeatureExtractor): ''' id = 'R35' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Changes of Meter' self.description = ('Set to 1 if the time signature is changed one or more ' @@ -2822,8 +2822,8 @@ class DurationFeature(featuresModule.FeatureExtractor): ''' id = 'R36' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Duration' self.description = 'The total duration in seconds of the music.' @@ -2856,8 +2856,8 @@ class OverallDynamicRangeFeature(featuresModule.FeatureExtractor): ''' id = 'D1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Overall Dynamic Range' self.description = 'The maximum loudness minus the minimum loudness value.' @@ -2877,8 +2877,8 @@ class VariationOfDynamicsFeature(featuresModule.FeatureExtractor): ''' id = 'D2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variation of Dynamics' self.description = 'Standard deviation of loudness levels of all notes.' @@ -2898,8 +2898,8 @@ class VariationOfDynamicsInEachVoiceFeature(featuresModule.FeatureExtractor): ''' id = 'D3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variation of Dynamics In Each Voice' self.description = ('The average of the standard deviations of loudness ' @@ -2922,8 +2922,8 @@ class AverageNoteToNoteDynamicsChangeFeature(featuresModule.FeatureExtractor): id = 'D4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Note To Note Dynamics Change' self.description = ('Average change of loudness from one note to the next note ' @@ -2956,8 +2956,8 @@ class MaximumNumberOfIndependentVoicesFeature(featuresModule.FeatureExtractor): id = 'T1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Maximum Number of Independent Voices' self.description = ('Maximum number of different channels in which notes ' @@ -2999,8 +2999,8 @@ class AverageNumberOfIndependentVoicesFeature(featuresModule.FeatureExtractor): ''' id = 'T2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Average Number of Independent Voices' self.description = ('Average number of different channels in which notes have ' @@ -3040,8 +3040,8 @@ class VariabilityOfNumberOfIndependentVoicesFeature( ''' id = 'T3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variability of Number of Independent Voices' self.description = ('Standard deviation of number of different channels ' @@ -3080,8 +3080,8 @@ class VoiceEqualityNumberOfNotesFeature(featuresModule.FeatureExtractor): ''' id = 'T4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Equality - Number of Notes' self.description = ('Standard deviation of the total number of Note Ons ' @@ -3101,8 +3101,8 @@ class VoiceEqualityNoteDurationFeature(featuresModule.FeatureExtractor): ''' id = 'T5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Equality - Note Duration' self.description = ('Standard deviation of the total duration of notes in seconds ' @@ -3122,8 +3122,8 @@ class VoiceEqualityDynamicsFeature(featuresModule.FeatureExtractor): ''' id = 'T6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Equality - Dynamics' self.description = ('Standard deviation of the average volume of notes ' @@ -3143,8 +3143,8 @@ class VoiceEqualityMelodicLeapsFeature(featuresModule.FeatureExtractor): ''' id = 'T7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Equality - Melodic Leaps' self.description = '''Standard deviation of the average melodic leap in MIDI pitches @@ -3162,8 +3162,8 @@ class VoiceEqualityRangeFeature(featuresModule.FeatureExtractor): ''' id = 'T8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Equality - Range' self.description = '''Standard deviation of the differences between the @@ -3183,8 +3183,8 @@ class ImportanceOfLoudestVoiceFeature(featuresModule.FeatureExtractor): ''' id = 'T9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Importance of Loudest Voice' self.description = '''Difference between the average loudness of the loudest channel @@ -3204,8 +3204,8 @@ class RelativeRangeOfLoudestVoiceFeature(featuresModule.FeatureExtractor): ''' id = 'T10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Relative Range of Loudest Voice' self.description = '''Difference between the highest note and the lowest note @@ -3226,8 +3226,8 @@ class RangeOfHighestLineFeature(featuresModule.FeatureExtractor): ''' id = 'T12' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Range of Highest Line' self.description = '''Difference between the highest note and the lowest note @@ -3248,8 +3248,8 @@ class RelativeNoteDensityOfHighestLineFeature(featuresModule.FeatureExtractor): ''' id = 'T13' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Relative Note Density of Highest Line' self.description = '''Number of Note Ons in the channel with the highest average @@ -3270,8 +3270,8 @@ class MelodicIntervalsInLowestLineFeature(featuresModule.FeatureExtractor): ''' id = 'T15' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Melodic Intervals in Lowest Line' self.description = '''Average melodic interval in semitones of the channel @@ -3290,8 +3290,8 @@ class VoiceSeparationFeature(featuresModule.FeatureExtractor): ''' id = 'T20' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Voice Separation' self.description = '''Average separation in semi-tones between the average pitches of @@ -3341,8 +3341,8 @@ class PitchedInstrumentsPresentFeature(featuresModule.FeatureExtractor): ''' id = 'I1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Pitched Instruments Present' self.description = '''Which pitched General MIDI Instruments are present. @@ -3386,8 +3386,8 @@ class UnpitchedInstrumentsPresentFeature(featuresModule.FeatureExtractor): id = 'I2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Unpitched Instruments Present' self.description = '''Which unpitched MIDI Percussion Key Map instruments are present. @@ -3432,8 +3432,8 @@ class NotePrevalenceOfPitchedInstrumentsFeature( ''' id = 'I3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Note Prevalence of Pitched Instruments' self.description = ('The fraction of (pitched) notes played by each ' @@ -3476,8 +3476,8 @@ class NotePrevalenceOfUnpitchedInstrumentsFeature( ''' id = 'I4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Note Prevalence of Unpitched Instruments' self.description = '''The fraction of (unpitched) notes played by each General MIDI @@ -3509,8 +3509,8 @@ class TimePrevalenceOfPitchedInstrumentsFeature( ''' id = 'I5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Time Prevalence of Pitched Instruments' self.description = ('The fraction of the total time of the recording in which a note ' @@ -3542,8 +3542,8 @@ class VariabilityOfNotePrevalenceOfPitchedInstrumentsFeature( ''' id = 'I6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variability of Note Prevalence of Pitched Instruments' self.description = ('Standard deviation of the fraction of Note Ons played ' @@ -3591,8 +3591,8 @@ class VariabilityOfNotePrevalenceOfUnpitchedInstrumentsFeature( ''' id = 'I7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Variability of Note Prevalence of Unpitched Instruments' self.description = ( @@ -3620,8 +3620,8 @@ class NumberOfPitchedInstrumentsFeature(featuresModule.FeatureExtractor): ''' id = 'I8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Pitched Instruments' self.description = ('Total number of General MIDI patches that are used to ' @@ -3656,8 +3656,8 @@ class NumberOfUnpitchedInstrumentsFeature(featuresModule.FeatureExtractor): id = 'I9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Number of Unpitched Instruments' self.description = ('Number of distinct MIDI Percussion Key Map patches that were ' @@ -3678,8 +3678,8 @@ class PercussionPrevalenceFeature(featuresModule.FeatureExtractor): id = 'I10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Percussion Prevalence' self.description = ('Total number of Note Ons corresponding to unpitched percussion ' @@ -3696,8 +3696,8 @@ class InstrumentFractionFeature(featuresModule.FeatureExtractor): look at the proportional usage of an Instrument ''' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) # subclasses must define self._targetPrograms = [] @@ -3736,8 +3736,8 @@ class StringKeyboardFractionFeature(InstrumentFractionFeature): id = 'I11' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'String Keyboard Fraction' self.description = ('Fraction of all Note Ons belonging to string keyboard patches ' @@ -3765,8 +3765,8 @@ class AcousticGuitarFractionFeature(InstrumentFractionFeature): id = 'I12' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Acoustic Guitar Fraction' self.description = ('Fraction of all Note Ons belonging to acoustic guitar patches ' @@ -3791,8 +3791,8 @@ class ElectricGuitarFractionFeature(InstrumentFractionFeature): id = 'I13' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Electric Guitar Fraction' self.description = ('Fraction of all Note Ons belonging to ' @@ -3820,8 +3820,8 @@ class ViolinFractionFeature(InstrumentFractionFeature): id = 'I14' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Violin Fraction' self.description = ('Fraction of all Note Ons belonging to violin patches ' @@ -3849,8 +3849,8 @@ class SaxophoneFractionFeature(InstrumentFractionFeature): ''' id = 'I15' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Saxophone Fraction' self.description = ('Fraction of all Note Ons belonging to saxophone patches ' @@ -3880,8 +3880,8 @@ class BrassFractionFeature(InstrumentFractionFeature): id = 'I16' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Brass Fraction' self.description = ('Fraction of all Note Ons belonging to brass patches ' @@ -3911,8 +3911,8 @@ class WoodwindsFractionFeature(InstrumentFractionFeature): id = 'I17' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Woodwinds Fraction' self.description = ('Fraction of all Note Ons belonging to woodwind patches ' @@ -3940,8 +3940,8 @@ class OrchestralStringsFractionFeature(InstrumentFractionFeature): id = 'I18' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Orchestral Strings Fraction' self.description = ('Fraction of all Note Ons belonging to orchestral strings patches ' @@ -3963,8 +3963,8 @@ class StringEnsembleFractionFeature(InstrumentFractionFeature): id = 'I19' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'String Ensemble Fraction' self.description = ('Fraction of all Note Ons belonging to string ensemble patches ' @@ -3991,8 +3991,8 @@ class ElectricInstrumentFractionFeature(InstrumentFractionFeature): ''' id = 'I20' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Electric Instrument Fraction' self.description = ('Fraction of all Note Ons belonging to electric instrument patches ' diff --git a/music21/features/native.py b/music21/features/native.py index f71d2841ea..660af2ed7a 100644 --- a/music21/features/native.py +++ b/music21/features/native.py @@ -89,8 +89,8 @@ class QualityFeature(featuresModule.FeatureExtractor): ''' id = 'P22' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Quality' self.description = ''' @@ -170,8 +170,8 @@ class TonalCertainty(featuresModule.FeatureExtractor): ''' id = 'K1' # TODO: need id - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Tonal Certainty' self.description = ('A floating point magnitude value that suggest tonal ' @@ -202,8 +202,8 @@ class FirstBeatAttackPrevalence(featuresModule.FeatureExtractor): ''' id = 'MP1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'First Beat Attack Prevalence' self.description = ('Fraction of first beats of a measure that have notes ' @@ -225,8 +225,8 @@ class UniqueNoteQuarterLengths(featuresModule.FeatureExtractor): ''' id = 'QL1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Unique Note Quarter Lengths' self.description = 'The number of unique note quarter lengths.' @@ -254,8 +254,8 @@ class MostCommonNoteQuarterLength(featuresModule.FeatureExtractor): ''' id = 'QL2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Note Quarter Length' self.description = 'The value of the most common quarter length.' @@ -285,8 +285,8 @@ class MostCommonNoteQuarterLengthPrevalence(featuresModule.FeatureExtractor): ''' id = 'QL3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Note Quarter Length Prevalence' self.description = 'Fraction of notes that have the most common quarter length.' @@ -320,8 +320,8 @@ class RangeOfNoteQuarterLengths(featuresModule.FeatureExtractor): ''' id = 'QL4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Range of Note Quarter Lengths' self.description = 'Difference between the longest and shortest quarter lengths.' @@ -359,8 +359,8 @@ class UniquePitchClassSetSimultaneities(featuresModule.FeatureExtractor): ''' id = 'CS1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Unique Pitch Class Set Simultaneities' self.description = 'Number of unique pitch class simultaneities.' @@ -389,8 +389,8 @@ class UniqueSetClassSimultaneities(featuresModule.FeatureExtractor): ''' id = 'CS2' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Unique Set Class Simultaneities' self.description = 'Number of unique set class simultaneities.' @@ -420,8 +420,8 @@ class MostCommonPitchClassSetSimultaneityPrevalence( ''' id = 'CS3' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Pitch Class Set Simultaneity Prevalence' self.description = ('Fraction of all pitch class simultaneities that are ' @@ -465,8 +465,8 @@ class MostCommonSetClassSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS4' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Most Common Set Class Simultaneity Prevalence' self.description = ('Fraction of all set class simultaneities that ' @@ -506,8 +506,8 @@ class MajorTriadSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS5' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Major Triad Simultaneity Prevalence' self.description = 'Percentage of all simultaneities that are major triads.' @@ -538,8 +538,8 @@ class MinorTriadSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS6' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Minor Triad Simultaneity Prevalence' self.description = 'Percentage of all simultaneities that are minor triads.' @@ -570,8 +570,8 @@ class DominantSeventhSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS7' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Dominant Seventh Simultaneity Prevalence' self.description = 'Percentage of all simultaneities that are dominant seventh.' @@ -602,8 +602,8 @@ class DiminishedTriadSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS8' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Diminished Triad Simultaneity Prevalence' self.description = 'Percentage of all simultaneities that are diminished triads.' @@ -641,8 +641,8 @@ class TriadSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS9' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Triad Simultaneity Prevalence' self.description = 'Proportion of all simultaneities that form triads.' @@ -673,8 +673,8 @@ class DiminishedSeventhSimultaneityPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS10' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Diminished Seventh Simultaneity Prevalence' self.description = 'Percentage of all simultaneities that are diminished seventh chords.' @@ -716,8 +716,8 @@ class IncorrectlySpelledTriadPrevalence(featuresModule.FeatureExtractor): ''' id = 'CS11' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Incorrectly Spelled Triad Prevalence' self.description = 'Percentage of all triads that are spelled incorrectly.' @@ -777,8 +777,8 @@ class ChordBassMotionFeature(featuresModule.FeatureExtractor): ''' id = 'CS12' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Chord Bass Motion' self.description = ('12-element vector showing the fraction of chords that move ' @@ -852,8 +852,8 @@ class LandiniCadence(featuresModule.FeatureExtractor): ''' id = 'MC1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Ends With Landini Melodic Contour' self.description = ('Boolean that indicates the presence of a Landini-like ' @@ -921,8 +921,8 @@ class LanguageFeature(featuresModule.FeatureExtractor): ''' id = 'TX1' - def __init__(self, dataOrStream=None, *arguments, **keywords): - super().__init__(dataOrStream=dataOrStream, *arguments, **keywords) + def __init__(self, dataOrStream=None, **keywords): + super().__init__(dataOrStream=dataOrStream, **keywords) self.name = 'Language Feature' self.description = ('Language of the lyrics of the piece given as a numeric ' diff --git a/music21/figuredBass/segment.py b/music21/figuredBass/segment.py index 1f5fd6cb19..8e86253eb0 100644 --- a/music21/figuredBass/segment.py +++ b/music21/figuredBass/segment.py @@ -766,7 +766,9 @@ def allCorrectConsecutivePossibilities(self, segmentB): if not (self._maxPitch == segmentB._maxPitch): raise SegmentException('Two segments with unequal maxPitch cannot be compared.') self._specialResolutionRuleChecking = _compileRules( - self.specialResolutionRules(self.fbRules), 3) + self.specialResolutionRules(self.fbRules), + 3 + ) for (resolutionMethod, args) in self._specialResolutionRuleChecking[True]: return resolutionMethod(segmentB, *args) return self._resolveOrdinarySegment(segmentB) diff --git a/music21/graph/__init__.py b/music21/graph/__init__.py index d3dc300e97..7f31bf81f9 100644 --- a/music21/graph/__init__.py +++ b/music21/graph/__init__.py @@ -213,21 +213,20 @@ def testPlotChordsC(self): s.append(sc.getChord('f4', 'g5', quarterLength=3)) s.append(note.Note('c5', quarterLength=3)) - for args in [ - ('histogram', 'pitch'), - ('histogram', 'pitchclass'), - ('histogram', 'quarterlength'), + for plotType, xValue, yValue in [ + ('histogram', 'pitch', None), + ('histogram', 'pitchclass', None), + ('histogram', 'quarterlength', None), ('scatter', 'pitch', 'quarterlength'), ('scatter', 'pitchspace', 'offset'), ('scatter', 'pitch', 'offset'), - ('scatter', 'dynamics'), - ('bar', 'pitch'), - ('bar', 'pc'), + ('scatter', 'dynamics', None), + ('bar', 'pitch', None), + ('bar', 'pc', None), ('weighted', 'pc', 'duration'), - ('weighted', 'dynamics'), + ('weighted', 'dynamics', None), ]: - # s.plot(*args, doneAction='write') - s.plot(*args, doneAction=None) + s.plot(plotType, xValue=xValue, yValue=yValue, doneAction=None) def testHorizontalInstrumentationB(self): from music21 import corpus diff --git a/music21/graph/plot.py b/music21/graph/plot.py index ad1b77b615..c7e33abede 100644 --- a/music21/graph/plot.py +++ b/music21/graph/plot.py @@ -65,7 +65,7 @@ class derived from Graph. ''' axesClasses: t.Dict[str, t.Type[axis.Axis]] = {'x': axis.Axis, 'y': axis.Axis} - def __init__(self, streamObj=None, recurse=True, *args, **keywords): + def __init__(self, streamObj=None, recurse=True, **keywords): # if not isinstance(streamObj, music21.stream.Stream): if streamObj is not None and not hasattr(streamObj, 'elements'): # pragma: no cover raise PlotStreamException(f'non-stream provided as argument: {streamObj}') @@ -391,8 +391,8 @@ def id(self): # ------------------------------------------------------------------------------ class PlotStream(primitives.Graph, PlotStreamMixin): - def __init__(self, streamObj=None, *args, **keywords): - primitives.Graph.__init__(self, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + primitives.Graph.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) self.axisX = axis.OffsetAxis(self, 'x') @@ -406,8 +406,8 @@ class Scatter(primitives.GraphScatter, PlotStreamMixin): Base class for 2D scatter plots. ''' - def __init__(self, streamObj=None, *args, **keywords): - primitives.GraphScatter.__init__(self, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + primitives.GraphScatter.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) @@ -430,8 +430,8 @@ class ScatterPitchSpaceQuarterLength(Scatter): 'y': axis.PitchSpaceAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) self.axisX.useLogScale = True # need more space for pitch axis labels if 'figureSize' not in keywords: @@ -461,8 +461,8 @@ class ScatterPitchClassQuarterLength(ScatterPitchSpaceQuarterLength): 'y': axis.PitchClassAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) if 'title' not in keywords: self.title = 'Pitch Class by Quarter Length Scatter' @@ -486,8 +486,8 @@ class ScatterPitchClassOffset(Scatter): 'y': axis.PitchClassAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) # need more space for pitch axis labels if 'figureSize' not in keywords: @@ -520,8 +520,8 @@ class ScatterPitchSpaceDynamicSymbol(Scatter): 'y': axis.DynamicsAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) self.axisX.showEnharmonic = False # need more space for pitch axis labels @@ -559,8 +559,8 @@ class Histogram(primitives.GraphHistogram, PlotStreamMixin): 'y': axis.CountingAxis, } - def __init__(self, streamObj=None, *args, **keywords): - primitives.GraphHistogram.__init__(self, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + primitives.GraphHistogram.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) if 'alpha' not in keywords: @@ -635,8 +635,8 @@ class HistogramPitchSpace(Histogram): 'x': axis.PitchSpaceAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) self.axisX.showEnharmonic = False # need more space for pitch axis labels if 'figureSize' not in keywords: @@ -666,8 +666,8 @@ class HistogramPitchClass(Histogram): 'x': axis.PitchClassAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) self.axisX.showEnharmonic = False if 'title' not in keywords: self.title = 'Pitch Class Histogram' @@ -694,8 +694,8 @@ class HistogramQuarterLength(Histogram): 'x': axis.QuarterLengthAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) self.axisX = axis.QuarterLengthAxis(self, 'x') self.axisX.useLogScale = False if 'title' not in keywords: @@ -717,8 +717,8 @@ class ScatterWeighted(primitives.GraphScatterWeighted, PlotStreamMixin): 'z': axis.CountingAxis, } - def __init__(self, streamObj=None, *args, **keywords): - primitives.GraphScatterWeighted.__init__(self, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + primitives.GraphScatterWeighted.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) self.axisZ.countAxes = ('x', 'y') @@ -743,9 +743,9 @@ class ScatterWeightedPitchSpaceQuarterLength(ScatterWeighted): 'y': axis.PitchSpaceAxis, } - def __init__(self, streamObj=None, *args, **keywords): + def __init__(self, streamObj=None, **keywords): super().__init__( - streamObj, *args, **keywords) + streamObj, **keywords) # need more space for pitch axis labels if 'figureSize' not in keywords: self.figureSize = (7, 7) @@ -775,9 +775,9 @@ class ScatterWeightedPitchClassQuarterLength(ScatterWeighted): 'y': axis.PitchClassAxis, } - def __init__(self, streamObj=None, *args, **keywords): + def __init__(self, streamObj=None, **keywords): super().__init__( - streamObj, *args, **keywords) + streamObj, **keywords) # need more space for pitch axis labels if 'figureSize' not in keywords: @@ -809,9 +809,9 @@ class ScatterWeightedPitchSpaceDynamicSymbol(ScatterWeighted): 'y': axis.DynamicsAxis, } - def __init__(self, streamObj=None, *args, **keywords): + def __init__(self, streamObj=None, **keywords): super().__init__( - streamObj, *args, **keywords) + streamObj, **keywords) self.axisX.showEnharmonic = False @@ -856,7 +856,7 @@ class WindowedAnalysis(primitives.GraphColorGrid, PlotStreamMixin): axesClasses: t.Dict[str, t.Type[axis.Axis]] = {'x': axis.OffsetAxis} processorClassDefault: t.Type[discrete.DiscreteAnalysis] = discrete.KrumhanslSchmuckler - def __init__(self, streamObj=None, *args, **keywords): + def __init__(self, streamObj=None, **keywords): self.processorClass = self.processorClassDefault # a discrete processor class. self._processor = None @@ -867,7 +867,7 @@ def __init__(self, streamObj=None, *args, **keywords): self.windowType = 'overlap' self.compressLegend = True - primitives.GraphColorGrid.__init__(self, *args, **keywords) + primitives.GraphColorGrid.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) self.axisX = axis.OffsetAxis(self, 'x') @@ -880,7 +880,7 @@ def processor(self): self._processor = self.processorClass(self.streamObj) # pylint: disable=not-callable return self._processor - def run(self, *args, **keywords): + def run(self, **keywords): ''' actually create the graph... ''' @@ -1034,11 +1034,11 @@ class HorizontalBar(primitives.GraphHorizontalBar, PlotStreamMixin): 'y': axis.PitchSpaceAxis, } - def __init__(self, streamObj=None, *args, colorByPart=False, **keywords): + def __init__(self, streamObj=None, *, colorByPart=False, **keywords): self.colorByPart = colorByPart self._partsToColor: t.Dict[stream.Part, str] = {} - primitives.GraphHorizontalBar.__init__(self, *args, **keywords) + primitives.GraphHorizontalBar.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) self.axisY.hideUnused = False @@ -1146,8 +1146,8 @@ class HorizontalBarPitchClassOffset(HorizontalBar): 'y': axis.PitchClassAxis, } - def __init__(self, streamObj=None, *args, colorByPart=False, **keywords): - super().__init__(streamObj, *args, colorByPart=colorByPart, **keywords) + def __init__(self, streamObj=None, *, colorByPart=False, **keywords): + super().__init__(streamObj, colorByPart=colorByPart, **keywords) self.axisY = axis.PitchClassAxis(self, 'y') self.axisY.hideUnused = False @@ -1173,8 +1173,8 @@ class HorizontalBarPitchSpaceOffset(HorizontalBar): :width: 600 ''' - def __init__(self, streamObj=None, *args, colorByPart=False, **keywords): - super().__init__(streamObj, *args, colorByPart=colorByPart, **keywords) + def __init__(self, streamObj=None, *, colorByPart=False, **keywords): + super().__init__(streamObj, colorByPart=colorByPart, **keywords) if 'figureSize' not in keywords: self.figureSize = (10, 6) @@ -1196,13 +1196,13 @@ class HorizontalBarWeighted(primitives.GraphHorizontalBarWeighted, PlotStreamMix 'segmentByTarget', ) - def __init__(self, streamObj=None, *args, **keywords): + def __init__(self, streamObj=None, **keywords): self.fillByMeasure = False self.segmentByTarget = True self.normalizeByPart = False self.partGroups = None - primitives.GraphHorizontalBarWeighted.__init__(self, *args, **keywords) + primitives.GraphHorizontalBarWeighted.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) def extractData(self): @@ -1274,8 +1274,8 @@ class Dolan(HorizontalBarWeighted): ''' - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) # self.fy = lambda n: n.pitch.pitchClass # self.fyTicks = self.ticksPitchClassUsage @@ -1368,8 +1368,8 @@ class Plot3DBars(primitives.Graph3DBars, PlotStreamMixin): 'z': axis.CountingAxis, } - def __init__(self, streamObj=None, *args, **keywords): - primitives.Graph3DBars.__init__(self, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + primitives.Graph3DBars.__init__(self, **keywords) PlotStreamMixin.__init__(self, streamObj, **keywords) self.axisZ.countAxes = ('x', 'y') @@ -1396,8 +1396,8 @@ class Plot3DBarsPitchSpaceQuarterLength(Plot3DBars): 'y': axis.PitchSpaceAxis, } - def __init__(self, streamObj=None, *args, **keywords): - super().__init__(streamObj, *args, **keywords) + def __init__(self, streamObj=None, **keywords): + super().__init__(streamObj, **keywords) # need more space for pitch axis labels if 'figureSize' not in keywords: @@ -1421,8 +1421,8 @@ class MultiStream(primitives.GraphGroupedVerticalBar, PlotStreamMixin): ''' axesClasses: t.Dict[str, t.Type[axis.Axis]] = {} - def __init__(self, streamList, labelList=None, *args, **keywords): - primitives.GraphGroupedVerticalBar.__init__(self, *args, **keywords) + def __init__(self, streamList, labelList=None, **keywords): + primitives.GraphGroupedVerticalBar.__init__(self, **keywords) PlotStreamMixin.__init__(self, None) if labelList is None: @@ -1468,11 +1468,11 @@ class Features(MultiStream): ''' format = 'features' - def __init__(self, streamList, featureExtractors, labelList=None, *args, **keywords): + def __init__(self, streamList, featureExtractors, labelList=None, **keywords): if labelList is None: labelList = [] - super().__init__(streamList, labelList, *args, **keywords) + super().__init__(streamList, labelList, **keywords) self.featureExtractors = featureExtractors diff --git a/music21/graph/primitives.py b/music21/graph/primitives.py index 09d161cf58..aceb2e61a9 100644 --- a/music21/graph/primitives.py +++ b/music21/graph/primitives.py @@ -125,7 +125,7 @@ class Graph(prebase.ProtoM21Object): 'xTickLabelVerticalAlignment', ) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): extm = getExtendedModules() self.plt = extm.plt # wrapper to matplotlib.pyplot @@ -600,11 +600,11 @@ class GraphNetworkxGraph(Graph): 'networkxGraph', 'hideLeftBottomSpines', ) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.networkxGraph = None self.hideLeftBottomSpines = True - super().__init__(*args, **keywords) + super().__init__(**keywords) extm = getExtendedModules() @@ -695,9 +695,9 @@ class GraphColorGrid(Graph): figureSizeDefault = (9, 6) keywordConfigurables = Graph.keywordConfigurables + ('hideLeftBottomSpines',) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.hideLeftBottomSpines = True - super().__init__(*args, **keywords) + super().__init__(**keywords) def renderSubplot(self, subplot): # do not need a grid for the outer container @@ -802,10 +802,10 @@ class GraphColorGridLegend(Graph): figureSizeDefault = (5, 1.5) keywordConfigurables = Graph.keywordConfigurables + ('hideLeftBottomSpines',) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.hideLeftBottomSpines = True - super().__init__(*args, **keywords) + super().__init__(**keywords) if 'title' not in keywords: self.title = 'Legend' @@ -968,11 +968,11 @@ class GraphHorizontalBar(Graph): 'margin', ) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.barSpace = 8 self.margin = 2 - super().__init__(*args, **keywords) + super().__init__(**keywords) if 'alpha' not in keywords: self.alpha = 0.6 @@ -1077,11 +1077,11 @@ class GraphHorizontalBarWeighted(Graph): 'margin', ) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.barSpace = 8 self.margin = 0.25 # was 8; determines space between channels - super().__init__(*args, **keywords) + super().__init__(**keywords) # this default alpha is used if not specified per bar if 'alpha' not in keywords: @@ -1220,11 +1220,11 @@ class GraphScatterWeighted(Graph): keywordConfigurables = Graph.keywordConfigurables + ('maxDiameter', 'minDiameter') - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.maxDiameter = 1.25 self.minDiameter = 0.25 - super().__init__(*args, **keywords) + super().__init__(**keywords) if 'alpha' not in keywords: self.alpha = 0.6 @@ -1422,12 +1422,9 @@ class GraphHistogram(Graph): graphType = 'histogram' keywordConfigurables = Graph.keywordConfigurables + ('binWidth',) - def __init__(self, *args, **keywords): - self.binWidth = 0.8 - super().__init__(*args, **keywords) - - if 'alpha' not in keywords: - self.alpha = 0.8 + def __init__(self, *, binWidth: float = 0.8, alpha: float = 0.8, **keywords): + self.binWidth = binWidth + super().__init__(alpha=alpha, **keywords) def renderSubplot(self, subplot): self.figure.subplots_adjust(left=0.15) @@ -1472,12 +1469,12 @@ class GraphGroupedVerticalBar(Graph): keywordConfigurables = Graph.keywordConfigurables + ( 'binWidth', 'roundDigits', 'groupLabelHeight',) - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.binWidth = 1 self.roundDigits = 1 self.groupLabelHeight = 0.0 - super().__init__(*args, **keywords) + super().__init__(**keywords) def labelBars(self, subplot, rects): # attach some text labels @@ -1570,10 +1567,8 @@ class Graph3DBars(Graph): graphType = '3DBars' axisKeys = ('x', 'y', 'z') - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) - if 'alpha' not in keywords: - self.alpha = 0.8 + def __init__(self, *, alpha: float = 0.8, **keywords): + super().__init__(alpha=alpha, **keywords) if 'colors' not in keywords: self.colors = ['#ff0000', '#00ff00', '#6666ff'] @@ -1884,4 +1879,3 @@ def testGraphNetworkxGraph(self): if __name__ == '__main__': import music21 music21.mainTest(Test) # , runTest='testPlot3DPitchSpaceQuarterLengthCount') - diff --git a/music21/instrument.py b/music21/instrument.py index 6841a6e88e..542334b8be 100644 --- a/music21/instrument.py +++ b/music21/instrument.py @@ -2089,7 +2089,7 @@ def instrumentFromMidiProgram(number: int) -> Instrument: return inst -def partitionByInstrument(streamObj): +def partitionByInstrument(streamObj: 'music21.stream.Stream') -> 'music21.stream.Stream': # noinspection PyShadowingNames ''' Given a single Stream, or a Score or similar multi-part structure, @@ -2212,6 +2212,8 @@ def partitionByInstrument(streamObj): {0.0} {4.0} + Changes in v8: returns the original stream if there are no instruments. + TODO: parts should be in Score Order. Coincidence that this almost works. TODO: use proper recursion to make a copy of the stream. TODO: final barlines should be aligned. @@ -2232,12 +2234,11 @@ def partitionByInstrument(streamObj): sub.extendDuration('Instrument', inPlace=True) # first, find all unique instruments - instrumentIterator = s.recurse().getElementsByClass(Instrument) + instrumentIterator = s[Instrument] if not instrumentIterator: - # TODO(msc): v7 return s. - return None # no partition is available + return s # no partition is available - names = OrderedDict() # store unique names + names: t.OrderedDict[str, t.Dict[str, t.Any]] = OrderedDict() # store unique names for instrumentObj in instrumentIterator: # matching here by instrument name if instrumentObj.instrumentName not in names: diff --git a/music21/key.py b/music21/key.py index ffeb3ba966..0c8d08589e 100644 --- a/music21/key.py +++ b/music21/key.py @@ -1141,7 +1141,7 @@ def deriveByDegree(self, degree, pitchRef): return ret - def _tonalCertaintyCorrelationCoefficient(self, *args, **keywords): + def _tonalCertaintyCorrelationCoefficient(self): # possible measures: if not self.alternateInterpretations: raise KeySignatureException( @@ -1169,10 +1169,7 @@ def _tonalCertaintyCorrelationCoefficient(self, *args, **keywords): # estimate range as 2, normalize between zero and 1 return (absMagnitude * 1) + (leaderSpan * 2) - def tonalCertainty(self, - method='correlationCoefficient', - *args, - **keywords) -> float: + def tonalCertainty(self, method='correlationCoefficient') -> float: ''' Provide a measure of tonal ambiguity for Key determined with one of many methods. @@ -1216,8 +1213,7 @@ def tonalCertainty(self, [] ''' if method == 'correlationCoefficient': - return self._tonalCertaintyCorrelationCoefficient( - args, keywords) + return self._tonalCertaintyCorrelationCoefficient() else: raise ValueError(f'Unknown method: {method}') diff --git a/music21/layout.py b/music21/layout.py index ba63153a2f..b2babbed93 100644 --- a/music21/layout.py +++ b/music21/layout.py @@ -120,9 +120,6 @@ class LayoutBase(base.Music21Object): ''' classSortOrder = -10 - def __init__(self, *args, **keywords): - super().__init__(**keywords) - def _reprInternal(self): return '' @@ -134,7 +131,6 @@ class ScoreLayout(LayoutBase): PageLayout objects may be found on Measure or Part Streams. - >>> pl = layout.PageLayout(pageNumber=4, leftMargin=234, rightMargin=124, ... pageHeight=4000, pageWidth=3000, isNew=True) >>> pl.pageNumber @@ -157,7 +153,7 @@ class ScoreLayout(LayoutBase): # for each page are working together. def __init__(self, - *args, + *, scalingMillimeters: t.Union[int, float, None] = None, scalingTenths: t.Union[int, float, None] = None, musicFont: t.Optional[str] = None, @@ -222,15 +218,13 @@ class PageLayout(LayoutBase): True This object represents both and - elements in musicxml - - ## TODO -- make sure that the first pageLayout and systemLayout - for each page are working together. - + elements in musicxml. ''' + # TODO -- make sure that the first pageLayout and systemLayout + # for each page are working together. def __init__(self, - *args, + *, pageNumber: t.Optional[int] = None, leftMargin: t.Union[int, float, None] = None, rightMargin: t.Union[int, float, None] = None, @@ -278,9 +272,8 @@ class SystemLayout(LayoutBase): >>> sl.isNew True ''' - def __init__(self, - *args, + *, leftMargin: t.Union[int, float, None] = None, rightMargin: t.Union[int, float, None] = None, distance: t.Union[int, float, None] = None, @@ -365,7 +358,7 @@ class StaffLayout(LayoutBase): ''', } def __init__(self, - *args, + *, distance: t.Union[int, float, None] = None, staffNumber: t.Union[int, float, None] = None, staffSize: t.Union[int, float, None] = None, @@ -432,13 +425,13 @@ class StaffGroup(spanner.Spanner): :width: 400 ''' def __init__(self, - *arguments, + *spannedElements, name: t.Optional[str] = None, barTogether: t.Literal[True, False, None, 'Mensurstrich'] = True, abbreviation: t.Optional[str] = None, symbol: t.Literal['bracket', 'line', 'grace', 'square'] = None, **keywords): - super().__init__(*arguments, **keywords) + super().__init__(*spannedElements, **keywords) self.name = name or abbreviation # if this group has a name self.abbreviation = abbreviation @@ -754,8 +747,8 @@ class LayoutScore(stream.Opus): it is much faster as it uses a cache. ''' - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) + def __init__(self, givenElements=None, **keywords): + super().__init__(givenElements, **keywords) self.scoreLayout = None self.measureStart = None self.measureEnd = None @@ -1514,8 +1507,8 @@ class Page(stream.Opus): belongs on a single notated page. ''' - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) + def __init__(self, givenElements=None, **keywords): + super().__init__(givenElements, **keywords) self.pageNumber = 1 self.measureStart = None self.measureEnd = None @@ -1553,8 +1546,8 @@ class System(stream.Score): Attribute systemNumbering says at what point the numbering of systems resets. It can be either "Score" (default), "Opus", or "Page". ''' - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) + def __init__(self, givenElements=None, **keywords): + super().__init__(givenElements, **keywords) self.systemNumber = 0 self.pageNumber = 0 @@ -1579,8 +1572,8 @@ class Staff(stream.Part): belongs on a single Staff. ''' - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) + def __init__(self, givenElements=None, **keywords): + super().__init__(givenElements, **keywords) self.staffNumber = 1 # number in this system NOT GLOBAL self.scoreStaffNumber = 0 @@ -1686,5 +1679,3 @@ def testGetStaffLayoutFromStaff(self): if __name__ == '__main__': import music21 music21.mainTest(Test) # , runTest='getStaffLayoutFromStaff') - - diff --git a/music21/metadata/__init__.py b/music21/metadata/__init__.py index ba18e56c7e..1e905a1fb0 100755 --- a/music21/metadata/__init__.py +++ b/music21/metadata/__init__.py @@ -236,21 +236,27 @@ class Metadata(base.Music21Object): # INITIALIZER # - def __init__(self, *args, **keywords): - super().__init__() - - self._contents: t.Dict[str, t.List[ValueType]] = {} - - # TODO: check pickling, etc. + def __init__(self, **keywords): + m21BaseKeywords = {} + myKeywords = {} # We allow the setting of metadata values (attribute-style) via **keywords. # Any keywords that are uniqueNames, grandfathered workIds, or grandfathered # workId abbreviations can be set this way. - for attr in keywords: + for attr, value in keywords.items(): if attr in properties.ALL_LEGAL_ATTRIBUTES: - setattr(self, attr, keywords[attr]) + myKeywords[attr] = value + else: + m21BaseKeywords[attr] = value + + super().__init__(**m21BaseKeywords) + self._contents: t.Dict[str, t.List[ValueType]] = {} + + for attr, value in myKeywords.items(): + setattr(self, attr, value) self['software'] = [defaults.software] + # TODO: check pickling, etc. # ----------------------------------------------------------------------------- # Public APIs @@ -2402,8 +2408,8 @@ class RichMetadata(Metadata): # INITIALIZER # - def __init__(self, *args, **keywords): - super().__init__(*args, **keywords) + def __init__(self, **keywords): + super().__init__(**keywords) self.ambitus = None self.keySignatureFirst = None self.keySignatures = [] diff --git a/music21/metadata/primitives.py b/music21/metadata/primitives.py index d3bbc1deee..f347fd3eac 100644 --- a/music21/metadata/primitives.py +++ b/music21/metadata/primitives.py @@ -73,7 +73,6 @@ class Date(prebase.ProtoM21Object): >>> a = metadata.Date(year='1843?') >>> a.yearError 'uncertain' - ''' # CLASS VARIABLES # @@ -84,7 +83,7 @@ class Date(prebase.ProtoM21Object): # INITIALIZER # - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.year = None self.month = None self.day = None @@ -1009,7 +1008,7 @@ class Contributor(prebase.ProtoM21Object): # INITIALIZER # def __init__(self, - *args, + *, name: t.Union[str, Text, None] = None, names: t.Iterable[t.Union[str, Text]] = (), role: t.Union[str, Text, None] = None, @@ -1349,8 +1348,7 @@ class Imprint(prebase.ProtoM21Object): r''' An object representation of imprint, or publication. ''' - def __init__(self, *args, **keywords): - self.args = args + def __init__(self, **keywords): self.keywords = keywords # !!!PUB: Publication status. diff --git a/music21/note.py b/music21/note.py index b56cbdf856..a38d751ab0 100644 --- a/music21/note.py +++ b/music21/note.py @@ -36,7 +36,7 @@ from music21 import style from music21 import tie from music21 import volume -from music21.common.types import StepName +from music21.common.types import StepName, OffsetQLIn from music21 import environment environLocal = environment.Environment('note') @@ -542,7 +542,6 @@ class GeneralNote(base.Music21Object): objects directly, and not use this underlying structure. - >>> gn = note.GeneralNote(type='16th', dots=2) >>> gn.quarterLength 0.4375 @@ -566,13 +565,13 @@ class GeneralNote(base.Music21Object): } def __init__(self, - *arguments, + *, duration: t.Optional[Duration] = None, lyric: t.Union[None, str, Lyric] = None, **keywords ): if duration is None: - # ensure music21base not automatically create a duration. + # ensure music21base not automatically create a zero duration before we can. if not keywords or ('type' not in keywords and 'quarterLength' not in keywords): tempDuration = Duration(1.0) else: @@ -973,7 +972,6 @@ class NotRest(GeneralNote): } def __init__(self, - *arguments, beams: t.Optional[beam.Beams] = None, **keywords): super().__init__(**keywords) @@ -1898,7 +1896,6 @@ class Rest(GeneralNote): However, the property :attr:`~music21.stream.Stream.notesAndRests` of Streams gets rests as well. - >>> r = note.Rest() >>> r.isRest True @@ -1924,6 +1921,14 @@ class Rest(GeneralNote): >>> r2 = note.Rest(type='whole') >>> r2.duration.quarterLength 4.0 + + Or they can just be specified in without a type, and they'll be evaluated automatically + + >>> r3, r4 = note.Rest('half'), note.Rest(2.0) + >>> r3 == r4 + True + >>> r3.duration.quarterLength + 2.0 ''' isRest = True name = 'rest' @@ -1945,8 +1950,6 @@ class Rest(GeneralNote): update automatically to match the time signature context; and is True. Does not work yet -- functions as True. - # TODO: get it to work. - "auto" is the default, where if the rest value happens to match the current time signature context, then display it as a whole rest, centered, etc. otherwise will display normally. @@ -1955,10 +1958,21 @@ class Rest(GeneralNote): ''', } - def __init__(self, *arguments, **keywords): + def __init__(self, + length: t.Union[str, OffsetQLIn, None] = None, + *, + stepShift: int = 0, + fullMeasure: t.Literal[True, False, 'auto', 'always'] = 'auto', + **keywords): + if length is not None: + if isinstance(length, str) and 'type' not in keywords: + keywords['type'] = length + elif 'quarterLength' not in keywords: + keywords['quarterLength'] = length super().__init__(**keywords) - self.stepShift = 0 # display line - self.fullMeasure = 'auto' # see docs; True, False, 'always', + self.stepShift = stepShift # display line + # TODO: fullMeasure=='always' does not work properly + self.fullMeasure = fullMeasure # see docs; True, False, 'always', def _reprInternal(self): duration_name = self.duration.fullName.lower() @@ -1976,7 +1990,6 @@ def __eq__(self, other): A Music21 rest is equal to another object if that object is also a rest which has the same duration. - >>> r1 = note.Rest() >>> r2 = note.Rest() >>> r1 == r2 @@ -1984,7 +1997,7 @@ def __eq__(self, other): >>> r1 != r2 False - >>> r2.duration.quarterLength = 4.0/3 + >>> r2.duration.quarterLength = 4/3 >>> r1 == r2 False >>> r1 == note.Note() @@ -2424,4 +2437,3 @@ def testVolumeB(self): # sys.arg test options will be used in mainTest() import music21 music21.mainTest(Test) - diff --git a/music21/noteworthy/binaryTranslate.py b/music21/noteworthy/binaryTranslate.py index 33ab51c832..b26401006b 100644 --- a/music21/noteworthy/binaryTranslate.py +++ b/music21/noteworthy/binaryTranslate.py @@ -105,7 +105,7 @@ class NWCConverter: >>> nwcc.staves [] ''' - def __init__(self, *args, **keywords): + def __init__(self, **keywords): self.fileContents = None self.parsePosition = 0 self.version = 200 diff --git a/music21/pitch.py b/music21/pitch.py index 864ddc1b62..04f23f606b 100644 --- a/music21/pitch.py +++ b/music21/pitch.py @@ -4116,7 +4116,6 @@ def getEnharmonic(self: PitchType, *, inPlace=False) -> t.Optional[PitchType]: However, isEnharmonic() for A## and B certainly returns True. - >>> p = pitch.Pitch('d#') >>> print(p.getEnharmonic()) E- @@ -4178,6 +4177,7 @@ def getEnharmonic(self: PitchType, *, inPlace=False) -> t.Optional[PitchType]: post.getHigherEnharmonic(inPlace=True) if inPlace: + self.informClient() return None else: return post diff --git a/music21/scale/intervalNetwork.py b/music21/scale/intervalNetwork.py index dfe6cb02af..00c4e4bbe0 100644 --- a/music21/scale/intervalNetwork.py +++ b/music21/scale/intervalNetwork.py @@ -975,7 +975,7 @@ def nodeIdToEdgeDirections(self, nId): raise IntervalNetworkException('failed to match any edges', nObj) return collection - def degreeModulus(self, degree): + def degreeModulus(self, degree: int) -> int: ''' Return the degree modulus degreeMax - degreeMin. @@ -1009,6 +1009,7 @@ def degreeModulus(self, degree): def nodeNameToNodes(self, nodeId: t.Union[Node, int, Terminus, None], + *, equateTermini=True, permitDegreeModuli=True): ''' @@ -1131,7 +1132,12 @@ def getNext(self, nodeStart, direction): postNode = [self.nodes[nId] for nId in postNodeId] return postEdge, postNode - def processAlteredNodes(self, alteredDegrees, n, p, direction): + def processAlteredNodes(self, + alteredDegrees, + n, + p, + *, + direction): ''' Return an altered pitch for given node, if an alteration is specified in the alteredDegrees dictionary @@ -1173,6 +1179,7 @@ def getUnalteredPitch( self, pitchObj, nodeObj, + *, direction=Direction.BI, alteredDegrees=None ) -> pitch.Pitch: @@ -1196,6 +1203,7 @@ def nextPitch( pitchReference: t.Union[pitch.Pitch, str], nodeName: t.Union[Node, int, Terminus, None], pitchOrigin: t.Union[pitch.Pitch, str], + *, direction: Direction = Direction.ASCENDING, stepSize=1, alteredDegrees=None, @@ -1208,23 +1216,35 @@ def nextPitch( The `nodeName` parameter may be a :class:`~music21.scale.intervalNetwork.Node` object, a node degree, a Terminus Enum, or a None (indicating Terminus.LOW). - The `stepSize` parameter can be configured to permit different sized steps - in the specified direction. >>> edgeList = ['M2', 'M2', 'm2', 'M2', 'M2', 'M2', 'm2'] >>> net = scale.intervalNetwork.IntervalNetwork() >>> net.fillBiDirectedEdges(edgeList) - >>> net.nextPitch('g', 1, 'f#5', scale.Direction.ASCENDING) + >>> net.nextPitch('g', 1, 'f#5', direction=scale.Direction.ASCENDING) - >>> net.nextPitch('g', 1, 'f#5', scale.Direction.DESCENDING) + >>> net.nextPitch('g', 1, 'f#5', direction=scale.Direction.DESCENDING) - >>> net.nextPitch('g', 1, 'f#5', scale.Direction.ASCENDING, 2) # two steps + + The `stepSize` parameter can be configured to permit different sized steps + in the specified direction. + + >>> net.nextPitch('g', 1, 'f#5', + ... direction=scale.Direction.ASCENDING, + ... stepSize=2) + + Altered degrees can be given to temporarily change the pitches returned + without affecting the network as a whole. + >>> alteredDegrees = {2: {'direction': scale.Direction.BI, ... 'interval': interval.Interval('-a1')}} - >>> net.nextPitch('g', 1, 'g2', scale.Direction.ASCENDING, alteredDegrees=alteredDegrees) + >>> net.nextPitch('g', 1, 'g2', + ... direction=scale.Direction.ASCENDING, + ... alteredDegrees=alteredDegrees) - >>> net.nextPitch('g', 1, 'a-2', scale.Direction.ASCENDING, alteredDegrees=alteredDegrees) + >>> net.nextPitch('g', 1, 'a-2', + ... direction=scale.Direction.ASCENDING, + ... alteredDegrees=alteredDegrees) ''' if pitchOrigin is None: @@ -1341,6 +1361,7 @@ def _getCacheKey( pitchReference: pitch.Pitch, minPitch: t.Optional[pitch.Pitch], maxPitch: t.Optional[pitch.Pitch], + *, includeFirst: bool, reverse: t.Optional[bool] = None, # only meaningful for descending ) -> CacheKey: @@ -1370,6 +1391,7 @@ def realizeAscending( nodeId: t.Union[Node, int, Terminus, None] = None, minPitch: t.Union[pitch.Pitch, str, None] = None, maxPitch: t.Union[pitch.Pitch, str, None] = None, + *, alteredDegrees=None, fillMinMaxIfNone=False ) -> t.Tuple[t.List[pitch.Pitch], t.List[t.Union[Terminus, int]]]: @@ -1534,6 +1556,7 @@ def realizeDescending( nodeId: t.Union[Node, int, Terminus, None] = None, minPitch: t.Union[pitch.Pitch, str, None] = None, maxPitch: t.Union[pitch.Pitch, str, None] = None, + *, alteredDegrees=None, includeFirst=False, fillMinMaxIfNone=False, @@ -1637,10 +1660,10 @@ def realizeDescending( if self.deterministic: ck = self._getCacheKey(nodeObj, pitchRef, - minPitchObj, - maxPitchObj, - includeFirst, - reverse, + minPitch=minPitchObj, + maxPitch=maxPitchObj, + includeFirst=includeFirst, + reverse=reverse, ) if ck in self._descendingCache: return self._descendingCache[ck] @@ -2307,7 +2330,6 @@ def sortTerminusLowThenIntThenTerminusHigh(a): return g def plot(self, - *args, **keywords): ''' Given a method and keyword configuration arguments, create and display a plot. @@ -2336,6 +2358,7 @@ def getRelativeNodeId( pitchReference: t.Union[pitch.Pitch, str], nodeId: t.Union[Node, int, Terminus, None], pitchTarget: t.Union[pitch.Pitch, note.Note, str], + *, comparisonAttribute: str = 'ps', direction: Direction = Direction.ASCENDING, alteredDegrees=None @@ -2364,9 +2387,9 @@ def getRelativeNodeId( 0 >>> net.getRelativeNodeId('a', 1, 'c#4') 1 - >>> net.getRelativeNodeId('a', 1, 'c4', comparisonAttribute = 'step') + >>> net.getRelativeNodeId('a', 1, 'c4', comparisonAttribute='step') 1 - >>> net.getRelativeNodeId('a', 1, 'c', comparisonAttribute = 'step') + >>> net.getRelativeNodeId('a', 1, 'c', comparisonAttribute='step') 1 >>> net.getRelativeNodeId('a', 1, 'b-4') is None True diff --git a/music21/scale/test_intervalNetwork.py b/music21/scale/test_intervalNetwork.py index ec509fdbdf..2ebeaabcde 100644 --- a/music21/scale/test_intervalNetwork.py +++ b/music21/scale/test_intervalNetwork.py @@ -500,19 +500,31 @@ def testNextPitch(self): net.fillMelodicMinor() # ascending from known pitches - self.assertEqual(str(net.nextPitch('c4', 1, 'g4', Direction.ASCENDING)), 'A4') - self.assertEqual(str(net.nextPitch('c4', 1, 'a4', Direction.ASCENDING)), 'B4') - self.assertEqual(str(net.nextPitch('c4', 1, 'b4', Direction.ASCENDING)), 'C5') + self.assertEqual(str(net.nextPitch('c4', 1, 'g4', direction=Direction.ASCENDING)), + 'A4') + self.assertEqual(str(net.nextPitch('c4', 1, 'a4', direction=Direction.ASCENDING)), + 'B4') + self.assertEqual(str(net.nextPitch('c4', 1, 'b4', direction=Direction.ASCENDING)), + 'C5') # descending - self.assertEqual(str(net.nextPitch('c4', 1, 'c5', Direction.DESCENDING)), 'B-4') - self.assertEqual(str(net.nextPitch('c4', 1, 'b-4', Direction.DESCENDING)), 'A-4') - self.assertEqual(str(net.nextPitch('c4', 1, 'a-4', Direction.DESCENDING)), 'G4') + self.assertEqual(str(net.nextPitch('c4', 1, 'c5', direction=Direction.DESCENDING)), + 'B-4') + self.assertEqual(str(net.nextPitch('c4', 1, 'b-4', direction=Direction.DESCENDING)), + 'A-4') + self.assertEqual(str(net.nextPitch('c4', 1, 'a-4', + direction=Direction.DESCENDING)), + 'G4') # larger degree sizes - self.assertEqual(str(net.nextPitch('c4', 1, 'c5', Direction.DESCENDING, stepSize=2)), + self.assertEqual(str(net.nextPitch('c4', 1, 'c5', + direction=Direction.DESCENDING, + stepSize=2)), 'A-4') - self.assertEqual(str(net.nextPitch('c4', 1, 'a4', Direction.ASCENDING, stepSize=2)), 'C5') + self.assertEqual(str(net.nextPitch('c4', 1, 'a4', + direction=Direction.ASCENDING, + stepSize=2)), + 'C5') # moving from a non-scale degree @@ -520,34 +532,41 @@ def testNextPitch(self): self.assertEqual( str( net.nextPitch( - 'c4', 1, 'c#4', Direction.ASCENDING, getNeighbor=Direction.ASCENDING + 'c4', 1, 'c#4', + direction=Direction.ASCENDING, + getNeighbor=Direction.ASCENDING ) ), 'E-4' ) # if we get the descending neighbor, we move from c to d - self.assertEqual(str(net.nextPitch('c4', 1, 'c#4', Direction.ASCENDING, + self.assertEqual(str(net.nextPitch('c4', 1, 'c#4', + direction=Direction.ASCENDING, getNeighbor=Direction.DESCENDING)), 'D4') # if on a- and get ascending neighbor, move from a to b- - self.assertEqual(str(net.nextPitch('c4', 1, 'a-', Direction.ASCENDING, + self.assertEqual(str(net.nextPitch('c4', 1, 'a-', + direction=Direction.ASCENDING, getNeighbor=Direction.ASCENDING)), 'B4') # if on a- and get descending neighbor, move from g to a - self.assertEqual(str(net.nextPitch('c4', 1, 'a-', Direction.ASCENDING, + self.assertEqual(str(net.nextPitch('c4', 1, 'a-', + direction=Direction.ASCENDING, getNeighbor=Direction.DESCENDING)), 'A4') # if on b, ascending neighbor, move from c to b- - self.assertEqual(str(net.nextPitch('c4', 1, 'b3', Direction.DESCENDING, + self.assertEqual(str(net.nextPitch('c4', 1, 'b3', + direction=Direction.DESCENDING, getNeighbor=Direction.ASCENDING)), 'B-3') # if on c-4, use mode derivation instead of neighbor, move from b4 to c4 - self.assertEqual(str(net.nextPitch('c4', 1, 'c-4', Direction.ASCENDING)), + self.assertEqual(str(net.nextPitch('c4', 1, 'c-4', + direction=Direction.ASCENDING)), 'C4') self.assertEqual( @@ -565,8 +584,13 @@ def testNextPitch(self): (6, Terminus.HIGH) ) - self.assertEqual(net.getNeighborNodeIds( - pitchReference='c4', nodeName=1, pitchTarget='b-'), (4, 6)) + self.assertEqual( + net.getNeighborNodeIds( + pitchReference='c4', + nodeName=1, + pitchTarget='b-'), + (4, 6) + ) self.assertEqual( net.getNeighborNodeIds( @@ -590,7 +614,7 @@ def testNextPitch(self): 'c4', 1, 'b4', - Direction.DESCENDING, + direction=Direction.DESCENDING, getNeighbor=Direction.DESCENDING)), 'A-4') diff --git a/music21/search/segment.py b/music21/search/segment.py index 64a0bee4a1..5318af7ae8 100644 --- a/music21/search/segment.py +++ b/music21/search/segment.py @@ -45,6 +45,7 @@ # noinspection SpellCheckingInspection def translateMonophonicPartToSegments( inputStream, + *, segmentLengths=30, overlap=12, algorithm=None, @@ -113,7 +114,7 @@ def translateMonophonicPartToSegments( # noinspection SpellCheckingInspection -def indexScoreParts(scoreFile, *args, **keywords): +def indexScoreParts(scoreFile, **keywords): r''' Creates segment and measure lists for each part of a score Returns list of dictionaries of segment and measure lists @@ -129,7 +130,7 @@ def indexScoreParts(scoreFile, *args, **keywords): indexedList = [] for part in scoreFileParts: segmentList, measureList = translateMonophonicPartToSegments( - part, *args, **keywords) + part, **keywords) indexedList.append({ 'segmentList': segmentList, 'measureList': measureList, @@ -137,7 +138,7 @@ def indexScoreParts(scoreFile, *args, **keywords): return indexedList -def _indexSingleMulticore(filePath, *args, failFast=False, **keywords): +def _indexSingleMulticore(filePath, failFast=False, **keywords): ''' Index one path in the context of multicore. ''' @@ -147,7 +148,7 @@ def _indexSingleMulticore(filePath, *args, failFast=False, **keywords): shortFp = filePath.name try: - indexOutput = indexOnePath(filePath, *args, **keywords) + indexOutput = indexOnePath(filePath, **keywords) except Exception as e: # pylint: disable=broad-except if not failFast: print(f'Failed on parse/index for, {filePath}: {e}') @@ -163,8 +164,8 @@ def _giveUpdatesMulticore(numRun, totalRun, latestOutput): # noinspection SpellCheckingInspection def indexScoreFilePaths(scoreFilePaths, + *, giveUpdates=False, - *args, runMulticore=True, **keywords): # noinspection PyShadowingNames @@ -193,7 +194,7 @@ def indexScoreFilePaths(scoreFilePaths, else: updateFunction = None - indexFunc = partial(_indexSingleMulticore, *args, **keywords) + indexFunc = partial(_indexSingleMulticore, **keywords) for i in range(len(scoreFilePaths)): if not isinstance(scoreFilePaths[i], pathlib.Path): @@ -224,7 +225,7 @@ def indexScoreFilePaths(scoreFilePaths, return scoreDict -def indexOnePath(filePath, *args, **keywords): +def indexOnePath(filePath, **keywords): ''' Index a single path. Returns a scoreDictEntry ''' @@ -236,7 +237,7 @@ def indexOnePath(filePath, *args, **keywords): else: scoreObj = converter.parse(filePath) - scoreDictEntry = indexScoreParts(scoreObj, *args, **keywords) + scoreDictEntry = indexScoreParts(scoreObj, **keywords) return scoreDictEntry @@ -404,4 +405,3 @@ def doOneSegment(thisSegment): if __name__ == '__main__': import music21 music21.mainTest() - diff --git a/music21/serial.py b/music21/serial.py index 3a2f75794f..9aefc2d5aa 100644 --- a/music21/serial.py +++ b/music21/serial.py @@ -290,8 +290,8 @@ class ToneRow(stream.Stream): 'zeroCenteredTransformation', 'originalCenteredTransformation', 'findZeroCenteredTransformations', 'findOriginalCenteredTransformations'] - def __init__(self, row=None, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, row=None, **keywords): + super().__init__(**keywords) if row is not None: self.row = row else: @@ -666,23 +666,9 @@ class TwelveToneRow(ToneRow): ''' A Stream representation of a twelve-tone row, capable of producing a 12-tone matrix. ''' - # row = None - - # _DOC_ATTR: t.Dict[str, str] = { - # 'row': 'A list representing the pitch class values of the row.', - # } - _DOC_ORDER = ['matrix', 'isAllInterval', 'getLinkClassification', 'isLinkChord', 'areCombinatorial'] - # def __init__(self, *arguments, **keywords): - # super().__init__(*arguments, **keywords) - # # environLocal.printDebug(['TwelveToneRow.__init__: length of elements', len(self)]) - # - # # if self.row != None: - # # for pc in self.row: - # # self.append(pitch.Pitch(pc)) - def matrix(self): # noinspection PyShadowingNames ''' @@ -1110,8 +1096,9 @@ def __init__(self, composer: t.Union[None, str] = None, opus: t.Union[None, str] = None, title: t.Union[None, str] = None, - row=None): - super().__init__(row) + row=None, + **keywords): + super().__init__(row, **keywords) self.composer = composer self.opus = opus self.title = title diff --git a/music21/spanner.py b/music21/spanner.py index 28fb4c4678..f844eafb7c 100644 --- a/music21/spanner.py +++ b/music21/spanner.py @@ -64,7 +64,6 @@ class Spanner(base.Music21Object): as Elliott Carter uses in his second string quartet (he marks them with an arrow). - >>> class CarterAccelerandoSign(spanner.Spanner): ... pass >>> n1 = note.Note('C4') @@ -98,7 +97,6 @@ class Spanner(base.Music21Object): - (2) we can get a stream of spanners (equiv. to getElementsByClass(spanner.Spanner)) by calling the .spanner property on the stream. @@ -107,7 +105,6 @@ class Spanner(base.Music21Object): ... print(thisSpanner) > - (3) we can get the spanner by looking at the list getSpannerSites() on any object that has a spanner: @@ -176,23 +173,21 @@ class Spanner(base.Music21Object): (the Carter example would not print an arrow since that element has no corresponding musicxml representation). - - Implementation notes: + *Implementation notes:* The elements that are included in a spanner are stored in a Stream subclass called :class:`~music21.stream.SpannerStorage` found as the `.spannerStorage` attribute. That Stream has an - attribute called `spannerParent` which links to the original spanner. + attribute called `client` which links to the original spanner. Thus, `spannerStorage` is smart enough to know where it's stored, but it makes deleting/garbage-collecting a spanner a tricky operation: Ex. Prove that the spannedElement Stream is linked to container via - `spannerParent`: + `client`: - >>> sp1.spannerStorage.spannerParent is sp1 + >>> sp1.spannerStorage.client is sp1 True - Spanners have a `.completeStatus` attribute which can be used to find out if all spanned elements have been added yet. It's up to the processing agent to set this, but it could be useful in deciding where to append a spanner. @@ -205,8 +200,11 @@ class Spanner(base.Music21Object): >>> sp1.completeStatus = True ''' - def __init__(self, *arguments, **keywords): - super().__init__() + def __init__(self, + *spannedElements: t.Union[base.Music21Object, + t.Sequence[base.Music21Object]], + **keywords): + super().__init__(**keywords) # store a Stream inside of Spanner from music21 import stream @@ -216,7 +214,7 @@ def __init__(self, *arguments, **keywords): # directly # TODO: Move here! along with VariantStorage to variant. - self.spannerStorage = stream.SpannerStorage(spannerParent=self) + self.spannerStorage = stream.SpannerStorage(client=self) # we do not want to auto sort based on offset or class, as # both are meaningless inside this Stream (and only have meaning @@ -224,17 +222,13 @@ def __init__(self, *arguments, **keywords): self.spannerStorage.autoSort = False # add arguments as a list or single item - proc = [] - for arg in arguments: - if common.isListLike(arg): - proc += arg - else: - proc.append(arg) + proc: t.List[base.Music21Object] = [] + for spannedElement in spannedElements: + if isinstance(spannedElement, base.Music21Object): + proc.append(spannedElement) + elif spannedElement is not None: + proc += spannedElement self.addSpannedElements(proc) - # if len(arguments) > 1: - # self.spannerStorage.append(arguments) - # elif len(arguments) == 1: # assume a list is first arg - # self.spannerStorage.append(c) # parameters that spanners need in loading and processing # local id is the id for the local area; used by musicxml @@ -412,8 +406,7 @@ def addSpannedElements( self, spannedElements: t.Union[t.Sequence[base.Music21Object], base.Music21Object], - *arguments, - **keywords + *otherElements: base.Music21Object, ): ''' Associate one or more elements with this Spanner. @@ -438,11 +431,11 @@ def addSpannedElements( # add mypy disables because isListLike() performs type-narrowing if not common.isListLike(spannedElements): spannedElements = [spannedElements] # type: ignore[list-item] - if arguments: + if otherElements: # copy spannedElements = spannedElements[:] # type: ignore[index] - # assume all other arguments are spanners - spannedElements += arguments # type: ignore[operator] + # assume all other arguments are music21 objects + spannedElements += otherElements # type: ignore[operator] for c in spannedElements: # type: ignore[union-attr] if c is None: continue @@ -618,7 +611,7 @@ class SpannerBundle(prebase.ProtoM21Object): ''' An advanced utility object for collecting and processing collections of Spanner objects. This is necessary because - often processing routines that happen at many different + often processing routines that happen at many levels still need access to the same collection of spanners. Because SpannerBundles are so commonly used with @@ -928,7 +921,7 @@ def setIdLocalByClass(self, className, maxId=6): The `maxId` parameter sets the largest number that is available for this class. In MusicXML it is 6. - Currently this method just iterates over the spanners of this class + Currently, this method just iterates over the spanners of this class and counts the number from 1-6 and then recycles numbers. It does not check whether more than 6 overlapping spanners of the same type exist, nor does it reset the count to 1 after all spanners of that @@ -1131,8 +1124,8 @@ class Slur(Spanner): Slurs have `.placement` options ('above' or 'below') and `.lineType` ('dashed' or None) ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self.placement = None # can above or below, after musicxml self.lineType = None # can be 'dashed' or None @@ -1169,8 +1162,8 @@ class MultiMeasureRest(Spanner): ''', } - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, *spannedElements, **keywords): + super().__init__(*spannedElements, **keywords) self._overriddenNumber = None self.useSymbols = keywords.get('useSymbols', defaults.multiMeasureRestUseSymbols) self.maxSymbols = keywords.get('maxSymbols', defaults.multiMeasureRestMaxSymbols) @@ -1281,11 +1274,11 @@ class RepeatBracket(Spanner): '1, 2, 3, 7' ''' def __init__(self, - *arguments, + *spannedElements, number: t.Optional[int] = None, overrideDisplay: t.Optional[str] = None, **keywords): - super().__init__(*arguments, **keywords) + super().__init__(*spannedElements, **keywords) self._number: t.Optional[int] = None # store a range, inclusive of the single number assignment @@ -1479,12 +1472,12 @@ class Ottava(Spanner): validOttavaTypes = ('8va', '8vb', '15ma', '15mb', '22da', '22db') def __init__(self, - *arguments, + *spannedElements, type: str = '8va', # pylint: disable=redefined-builtin transposing: bool = True, placement: t.Literal['above', 'below'] = 'above', **keywords): - super().__init__(*arguments, **keywords) + super().__init__(*spannedElements, **keywords) self._type = None # can be 8va, 8vb, 15ma, 15mb self.type = type @@ -1676,7 +1669,7 @@ class Line(Spanner): def __init__( self, - *arguments, + *spannedElements, lineType: str = 'solid', tick: str = 'down', startTick: str = 'down', @@ -1685,7 +1678,7 @@ def __init__( endHeight: t.Optional[t.Union[int, float]] = None, **keywords ): - super().__init__(*arguments, **keywords) + super().__init__(*spannedElements, **keywords) DEFAULT_TICK = 'down' self._endTick = DEFAULT_TICK # can ne up/down/arrow/both/None @@ -1840,19 +1833,19 @@ class Glissando(Spanner): validSlideTypes = ('chromatic', 'continuous', 'diatonic', 'white', 'black') def __init__(self, - *arguments, + *spannedElements, lineType: str = 'wavy', label: t.Optional[str] = None, **keywords): - super().__init__(*arguments, **keywords) + super().__init__(*spannedElements, **keywords) - GLISSANDO_DEFAULT_LINETYPE = 'wavy' - self._lineType = GLISSANDO_DEFAULT_LINETYPE + GLISSANDO_DEFAULT_LINE_TYPE = 'wavy' + self._lineType = GLISSANDO_DEFAULT_LINE_TYPE self._slideType = 'chromatic' self.label = None - if lineType != GLISSANDO_DEFAULT_LINETYPE: + if lineType != GLISSANDO_DEFAULT_LINE_TYPE: self.lineType = lineType # use property if label is not None: self.label = label # use property @@ -2773,5 +2766,3 @@ def testGetSpannedElementIds(self): if __name__ == '__main__': import music21 music21.mainTest(Test) - - diff --git a/music21/stream/base.py b/music21/stream/base.py index e4d302a7a7..d4246be25d 100644 --- a/music21/stream/base.py +++ b/music21/stream/base.py @@ -245,7 +245,7 @@ class Stream(core.StreamCore, t.Generic[M21ObjType]): be allowed, because craziness and givenElements are required:: class CrazyStream(Stream): - def __init__(self, givenElements, craziness, *args, **keywords): + def __init__(self, givenElements, craziness, **keywords): ... New in v.7 -- smart appending @@ -312,11 +312,11 @@ def __init__(self, givenElements: t.Union[None, base.Music21Object, t.Sequence[base.Music21Object]] = None, - *arguments, + *, appendOrInsert: t.Literal['append', 'insert', 'offsets'] = 'offsets', **keywords): # restrictClass: t.Type[M21ObjType] = base.Music21Object, - super().__init__(self, *arguments, **keywords) + super().__init__(**keywords) self.streamStatus = streamStatus.StreamStatus(self) self._unlinkedDuration = None @@ -3322,7 +3322,12 @@ def _reprTextLine(self, *, addEndTimes=False, useMixedNumerals=False) -> str: # -------------------------------------------------------------------------- # display methods; in the same manner as show() and write() - def plot(self, *args, **keywords): + def plot(self, + plotFormat: str, + xValue: t.Optional[str] = None, + yValue: t.Optional[str] = None, + zValue: t.Optional[str] = None, + **keywords): ''' Given a method and keyword configuration arguments, create and display a plot. @@ -3343,9 +3348,14 @@ def plot(self, *args, **keywords): # import is here to avoid import of matplotlib problems from music21 import graph # first ordered arg can be method type - return graph.plotStream(self, *args, **keywords) + return graph.plotStream(self, + plotFormat, + xValue=xValue, + yValue=yValue, + zValue=zValue, + **keywords) - def analyze(self, *args, **keywords): + def analyze(self, method: str, **keywords): ''' Runs a particular analytical method on the contents of the stream to find its ambitus (range) or key. @@ -3359,7 +3369,6 @@ def analyze(self, *args, **keywords): Example: - >>> s = corpus.parse('bach/bwv66.6') >>> s.analyze('ambitus') @@ -3409,7 +3418,7 @@ def analyze(self, *args, **keywords): from music21.analysis import discrete # pass this stream to the analysis procedure - return discrete.analyzeStream(self, *args, **keywords) + return discrete.analyzeStream(self, method, **keywords) # -------------------------------------------------------------------------- # methods that act on individual elements without requiring @@ -9936,19 +9945,67 @@ def pitches(self) -> t.List[pitch.Pitch]: # -------------------------------------------------------------------------- # interval routines + @overload + def findConsecutiveNotes( + self, + *, + skipRests: bool = False, + skipChords: t.Literal[False] = False, + skipUnisons: bool = False, + skipOctaves: bool = False, + skipGaps: bool = False, + getOverlaps: bool = False, + noNone: t.Literal[True], + **keywords + ) -> t.List[note.NotRest]: + return [] + + @overload + def findConsecutiveNotes( + self, + *, + skipRests: bool = False, + skipChords: t.Literal[True], + skipUnisons: bool = False, + skipOctaves: bool = False, + skipGaps: bool = False, + getOverlaps: bool = False, + noNone: t.Literal[True], + **keywords + ) -> t.List[note.Note]: + return [] + @overload def findConsecutiveNotes( self, *, - skipRests=False, - skipChords=False, - skipUnisons=False, - skipOctaves=False, - skipGaps=False, - getOverlaps=False, - noNone=False, + skipRests: bool = False, + skipChords: bool = False, + skipUnisons: bool = False, + skipOctaves: bool = False, + skipGaps: bool = False, + getOverlaps: bool = False, + noNone: t.Literal[False] = False, **keywords ) -> t.List[t.Union[note.NotRest, None]]: + return [] + + def findConsecutiveNotes( + self, + *, + skipRests: bool = False, + skipChords: bool = False, + skipUnisons: bool = False, + skipOctaves: bool = False, + skipGaps: bool = False, + getOverlaps: bool = False, + noNone: bool = False, + **keywords + ) -> t.Union[ + t.List[t.Union[note.NotRest, None]], + t.List[note.NotRest], + t.List[note.Note], + ]: r''' Returns a list of consecutive *pitched* Notes in a Stream. @@ -10093,7 +10150,7 @@ def findConsecutiveNotes( returnList.pop() # removes the last-added element return returnList - def melodicIntervals(self, *skipArgs, **skipKeywords): + def melodicIntervals(self, **skipKeywords): ''' Returns a Stream of :class:`~music21.interval.Interval` objects between Notes (and by default, Chords) that follow each other in a stream. @@ -10117,7 +10174,6 @@ def melodicIntervals(self, *skipArgs, **skipKeywords): Returns an empty Stream if there are not at least two elements found by findConsecutiveNotes. - >>> s1 = converter.parse("tinynotation: 3/4 c4 d' r b b'", makeNotation=False) >>> #_DOCS_SHOW s1.show() @@ -14214,16 +14270,15 @@ class SpannerStorage(Stream): object's .sites and find any and all locations that are SpannerStorage objects. - A `spannerParent` keyword argument must be - provided by the Spanner in creation. + A `client` keyword argument must be provided by the Spanner in creation. - TODO v7: rename spannerParent to client. + Changed in v8: spannerParent is renamed client. ''' - def __init__(self, *arguments, spannerParent=None, **keywords): + def __init__(self, givenElements=None, *, client: 'music21.spanner.Spanner', **keywords): # No longer need store as weakref since Py2.3 and better references - self.spannerParent = spannerParent - super().__init__(*arguments, **keywords) + self.client = client + super().__init__(givenElements, **keywords) # must provide a keyword argument with a reference to the spanner # parent could name spannerContainer or other? diff --git a/music21/stream/core.py b/music21/stream/core.py index 7df949c0fa..cd2e1bae3d 100644 --- a/music21/stream/core.py +++ b/music21/stream/core.py @@ -43,8 +43,8 @@ class StreamCore(Music21Object): Core aspects of a Stream's behavior. Any of these can change at any time. Users are encouraged only to create stream.Stream objects. ''' - def __init__(self, *arguments, **keywords): - super().__init__(*arguments, **keywords) + def __init__(self, **keywords): + super().__init__(**keywords) # hugely important -- keeps track of where the _elements are # the _offsetDict is a dictionary where id(element) is the # index and the value is a tuple of offset and element.