mfp1-2022/notebooks/week-2.ipynb

117 lines
2.9 KiB
Plaintext
Raw Permalink Normal View History

2022-10-20 16:22:22 +02:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Woche 2 - 17.-23. Oktober 2022 #\n",
"\n",
2022-10-20 22:04:15 +02:00
"Herzlich willkommen zur 2. Woche!\n",
"\n",
"## Agenda ##\n",
"\n",
"- [x] Struktur\n",
"- [x] Aufwärme\n",
"- [x] Seminaraufgaben 2.x\n",
2022-10-27 21:39:38 +02:00
"- ~~[ ] Besprechung von HA 1.x~~\n"
2022-10-20 16:22:22 +02:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2022-10-23 14:13:30 +02:00
"# imports\n",
2022-10-20 16:22:22 +02:00
"import os;\n",
2022-10-23 14:13:30 +02:00
"import sys; \n",
2022-10-20 16:22:22 +02:00
"\n",
"# NOTE: need this to force jupyter to reload imports:\n",
"for key in list(sys.modules.keys()):\n",
" if key.startswith('src.'):\n",
" del sys.modules[key];\n",
"\n",
"os.chdir(os.path.dirname(_dh[0]));\n",
"sys.path.insert(0, os.getcwd());\n",
"\n",
"from src.thirdparty.maths import *;\n",
"from src.thirdparty.render import *;\n",
"\n",
"from src.maths.diagrams import *;\n",
"from src.maths.sets import *;\n",
2022-10-21 22:10:11 +02:00
"from src.widgets import *;\n",
2022-10-20 16:22:22 +02:00
"\n",
"np.random.seed(8007253); # zur Wiederholbarkeit"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2022-10-23 14:13:30 +02:00
"# Userinput - Anzahl der Funktionen\n",
"fnames = ['f', 'g', 'h', 'i', 'j'];\n",
"setnames = ['X', 'Y', 'Z', 'U', 'V', 'W'];\n",
"ctrl = widgets.IntSlider(value=1, description=f'# Funktionen', min=1, max=len(fnames));\n",
"display(ctrl);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Widget - Mengen und Funktionen\n",
"FunctionDiagramWidget(N=ctrl.value, fnames=fnames, setnames=setnames).run();"
2022-10-20 16:22:22 +02:00
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
2022-10-21 22:10:11 +02:00
"# ohne Zufallserzeugung:\n",
"X = ['a', 'b', 'c', 'd', 'e'];\n",
"Y = [2, 3, 5, 7, 11, 13, 17];\n",
"Z = ['α', 'β', 'γ', 'δ'];\n",
"f = [('a', 5), ('b', 5), ('c', 17), ('d', 2), ('e', 5)]\n",
"g = [(2, 'γ'), (3, 'α'), (5, 'β'), (7, 'δ'), (11, 'β'), (13, 'γ'), (17, 'β')];\n",
2022-10-20 16:22:22 +02:00
"comp = Functions(\n",
2022-10-20 22:04:15 +02:00
" Function(name=('f', 'X', 'Y'), domain=X, codomain=Y, fct=f),\n",
" Function(name=('g', 'Y', 'Z'), domain=Y, codomain=Z, fct=g),\n",
2022-10-20 16:22:22 +02:00
");\n",
2022-10-21 22:10:11 +02:00
"comp.draw(show_labels=True);"
2022-10-20 16:22:22 +02:00
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.8 64-bit",
"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.10.8"
2022-10-27 21:39:38 +02:00
},
"vscode": {
"interpreter": {
"hash": "98590ff4fe04c8543246b2a01debd3de3c5ca9b666f43f1fa87d5110c692004c"
}
2022-10-20 16:22:22 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 2
}