Skip to content

Commit 47adf5a

Browse files
authored
Merge pull request #1821 from cuthbertLab/init_refactor
Refactor init / RichMD.scoreQuarterLength / rm networkX
2 parents 555f6b8 + 71475e1 commit 47adf5a

File tree

42 files changed

+483
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+483
-446
lines changed

music21/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
2121
The development of music21 was supported by grants
2222
from the Seaver Institute and the NEH/Digging into Data Challenge,
23-
with the support of the MIT
24-
Music and Theater Arts section and the School of Humanities, Arts,
25-
and Social Sciences. Portions of music21 were originally part of
26-
the PMusic (Perl) library, developed by Cuthbert prior to arriving at MIT.
23+
with the support of the MIT Music and Theater Arts section
24+
and the School of Humanities, Arts, and Social Sciences.
25+
Portions of music21 were originally part of the PMusic (Perl) library,
26+
developed by Cuthbert prior to arriving at MIT.
2727
2828
music21 outputs a subset of XML data defined by the MusicXML 4.0
2929
standard, Copyright © 2004-2022 W3C, open source.
@@ -35,7 +35,7 @@
3535

3636
import sys
3737

38-
minPythonVersion = (3, 10)
38+
minPythonVersion = (3, 11)
3939
minPythonVersionStr = '.'.join([str(x) for x in minPythonVersion])
4040
if sys.version_info < minPythonVersion:
4141
# DO NOT CHANGE THIS TO AN f-String -- it needs to run on old python.
@@ -48,6 +48,7 @@
4848
Use music21 v6.7 to run on Python 3.6.
4949
Use music21 v7.3 to run on Python 3.7
5050
Use music21 v8.1 to run on Python 3.8/3.9
51+
Use music21 v9.9 to run on Python 3.10.
5152
5253
If you have the wrong version there are several options for getting
5354
the right one.
@@ -273,4 +274,3 @@
273274
from music21 import voiceLeading # noqa: E402
274275
from music21 import volpiano # noqa: E402
275276
from music21 import volume # noqa: E402
276-

music21/abcFormat/__init__.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,35 @@
4848
from __future__ import annotations
4949

5050
__all__ = [
51-
'translate',
52-
'testFiles',
53-
'ABCTokenException', 'ABCHandlerException', 'ABCFileException',
51+
'ABCAccent',
52+
'ABCBar',
53+
'ABCBrokenRhythmMarker',
54+
'ABCChord',
55+
'ABCCrescStart',
56+
'ABCDimStart',
57+
'ABCDownbow',
58+
'ABCFile',
59+
'ABCFileException',
60+
'ABCGraceStart',
61+
'ABCGraceStop',
62+
'ABCHandler',
63+
'ABCHandlerBar',
64+
'ABCHandlerException',
65+
'ABCMetadata',
66+
'ABCNote',
67+
'ABCParenStop',
68+
'ABCSlurStart',
69+
'ABCStaccato',
70+
'ABCStraccent',
71+
'ABCTenuto',
72+
'ABCTie',
5473
'ABCToken',
55-
'ABCMetadata', 'ABCBar', 'ABCTuplet', 'ABCTie',
56-
'ABCSlurStart', 'ABCParenStop', 'ABCCrescStart', 'ABCDimStart',
57-
'ABCStaccato', 'ABCUpbow', 'ABCDownbow', 'ABCAccent', 'ABCStraccent',
58-
'ABCTenuto', 'ABCGraceStart', 'ABCGraceStop', 'ABCBrokenRhythmMarker',
59-
'ABCNote', 'ABCChord',
60-
'ABCHandler', 'ABCHandlerBar',
74+
'ABCTokenException',
75+
'ABCTuplet',
76+
'ABCUpbow',
6177
'mergeLeadingMetaData',
62-
'ABCFile',
78+
'testFiles',
79+
'translate',
6380
]
6481

6582
from collections.abc import Sequence

music21/analysis/__init__.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@
22
from __future__ import annotations
33

