Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove *arguments where not used #1394

Merged
merged 37 commits into from
Aug 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e63e8ba
Explicit Keywords on all music21 objects
mscuthbert Aug 14, 2022
4a72f9f
Tuplet
mscuthbert Aug 14, 2022
6a1785d
few fixes. More needed
mscuthbert Aug 14, 2022
f902683
update some types
mscuthbert Aug 14, 2022
41b9bc2
lint,mypy,test
mscuthbert Aug 15, 2022
44aad43
note -- finished
mscuthbert Aug 15, 2022
89cfd1f
Stream; and fix previous typing
mscuthbert Aug 15, 2022
48958b1
fix mypy
mscuthbert Aug 15, 2022
db59588
fixup chordBase; lint
mscuthbert Aug 15, 2022
689e1ee
lint and mypy
mscuthbert Aug 15, 2022
81f3d5a
discrete analysis
mscuthbert Aug 15, 2022
3c92d8c
fix lints
mscuthbert Aug 16, 2022
6c4de9a
lint, mypy, flake
mscuthbert Aug 16, 2022
6723a1d
Variant takes only one arg
mscuthbert Aug 16, 2022
a627b56
kwargs -> keywords throughout
mscuthbert Aug 16, 2022
25228ea
midi realtime, etc.
mscuthbert Aug 16, 2022
a510697
lint, mypy
mscuthbert Aug 16, 2022
5a2ed20
Chorales, Date primitives, RepeatBracket
mscuthbert Aug 16, 2022
ba6f1e4
lint
mscuthbert Aug 16, 2022
38d103a
more metadata DatePrimitive work
mscuthbert Aug 16, 2022
dbeac11
layout. Remove chorales warnings; separate issue
mscuthbert Aug 16, 2022
29841b6
layout import annotations
mscuthbert Aug 16, 2022
5376b5a
Remove *arguments where not used
mscuthbert Aug 16, 2022
5327e26
fix substitution principle; sigh.
mscuthbert Aug 16, 2022
d2482fc
Remove more *args
mscuthbert Aug 16, 2022
ee330ba
fix metadata tests pinned to 8.0.0a9
mscuthbert Aug 16, 2022
20087f0
spanner star args
mscuthbert Aug 16, 2022
4cb3228
lint and flake
mscuthbert Aug 16, 2022
2377900
Merge branch 'explicit-keywords' into remove-star-args
mscuthbert Aug 16, 2022
5e78fde
fix all but bugs going other way
mscuthbert Aug 17, 2022
88978c6
Converting Interval to use Pitches not Note
mscuthbert Aug 17, 2022
ac2745b
Leave interval rewrite for another PR
mscuthbert Aug 17, 2022
fee7d88
Merge branch 'master' into remove-star-args
mscuthbert Aug 17, 2022
76de5fa
mypy, flake, lint
mscuthbert Aug 17, 2022
e8928cf
two more lints
mscuthbert Aug 17, 2022
90f481f
more mypy
mscuthbert Aug 18, 2022
31ac8f2
findConsecutiveNotes overload typing
mscuthbert Aug 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix all but bugs going other way
mscuthbert committed Aug 17, 2022
commit 5e78fde1fe9f08635e4f57668777931661dbf9b9
2 changes: 1 addition & 1 deletion music21/_version.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions music21/analysis/discrete.py
Original file line number Diff line number Diff line change
@@ -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

@@ -1326,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)

@@ -1338,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

@@ -1359,15 +1361,15 @@ def analysisClassFromMethodName(method: str):
>>> print(repr(acfmn('unknown-format')))
None
'''
analysisClasses = [
analysisClasses: t.List[t.Type[DiscreteAnalysis]] = [
Ambitus,
KrumhanslSchmuckler,
AardenEssen,
SimpleWeights,
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()
24 changes: 10 additions & 14 deletions music21/analysis/patel.py
Original file line number Diff line number Diff line change
@@ -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 '
8 changes: 4 additions & 4 deletions music21/analysis/reduction.py
Original file line number Diff line number Diff line change
@@ -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,
15 changes: 6 additions & 9 deletions music21/base.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
<class 'music21.base.Music21Object'>

>>> music21.VERSION_STR
'8.0.0a10'
'8.0.0a11'

Alternatively, after doing a complete import, these classes are available
under the module "base":
@@ -1160,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
@@ -2364,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)
@@ -2385,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
2 changes: 1 addition & 1 deletion music21/braille/segment.py
Original file line number Diff line number Diff line change
@@ -209,7 +209,7 @@ def __init__(self, *listElements):
>>> bg.numRepeats
0
'''
self.internalList = list(*listElement)
self.internalList = list(*listElements)
setGroupingGlobals()

self.keySignature = GROUPING_GLOBALS['keySignature']
2 changes: 2 additions & 0 deletions music21/chord/__init__.py
Original file line number Diff line number Diff line change
@@ -3597,6 +3597,8 @@ def isTriad(self) -> bool:
False

>>> incorrectlySpelled.pitches[1].getEnharmonic(inPlace=True)
>>> incorrectlySpelled
<music21.chord.Chord C E- G>
>>> incorrectlySpelled.isTriad()
True

35 changes: 18 additions & 17 deletions music21/common/decorators.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 5 additions & 8 deletions music21/common/stringTools.py
Original file line number Diff line number Diff line change
@@ -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
<BLANKLINE>
'''

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:
4 changes: 2 additions & 2 deletions music21/derivation.py
Original file line number Diff line number Diff line change
@@ -52,8 +52,8 @@ def derivationMethod(function):
<Derivation of <music21.note.Note D-> from <music21.note.Note C#> 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
Loading