diff --git a/Notebooks/Deprecated - Tutorial - model classes.ipynb b/Notebooks/Deprecated - Tutorial - model classes.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..c8fc8565cc2fb698645f3a5fcabe60046bc7201e --- /dev/null +++ b/Notebooks/Deprecated - Tutorial - model classes.ipynb @@ -0,0 +1,2184 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tutorial for the model classes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This notebook will briefly present some functionnalities implemented to cope with symbolic representation of music, as an upgrade of C. Louboutin's code." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It contains 2 files: note.py, chord.py.\n", + "All these files represent different objects, used to handle musical information at different levels.\n", + "\n", + "A note is the most basic element, a chord is an aggregation of notes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## note.py" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:39.980475Z", + "start_time": "2020-10-30T15:35:39.976485Z" + }, + "scrolled": true + }, + "outputs": [], + "source": [ + "from polytopes.model.note import Note" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's start with the Note object, which is the lowest-level object in music.\n", + "\n", + "The interest of defining such an object is that it allows us to control what is an acceptable note, and what isn't." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Initialization" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Particularily, a Note contains two attributes:\n", + " - a number: between 0 and 11, which corresponds to the pitch classe of the note. 0 represent the C pitch class, and 11 the B pitch class. \n", + " - a symbol: the classical representation of a note as a letter, with flat (\"b\") or sharp(\"#\") suffixes." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:41.270648Z", + "start_time": "2020-10-30T15:35:41.258680Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\"<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9)\"" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "note_a = Note('A')\n", + "repr(note_a)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can access to these attributes directly on the object:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:42.215995Z", + "start_time": "2020-10-30T15:35:42.211006Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'A'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "note_a.symbol" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:42.708684Z", + "start_time": "2020-10-30T15:35:42.702692Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "9" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "note_a.number" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A note can be defined by it's symbol or it's number." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:43.666480Z", + "start_time": "2020-10-30T15:35:43.660496Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9)" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note('9')" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:44.156913Z", + "start_time": "2020-10-30T15:35:44.151926Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note('A')" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:44.724397Z", + "start_time": "2020-10-30T15:35:44.718413Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note('9') == Note('A')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Modification" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A Note object can also be modified.\n", + "\n", + "Modifying the number of a note will also modify it's symbol, and vice-versa, as both are linked." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:47.003807Z", + "start_time": "2020-10-30T15:35:46.998822Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before modification: <class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11)\n", + "After modification: <class 'polytopes.model.note.Note'>(Symbol: 'D', Number: 2)\n", + "After modifying its number: <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)\n" + ] + } + ], + "source": [ + "a_note = Note('B')\n", + "print(\"Before modification: \" + str(a_note))\n", + "\n", + "a_note.symbol = 'D'\n", + "print(\"After modification: \" + str(a_note))\n", + "\n", + "a_note.number = 7\n", + "print(\"After modifying its number: \" + str(a_note))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still, not every symbol or every number is acceptable. Hence, modifying or initializing a Note with a wrong number should not be tolerated." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:50.898336Z", + "start_time": "2020-10-30T15:35:50.763098Z" + }, + "scrolled": true + }, + "outputs": [ + { + "ename": "InvalidNoteNumberException", + "evalue": "The desired new number is too large to be a valid note.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mInvalidNoteNumberException\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-10-8a3266453d6f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma_note\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnumber\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m15\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\note.py\u001b[0m in \u001b[0;36m_set_number\u001b[1;34m(self, number)\u001b[0m\n\u001b[0;32m 122\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInvalidNoteNumberException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"The desired new number is not an integer, and is not valid.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 123\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mIndexError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 124\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInvalidNoteNumberException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"The desired new number is too large to be a valid note.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 125\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 126\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mInvalidNoteNumberException\u001b[0m: The desired new number is too large to be a valid note." + ] + } + ], + "source": [ + "a_note.number = 15" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:52.920685Z", + "start_time": "2020-10-30T15:35:52.908717Z" + }, + "scrolled": true + }, + "outputs": [ + { + "ename": "InvalidNoteSymbolException", + "evalue": "This symbol is not a correct note symbol.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mInvalidNoteSymbolException\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-11-20488d99cd64>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma_note\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msymbol\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'K'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\note.py\u001b[0m in \u001b[0;36m_set_symbol\u001b[1;34m(self, symbol)\u001b[0m\n\u001b[0;32m 87\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_number\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnumber_from_symbol\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 88\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 89\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInvalidNoteSymbolException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"This symbol is not a correct note symbol.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 90\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 91\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_get_number\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mInvalidNoteSymbolException\u001b[0m: This symbol is not a correct note symbol." + ] + } + ], + "source": [ + "a_note.symbol = 'K'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, sharp and flat symbols should both exist but shouldn't invalid tests, as they represent the same note.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:55.400706Z", + "start_time": "2020-10-30T15:35:55.396706Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note('A#') == Note(\"Bb\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "By default, a note symbol is set in flat convention. Still, it can be set to sharp with an argument in the constructor." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:35:57.297625Z", + "start_time": "2020-10-30T15:35:57.293373Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Default: <class 'polytopes.model.note.Note'>(Symbol: 'Bb', Number: 10)\n", + "In sharp: <class 'polytopes.model.note.Note'>(Symbol: 'A#', Number: 10)\n" + ] + } + ], + "source": [ + "a_note = Note(\"A#\")\n", + "print(\"Default: \" + repr(a_note))\n", + "a_note = Note(\"A#\", flat = False)\n", + "print(\"In sharp: \" + repr(a_note))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Additionally, one can modify a note to be in the sharp or in the flat system." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:01.128721Z", + "start_time": "2020-10-30T15:36:01.123584Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "In flat: <class 'polytopes.model.note.Note'>(Symbol: 'Bb', Number: 10)\n", + "In sharp: <class 'polytopes.model.note.Note'>(Symbol: 'A#', Number: 10)\n" + ] + } + ], + "source": [ + "a_note = Note(\"Bb\")\n", + "print(\"In flat: \" + repr(a_note))\n", + "a_note.to_sharp()\n", + "print(\"In sharp: \" + repr(a_note))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:02.901568Z", + "start_time": "2020-10-30T15:36:02.896604Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "In sharp: <class 'polytopes.model.note.Note'>(Symbol: 'A#', Number: 10)\n", + "In flat: <class 'polytopes.model.note.Note'>(Symbol: 'Bb', Number: 10)\n" + ] + } + ], + "source": [ + "a_note = Note(\"A#\", flat = False)\n", + "print(\"In sharp: \" + repr(a_note))\n", + "a_note.to_flat()\n", + "print(\"In flat: \" + repr(a_note))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### chord.py" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:07.685939Z", + "start_time": "2020-10-30T15:36:07.681950Z" + }, + "scrolled": true + }, + "outputs": [], + "source": [ + "from polytopes.model.chord import Chord" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A chord is a set of mulitple pitches. Hence, a chord is defined from notes." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Initialization" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:10.163397Z", + "start_time": "2020-10-30T15:36:10.158409Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.chord.Chord'>(Symbol: 'Am', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9), <class 'polytopes.model.note.Note'>(Symbol: 'C', Number: 0), <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4)])" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a = Note('A')\n", + "c = Note('C')\n", + "e = Note('E')\n", + "Chord([a,c,e])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A chord must contain at least one note." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:12.076386Z", + "start_time": "2020-10-30T15:36:12.061393Z" + } + }, + "outputs": [ + { + "ename": "InvalidChordNotesException", + "evalue": "Empty list of notes: a Chord must admit notes.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mInvalidChordNotesException\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-18-bf07a16d637a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mChord\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\chord.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, a_chord, redundancy)\u001b[0m\n\u001b[0;32m 71\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_notes\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlocal_notes\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 72\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_notes\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 73\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInvalidChordNotesException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Empty list of notes: a Chord must admit notes.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 74\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_triad\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtriad_from_notes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 75\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtriad\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[0mcst\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mAMBIGUOUS\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_redundant\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# A redundant chord shouldn't be reordered as it corresponds to permutated chord (#TODO: rename the parameter ?)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mInvalidChordNotesException\u001b[0m: Empty list of notes: a Chord must admit notes." + ] + } + ], + "source": [ + "Chord([])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It can be directly defined by a list of numbers." + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:14.333701Z", + "start_time": "2020-10-30T15:36:14.325723Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.chord.Chord'>(Symbol: 'Am', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9), <class 'polytopes.model.note.Note'>(Symbol: 'C', Number: 0), <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4)])" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord([9, 0, 4])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "!!!!!!!!!!!! A chord **can't** be defined by a list of note symbols (at least not yet)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:17.596300Z", + "start_time": "2020-10-30T15:36:17.581336Z" + }, + "scrolled": true + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "int() argument must be a string, a bytes-like object or a number, not 'list'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\chord.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, a_chord, redundancy)\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 68\u001b[1;33m \u001b[0mnote_obj\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mNote\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma_note\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 69\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mnote_obj\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_in_list_of_notes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlocal_notes\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_redundant\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 10: 'A'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-20-6a8e4e2a89cb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mChord\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'A'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'C'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'E'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\chord.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, a_chord, redundancy)\u001b[0m\n\u001b[0;32m 80\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# If it's a symbol\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 81\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 82\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_symbol\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mformat_symbol\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma_chord\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 83\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_root\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mroot_from_symbol\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 84\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_triad\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtriad_from_symbol\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\chord.py\u001b[0m in \u001b[0;36mformat_symbol\u001b[1;34m(symbol)\u001b[0m\n\u001b[0;32m 693\u001b[0m \"\"\"\n\u001b[0;32m 694\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 695\u001b[1;33m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msymbol\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 696\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mInvalidChordSymbolException\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"The symbol isn't valid.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 697\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: int() argument must be a string, a bytes-like object or a number, not 'list'" + ] + } + ], + "source": [ + "Chord(['A', 'C', 'E'])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "However, a Chord can be defined by its symbol." + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:21.550969Z", + "start_time": "2020-10-30T15:36:21.545981Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.chord.Chord'>(Symbol: 'Abm', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8), <class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11), <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3)])" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord('Abmin')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Defining a Chord by its symbol or by its notes doesn't change the value of its attributes." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:23.347691Z", + "start_time": "2020-10-30T15:36:23.342704Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord('Abmin') == Chord([8, 11, 3])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When instanciated, a Chord has several attributes:\n", + " - notes: the list of notes of the Chord. These are Note objects.\n", + " - symbol: the symbol of the Chord.\n", + " - root: the root of the Chord.\n", + " - triad: the type of triad of the Chord (maj or min) if it's a triad." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:25.458179Z", + "start_time": "2020-10-30T15:36:25.453190Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4)]" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord = Chord('A')\n", + "chord.notes" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:27.419601Z", + "start_time": "2020-10-30T15:36:27.414602Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'A'" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord.symbol" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:27.944160Z", + "start_time": "2020-10-30T15:36:27.940510Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9)" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord.root" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:28.472353Z", + "start_time": "2020-10-30T15:36:28.467367Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'A'" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord.triad" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still, defined by its notes, a chord symbol can be ambiguous (ex: A6 (A with a sixth) is also F#m7)\n", + "\n", + "In that sense, a chord defined by its notes, when not a triad (perfect major or minor), will have its root and its symbol labelled as \"Ambiguous\"" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:30.499972Z", + "start_time": "2020-10-30T15:36:30.495979Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.chord.Chord'>(Symbol: 'Ambiguous', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9), <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1), <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4), <class 'polytopes.model.note.Note'>(Symbol: 'Gb', Number: 6)])" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord([9, 1, 4, 6])" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:32.195767Z", + "start_time": "2020-10-30T15:36:32.187788Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "('Ambiguous', 'Ambiguous', 'Ambiguous')" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord([9, 1, 4, 6]).symbol, Chord([9, 1, 4, 6]).root, Chord([9, 1, 4, 6]).triad" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Modification" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As for a Note, a Chord symbol or notes of a Chord can be directly modified." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:41.627387Z", + "start_time": "2020-10-30T15:36:41.621403Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Before modif: <class 'polytopes.model.chord.Chord'>(Symbol: 'B', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11), <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3), <class 'polytopes.model.note.Note'>(Symbol: 'Gb', Number: 6)])\n" + ] + }, + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Gb', Number: 6)]" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord = Chord('B')\n", + "print(\"Before modif: %r\" % (a_chord))\n", + "a_chord.notes" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:43.296242Z", + "start_time": "2020-10-30T15:36:43.289260Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "After modif: <class 'polytopes.model.chord.Chord'>(Symbol: 'Ab', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8), <class 'polytopes.model.note.Note'>(Symbol: 'C', Number: 0), <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3)])\n" + ] + }, + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'C', Number: 0),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3)]" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord.notes = [8, 0, 3]\n", + "print(\"After modif: %r\" % (a_chord))\n", + "a_chord.notes" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:45.000201Z", + "start_time": "2020-10-30T15:36:44.994248Z" + }, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "After 2nd modif: <class 'polytopes.model.chord.Chord'>(Symbol: 'A7', Notes: [<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9), <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1), <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4), <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)])\n" + ] + }, + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)]" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord.symbol = 'A7'\n", + "print(\"After 2nd modif: %r\" % (a_chord))\n", + "a_chord.notes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still, the other attributes can't, as they do not hold enough information on the new Chord to re-instanciate it." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:47.441333Z", + "start_time": "2020-10-30T15:36:47.427369Z" + }, + "scrolled": true + }, + "outputs": [ + { + "ename": "CantModifyAttribute", + "evalue": "Not on my watch: you can't modify this attribute alone, you can only modify the notes or the symbol.", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mCantModifyAttribute\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-32-2efe97ae21f2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0ma_chord\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mroot\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'B'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;32mc:\\users\\amarmore\\desktop\\projects\\phd main projects\\on git\\code\\polytopes and relation\\polytopes\\model\\chord.py\u001b[0m in \u001b[0;36m_not_on_my_watch\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 197\u001b[0m \u001b[0mRaises\u001b[0m \u001b[0man\u001b[0m \u001b[0merror\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mthese\u001b[0m \u001b[0mattributes\u001b[0m \u001b[0mmust\u001b[0m \u001b[0mbe\u001b[0m \u001b[0mfound\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0meither\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mnotes\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mthe\u001b[0m \u001b[0msymbol\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mset\u001b[0m \u001b[0mindependantly\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mthey\u001b[0m \u001b[0mdon\u001b[0m\u001b[0;31m'\u001b[0m\u001b[0mt\u001b[0m \u001b[0mcontain\u001b[0m \u001b[0menough\u001b[0m \u001b[0minformation\u001b[0m \u001b[0mon\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mchord\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 198\u001b[0m \"\"\"\n\u001b[1;32m--> 199\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mCantModifyAttribute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Not on my watch: you can't modify this attribute alone, you can only modify the notes or the symbol.\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 200\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 201\u001b[0m \u001b[0mroot\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mproperty\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0m_get_chord_root\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0m_not_on_my_watch\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mCantModifyAttribute\u001b[0m: Not on my watch: you can't modify this attribute alone, you can only modify the notes or the symbol." + ] + } + ], + "source": [ + "a_chord.root = 'B'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Adding a note" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A note can be added to a Chord, which will modify all of its attributes accordingly." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:50.653614Z", + "start_time": "2020-10-30T15:36:50.648627Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)]" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord = Chord('A')\n", + "chord.add_note(7)\n", + "chord.notes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Still, the added Note is already in the Chord, it won't be redundant." + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:52.466659Z", + "start_time": "2020-10-30T15:36:52.461672Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)]" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord.notes" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:53.563757Z", + "start_time": "2020-10-30T15:36:53.557773Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'A', Number: 9),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Db', Number: 1),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'E', Number: 4),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'G', Number: 7)]" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chord.add_note(9)\n", + "chord.notes" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:53.874511Z", + "start_time": "2020-10-30T15:36:53.865535Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord([8, 11, 3, 11]) == Chord([8, 11, 3, 11, 11, 11, 11])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Notes in the chord" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The attributes \"notes\" of a chord is a list, and so, an individual Note can be retrieved from this list." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:57.674854Z", + "start_time": "2020-10-30T15:36:57.667871Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8)" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord = Chord([8, 0, 3])\n", + "a_chord.notes[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "For convenience though, the i-th element of the .notes attribute can be accessed directly by indexing the Chord, as in:" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:36:58.339461Z", + "start_time": "2020-10-30T15:36:58.334474Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8)" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord[0]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Inversely, the presence of a note in the chord can be tested as any element in a list:" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:00.560917Z", + "start_time": "2020-10-30T15:37:00.554933Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, False)" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note(8) in a_chord.notes, Note(7) in a_chord.notes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Or, more simply, by testing if the Chord contains this note:" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:02.719718Z", + "start_time": "2020-10-30T15:37:02.714733Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, False)" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Note(8) in a_chord, Note(7) in a_chord" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To know the number of notes in a chord, one can use the method get_nb_notes():" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:05.609149Z", + "start_time": "2020-10-30T15:37:05.603649Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord.get_nb_notes()" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:08.439380Z", + "start_time": "2020-10-30T15:37:08.434394Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord.add_note(7)\n", + "a_chord.get_nb_notes()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, one can want to access to the notes as numbers, and there's a function for that:" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:10.143551Z", + "start_time": "2020-10-30T15:37:10.138568Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 7]" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a_chord.get_numbers()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Chord with redundancy" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Defined that way, chords doesn't allow repetitions in its notes (which is logical since notes are expressed in pitch classes).\n", + "\n", + "This could become a problem when manipulating theoretical objects, for example in a context of optimal transport between chords.\n", + "\n", + "To solve this problem, a parameter of the constructor can allow redundancy in the notes of a chord.\n", + "\n", + "It is called redundancy and is a boolean." + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:12.084047Z", + "start_time": "2020-10-30T15:37:12.077072Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'Eb', Number: 3),\n", + " <class 'polytopes.model.note.Note'>(Symbol: 'B', Number: 11)]" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Chord([8, 11, 3, 11], redundancy = True).notes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "When the object is created redundant, it remains redundant when its notes are modified." + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:14.444702Z", + "start_time": "2020-10-30T15:37:14.439716Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 8]" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "redundant_chord = Chord([8, 0, 3], redundancy = True)\n", + "redundant_chord.add_note(8)\n", + "redundant_chord.get_numbers()" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:15.852253Z", + "start_time": "2020-10-30T15:37:15.844280Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 4, 3]" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "redundant_chord = Chord([8, 0, 3], redundancy = True)\n", + "redundant_chord.notes = [8, 0, 3, 4, 3]\n", + "redundant_chord.get_numbers()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Conversely, a chord created without redundancy (default behavior) cannot be modified into a redundant chord." + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:16.964692Z", + "start_time": "2020-10-30T15:37:16.958700Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 4]" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "default_chord = Chord([8, 0, 3], redundancy = False) # or simply Chord([8, 0, 3])\n", + "default_chord.notes = [8, 0, 3, 4, 3]\n", + "default_chord.get_numbers()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It also works when defined by its symbol." + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:18.561793Z", + "start_time": "2020-10-30T15:37:18.555808Z" + }, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 4]" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "default_chord = Chord('A')\n", + "default_chord.notes = [8, 0, 3, 4, 3]\n", + "default_chord.get_numbers()" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:19.882635Z", + "start_time": "2020-10-30T15:37:19.875653Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[8, 0, 3, 4, 3]" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "redundant_chord = Chord('A', redundancy = True)\n", + "redundant_chord.notes = [8, 0, 3, 4, 3]\n", + "redundant_chord.get_numbers()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It should be noted that the notes of a triad are ordered when the chord is not redundant, and aren't ordered when the chord is.\n", + "\n", + "This is made to allow permutations when the chord is redundant, and to be more consistent with the real chord when it's not." + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:20.603827Z", + "start_time": "2020-10-30T15:37:20.597844Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "([8, 0, 3], <class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8))" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "default_chord = Chord('A')\n", + "default_chord.notes = [3, 8, 0]\n", + "default_chord.get_numbers(), default_chord.root" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T15:37:22.478662Z", + "start_time": "2020-10-30T15:37:22.470683Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "([3, 8, 0], <class 'polytopes.model.note.Note'>(Symbol: 'Ab', Number: 8))" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "redundant_chord = Chord('A', redundancy = True)\n", + "redundant_chord.notes = [3, 8, 0]\n", + "redundant_chord.get_numbers(), redundant_chord.root" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## polytope.py" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "ExecuteTime": { + "end_time": "2020-10-30T10:55:12.222629Z", + "start_time": "2020-10-30T10:55:12.139304Z" + } + }, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'anymore' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-1-8e7a5bdb8a47>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mEDIT\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0manymore\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[1;31mNameError\u001b[0m: name 'anymore' is not defined" + ] + } + ], + "source": [ + "EDIT: not anymore" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [], + "source": [ + "from polytope import Polytope" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A Polytope is an object defined to represent one or several musical bars, in the context of structural segmentation.\n", + "\n", + "Hence, it is defined by several chords." + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[<class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Gm', Notes: [<class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'D', Number: 2)]),\n", + " <class 'chord.Chord'>(Symbol: 'Gm', Notes: [<class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'D', Number: 2)]),\n", + " <class 'chord.Chord'>(Symbol: 'Gm', Notes: [<class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'D', Number: 2)]),\n", + " <class 'chord.Chord'>(Symbol: 'Gm', Notes: [<class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'D', Number: 2)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Ab', Notes: [<class 'note.Note'>(Symbol: 'Ab', Number: 8), <class 'note.Note'>(Symbol: 'C', Number: 0), <class 'note.Note'>(Symbol: 'Eb', Number: 3)]),\n", + " <class 'chord.Chord'>(Symbol: 'Bbm', Notes: [<class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'Db', Number: 1), <class 'note.Note'>(Symbol: 'F', Number: 5)]),\n", + " <class 'chord.Chord'>(Symbol: 'Bbm', Notes: [<class 'note.Note'>(Symbol: 'Bb', Number: 10), <class 'note.Note'>(Symbol: 'Db', Number: 1), <class 'note.Note'>(Symbol: 'F', Number: 5)]),\n", + " <class 'chord.Chord'>(Symbol: 'Eb', Notes: [<class 'note.Note'>(Symbol: 'Eb', Number: 3), <class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10)]),\n", + " <class 'chord.Chord'>(Symbol: 'Eb', Notes: [<class 'note.Note'>(Symbol: 'Eb', Number: 3), <class 'note.Note'>(Symbol: 'G', Number: 7), <class 'note.Note'>(Symbol: 'Bb', Number: 10)])]" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "some_chords = [[8, 0, 3], [8, 0, 3], [8, 0, 3], [8, 0, 3], [7, 10, 2], [7, 10, 2], [7, 10, 2], [7, 10, 2], [8, 0, 3], [8, 0, 3], [8, 0, 3], [8, 0, 3], [10, 1, 5], [10, 1, 5], [3, 7, 10], [3, 7, 10]]\n", + "polytope = Polytope(some_chords)\n", + "polytope.chords" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "To facilitates the visualization of polytopes, when they contain 16 elements, a 4 by 4 visualization function has been implemented." + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "16" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_length()" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 [8, 0, 3] 1 [8, 0, 3] \n", + "2 [8, 0, 3] 3 [8, 0, 3] \n", + "\n", + "4 [7, 10, 2] 5 [7, 10, 2] \n", + "6 [7, 10, 2] 7 [7, 10, 2] \n", + "\n", + "8 [8, 0, 3] 9 [8, 0, 3] \n", + "10 [8, 0, 3] 11 [8, 0, 3] \n", + "\n", + "12 [10, 1, 5] 13 [10, 1, 5] \n", + "14 [3, 7, 10] 15 [3, 7, 10] \n", + "\n" + ] + } + ], + "source": [ + "polytope.pretty_print()" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 Ab 1 Ab \n", + "2 Ab 3 Ab \n", + "\n", + "4 Gm 5 Gm \n", + "6 Gm 7 Gm \n", + "\n", + "8 Ab 9 Ab \n", + "10 Ab 11 Ab \n", + "\n", + "12 Bbm 13 Bbm \n", + "14 Eb 15 Eb \n", + "\n" + ] + } + ], + "source": [ + "polytope.pretty_print(symbols = True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It is also possible to access to the chords of a polytope as a list of Chord symbols or by lists of the note numbers:" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Gm',\n", + " 'Gm',\n", + " 'Gm',\n", + " 'Gm',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Bbm',\n", + " 'Bbm',\n", + " 'Eb',\n", + " 'Eb']" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_list_of_symbols()" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [10, 1, 5],\n", + " [10, 1, 5],\n", + " [3, 7, 10],\n", + " [3, 7, 10]]" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_list_of_numbers()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "One of the interest of the polytopical paradigm is to reorder the elements in a non sequential way.\n", + "\n", + "In that context, a promising framework, developed in [Louboutin 2017], is the \"Primer Preseving Permutation\" system, or PPP. Here, it is possible to obtain the ppp of a polytope with the methods:" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[8, 0, 3],\n", + " [8, 0, 3],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [10, 1, 5],\n", + " [10, 1, 5],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [3, 7, 10],\n", + " [3, 7, 10]]" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_ppp(1).get_list_of_numbers() # The argument is the index of the desired ppp." + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[<polytop.Polytop at 0x23b26514808>,\n", + " <polytop.Polytop at 0x23b26514908>,\n", + " <polytop.Polytop at 0x23b26514f08>,\n", + " <polytop.Polytop at 0x23b26514608>,\n", + " <polytop.Polytop at 0x23b26514548>,\n", + " <polytop.Polytop at 0x23b26514208>]" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_all_ppps()" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Ab',\n", + " 'Gm',\n", + " 'Gm',\n", + " 'Bbm',\n", + " 'Bbm',\n", + " 'Gm',\n", + " 'Gm',\n", + " 'Eb',\n", + " 'Eb']" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_all_ppps()[3].get_list_of_symbols()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, it is also possible to add a Chord to a polytope." + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "17" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.add_chord('Abmin')\n", + "polytope.get_length()" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [7, 10, 2],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [8, 0, 3],\n", + " [10, 1, 5],\n", + " [10, 1, 5],\n", + " [3, 7, 10],\n", + " [3, 7, 10],\n", + " [8, 11, 3]]" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polytope.get_list_of_numbers()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.5" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}