44
__all__ = [
5-
'correlate', 'discrete', 'elements', 'enharmonics',
6-
'floatingKey', 'harmonicFunction', 'metrical', 'neoRiemannian',
7-
'patel', 'pitchAnalysis',
8-
'reduceChords', 'reduceChordsOld', 'reduction', 'segmentByRests',
9-
'transposition', 'windowed',
105
'AnalysisException',
6+
'correlate',
7+
'discrete',
8+
'elements',
9+
'enharmonics',
10+
'floatingKey',
11+
'harmonicFunction',
12+
'metrical',
13+
'neoRiemannian',
14+
'patel',
15+
'pitchAnalysis',
16+
'reduceChords',
17+
'reduceChordsOld',
18+
'reduction',
19+
'segmentByRests',
20+
'transposition',
21+
'windowed',
1122
]
1223

1324
# this is necessary to get these names available with a

music21/audioSearch/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,26 @@
1919
from __future__ import annotations
2020

2121
__all__ = [
22-
'transcriber', 'recording', 'scoreFollower',
23-
'histogram', 'autocorrelationFunction',
24-
'prepareThresholds', 'interpolation',
25-
'normalizeInputFrequency', 'pitchFrequenciesToObjects',
26-
'getFrequenciesFromMicrophone',
22+
'AudioSearchException',
23+
'autocorrelationFunction',
24+
'decisionProcess',
25+
'detectPitchFrequencies',
2726
'getFrequenciesFromAudioFile',
27+
'getFrequenciesFromMicrophone',
2828
'getFrequenciesFromPartialAudioFile',
29-
'detectPitchFrequencies',
30-
'smoothFrequencies',
29+
'histogram',
30+
'interpolation',
3131
'joinConsecutiveIdenticalPitches',
32+
'normalizeInputFrequency',
33+
'notesAndDurationsToStream',
34+
'pitchFrequenciesToObjects',
35+
'prepareThresholds',
3236
'quantizeDuration',
3337
'quarterLengthEstimation',
34-
'notesAndDurationsToStream',
35-
'decisionProcess',
36-
'AudioSearchException',
38+
'recording',
39+
'scoreFollower',
40+
'smoothFrequencies',
41+
'transcriber',
3742
]
3843

3944
import copy

music21/beam.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ class Beams(prebase.ProtoM21Object, EqualSlottedObjectMixin):
219219

220220
# INITIALIZER #
221221

222-
def __init__(self):
222+
def __init__(self) -> None:
223223
# no need for super() call w/ ProtoM21 and EqualSlottedObject
224-
self.beamsList = []
225-
self.feathered = False
224+
self.beamsList: list[Beam] = []
225+
self.feathered: bool = False
226226

227227
# this should not be called .id.
228228
self.id = id(self)

