Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 0 additions & 52 deletions .flake8

This file was deleted.

16 changes: 8 additions & 8 deletions .github/workflows/maincheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install Ubuntu dependencies
run: ./.github/scripts/install_ubuntu_deps.sh
- name: Setup Lilypond
Expand All @@ -36,7 +36,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -56,10 +56,10 @@ jobs:
pylint -j0 music21
pylint -j0 documentation

flake:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -71,15 +71,15 @@ jobs:
pip install wheel
pip install -r requirements.txt
pip install -r requirements_dev.txt
- name: PEP8 with flake8
- name: Code-style etc. with Ruff
run: |
flake8 music21
flake8 documentation
ruff check music21
ruff check documentation

mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions documentation/nbvalNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import subprocess

# noinspection PyPackageRequirements
import pytest # pylint: disable=unused-import
import pytest # pylint: disable=unused-import # noqa
# noinspection PyPackageRequirements
import nbval # pylint: disable=unused-import
import nbval # pylint: disable=unused-import # noqa

from music21 import environment
from music21 import common
Expand Down
4 changes: 2 additions & 2 deletions documentation/source/about/what.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
],
"source": [
"n = note.Note(\"D#3\")\n",
"n = note.Note('D#3')\n",
"n.duration.type = 'half'\n",
"n.show()"
]
Expand Down Expand Up @@ -144,7 +144,7 @@
}
],
"source": [
"littleMelody = converter.parse(\"tinynotation: 3/4 c4 d8 f g16 a g f#\")\n",
"littleMelody = converter.parse('tinynotation: 3/4 c4 d8 f g16 a g f#')\n",
"littleMelody.show()"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
}
],
"source": [
"c = chord.Chord(\"C4 E4 G4\")\n",
"c = chord.Chord('C4 E4 G4')\n",
"c.isConsonant()"
]
},
Expand Down
55 changes: 27 additions & 28 deletions documentation/source/developerReference/musicxmlTest.ipynb

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions documentation/source/developerReference/testing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
],
"source": [
"if __name__ == \"__main__\":\n",
"if __name__ == '__main__':\n",
" import music21\n",
" music21.mainTest(Test)"
]
Expand Down Expand Up @@ -104,17 +104,19 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from music21 import exceptions21\n",
"\n",
"def flipStemDirection(n):\n",
" '''\n",
" Takes in a note with a `.stemDirection` of 'up' or 'down'\n",
" and transforms it to the other. Does nothing if the `stemDirection` is not defined.\n",
" \n",
"\n",
" Notes without stem direction of `up` or `down` are left alone:\n",
" \n",
"\n",
" >>> n = note.Note()\n",
" >>> n.stemDirection\n",
" 'unspecified'\n",
Expand All @@ -131,9 +133,9 @@
" >>> flipStemDirection(n)\n",
" >>> n.stemDirection\n",
" 'up'\n",
" \n",
"\n",
" Objects without `.stemDirection` raise a Music21Exception\n",
" \n",
"\n",
" >>> r = note.Rest()\n",
" >>> flipStemDirection(r)\n",
" Traceback (most recent call last):\n",
Expand All @@ -142,8 +144,8 @@
" try:\n",
" sd = n.stemDirection\n",
" except AttributeError:\n",
" raise exceptions21.Music21Exception(\"flipStemDirection only works on Notes\")\n",
" \n",
" raise exceptions21.Music21Exception('flipStemDirection only works on Notes')\n",
"\n",
" if sd == 'up':\n",
" n.stemDirection = 'down'\n",
" elif sd == 'down':\n",
Expand Down Expand Up @@ -238,7 +240,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -252,7 +254,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.1"
"version": "3.13.9"
},
"pycharm": {
"stem_cell": {
Expand All @@ -265,5 +267,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"metadata": {},
"outputs": [],
"source": [
"cMaj = chord.Chord(\"C3 E3 G3\")\n",
"cMaj = chord.Chord('C3 E3 G3')\n",
"s = stream.Stream()\n",
"for i in range(20):\n",
" inv = i % 3\n",
Expand Down Expand Up @@ -250,7 +250,7 @@
"metadata": {},
"outputs": [],
"source": [
"cMaj = chord.Chord(\"C1 G1 E2\")\n",
"cMaj = chord.Chord('C1 G1 E2')\n",
"s = stream.Stream()\n",
"for i in range(7):\n",
" inv = i % 3\n",
Expand Down Expand Up @@ -291,7 +291,7 @@
"metadata": {},
"outputs": [],
"source": [
"cMaj = chord.Chord(\"C3 E3 G3 B-3 D-4 F#4\")\n",
"cMaj = chord.Chord('C3 E3 G3 B-3 D-4 F#4')\n",
"s = stream.Stream()\n",
"for i in range(17):\n",
" inv = i % 6\n",
Expand Down Expand Up @@ -379,7 +379,7 @@
}
],
"source": [
"germ6 = chord.Chord(\"A-3 C4 E-4 F#4\")\n",
"germ6 = chord.Chord('A-3 C4 E-4 F#4')\n",
"s = stream.Stream()\n",
"print(germ6.inversion())\n",
"for i in range(12):\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,7 @@
"for v in tsColSmall.iterateVerticalities():\n",
" if v:\n",
" print(v)\n",
" print(v.getAllVoiceLeadingQuartets())\n",
" "
" print(v.getAllVoiceLeadingQuartets())\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@
" workCount = 0\n",
" intervalCount = 0\n",
" seventhCount = 0\n",
" \n",
" # Perform a location search on the corpus and iterate over \n",
"\n",
" # Perform a location search on the corpus and iterate over\n",
" # resulting file name and work number\n",
" for result in corpus.search(region, field='locale'):\n",
" workCount += 1\n",
" \n",
"\n",
" # Parse the work and create a dictionary of intervals\n",
" s = result.parse()\n",
" intervalDict = diversityTool.countMelodicIntervals(s, found=intervalDict)\n",
" \n",
"\n",
" # Iterate through all intervals, and count totals and sevenths\n",
" for label in intervalDict.keys():\n",
" intervalCount += intervalDict[label][1] \n",
" intervalCount += intervalDict[label][1]\n",
" if label in ['m7', 'M7']:\n",
" seventhCount += intervalDict[label][1]\n",
" \n",
"\n",
" # Calculate a percentage and store results\n",
" pcentSevenths = round((seventhCount / float(intervalCount) * 100), 4)\n",
" results.append((region, pcentSevenths, intervalCount, workCount))"
Expand All @@ -97,7 +97,7 @@
],
"source": [
"# print results\n",
"for region, pcentSevenths, intervalCount, workCount in results: \n",
"for region, pcentSevenths, intervalCount, workCount in results:\n",
" print('locale: {}: found {} percent melodic sevenths, '\n",
" 'out of {} intervals in {} works'.format(\n",
" region, pcentSevenths, intervalCount, workCount))"
Expand Down Expand Up @@ -181,7 +181,7 @@
" part = soprano.augmentOrDiminish(speed)\n",
" part.transpose(transposition, inPlace=True)\n",
" outputScore.insert(0, part)\n",
" \n",
"\n",
"outputScore.measures(1, 5).show()"
]
},
Expand Down
Loading