music21/chord/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@
1515
'''
1616
from __future__ import annotations
1717

18-
__all__ = ['tools', 'tables', 'Chord', 'ChordException', 'fromIntervalVector', 'fromForteClass']
18+
__all__ = [
19+
'Chord',
20+
'ChordBase',
21+
'ChordException',
22+
'fromForteClass',
23+
'fromIntervalVector',
24+
'tables',
25+
'tools',
26+
]
1927

2028
from collections.abc import Iterable, Sequence
2129
import copy
2230
import typing as t
23-
from typing import overload # pycharm bug
31+
# pycharm bug - need to import overload separately. typing.overload doesn't work
32+
from typing import overload
2433
import unittest
2534

26-
from music21 import beam
2735
from music21 import common
2836
from music21.common.decorators import cacheMethod
2937
from music21 import derivation
@@ -42,7 +50,6 @@
4250

4351
if t.TYPE_CHECKING:
4452
from music21 import stream
45-
from music21.style import Style
4653

4754
environLocal = environment.Environment('chord')
4855

@@ -468,7 +475,7 @@ def volume(self) -> 'music21.volume.Volume': # do NOT change to volume.Volume,
468475

469476

470477
@volume.setter
471-
def volume(self, expr: None|'music21.volume.Volume'|int|float):
478+
def volume(self, expr: 'None|music21.volume.Volume|int|float'):
472479
# Do NOT change typing to volume.Volume w/o quotes because it will take the property as
473480
# its name and be really confused.
474481
if isinstance(expr, volume.Volume):
@@ -4072,8 +4079,7 @@ def semiClosedPosition(
40724079
c2 = self
40734080

40744081
if t.TYPE_CHECKING:
4075-
from music21.stream import Stream
4076-
assert isinstance(c2, Stream)
4082+
assert isinstance(c2, stream.Stream)
40774083
# startOctave = c2.bass().octave
40784084
remainingPitches = copy.copy(c2.pitches) # no deepcopy needed
40794085

@@ -6134,8 +6140,7 @@ def testCopyAndDeepcopy(self):
61346140
testCopyAll(self, globals())
61356141

61366142

6137-
6138-
_DOC_ORDER = [Chord]
6143+
_DOC_ORDER = [Chord, ChordBase, fromForteClass, fromIntervalVector]
61396144

61406145

61416146
if __name__ == '__main__':

music21/common/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434
'objects',
3535
'pathTools',
3636
'parallel',
37+
'stringTools',
3738
'types',
3839
'weakrefTools',
3940
]
4041

41-
from music21 import defaults
42-
from music21 import exceptions21
4342
from music21.common.classTools import * # including isNum, isListLike
4443
from music21.common.decorators import * # gives the deprecated decorator
4544
from music21.common.enums import *

music21/corpus/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,43 @@
3636
>>> cb[0].parse()
3737
<music21.stream.Score airdsAirs/book1.abc>
3838
'''
39+
3940
from __future__ import annotations
4041
from collections.abc import Iterable
4142
import typing as t
4243

4344
from music21 import common
45+
from music21.exceptions21 import CorpusException
4446
from music21 import metadata
4547

4648
from music21.corpus import chorales
4749
from music21.corpus import corpora
4850
from music21.corpus import manager
4951
from music21.corpus import virtual
5052
from music21.corpus import work
51-
5253
from music21.corpus.manager import search
5354
from music21 import environment
54-
from music21.exceptions21 import CorpusException
5555

5656
__all__ = [
57-
'chorales', 'corpora', 'manager',
58-
# virtual
59-
'work',
60-
'parse',
61-
'getCorePaths',
62-
# 'getVirtualPaths',
63-
'getLocalPaths',
57+
'CorpusException',
6458
'addPath',
65-
'getPaths',
6659
'cacheMetadata',
60+
'chorales',
61+
'corpora',
6762
'getComposer',
68-
'noCorpus',
63+
'getCorePaths',
64+
'getLocalPaths',
65+
'getPaths',
66+
# 'getVirtualPaths',
6967
'getWork',
70-
68+
'manager',
69+
'noCorpus',
70+
'parse',
71+
# virtual
72+
'search',
73+
'work',
7174
]
7275

73-
7476
if t.TYPE_CHECKING:
7577
import pathlib
7678

-3.17 KB
Binary file not shown.

music21/corpus/corpora.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,14 @@ def addPath(self, directoryPath):
811811
Paths added in this way will not be persisted from session to session
812812
unless explicitly saved by a call to ``LocalCorpus.save()``.
813813
'''
814-
from music21 import corpus
815814
if not isinstance(directoryPath, (str, pathlib.Path)):
816-
raise corpus.CorpusException(
815+
raise CorpusException(
817816
f'an invalid file path has been provided: {directoryPath!r}')
818817

819818
directoryPath = common.cleanpath(directoryPath, returnPathlib=True)
820819
if (not directoryPath.exists()
821820
or not directoryPath.is_dir()):
822-
raise corpus.CorpusException(
821+
raise CorpusException(
823822
f'an invalid file path has been provided: {directoryPath!r}')
824823
if self.name not in LocalCorpus._temporaryLocalPaths:
825824
LocalCorpus._temporaryLocalPaths[self.name] = set()

0 commit comments

Comments
 (0)