From 91496a0a20115b9f0904fce67484eabbe2d17de0 Mon Sep 17 00:00:00 2001 From: Peter Mackenzie-Helnwein Date: Sun, 28 Jul 2024 21:19:27 -0700 Subject: [PATCH] cleaning up --- .../Lesson 01-Data Types-checkpoint.ipynb | 622 ------------ ... 02-Data Types and Loops-checkpoint.ipynb | 644 ------------ ...ops and matrix operations-checkpoint.ipynb | 922 ------------------ ...e more numpy and plotting-checkpoint.ipynb | 363 ------- .../Lesson 05-File IO-checkpoint.ipynb | 333 ------- ...ject Oriented Programming-checkpoint.ipynb | 197 ---- ...n 07-Inheritance (OOP 2)-checkpoint.ipynb | 814 ---------------- .../Pandas Demo-checkpoint.ipynb | 6 - .../Untitled-checkpoint.ipynb | 6 - .../Simulating effect of voter turnout.ipynb | 392 -------- 10 files changed, 4299 deletions(-) delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 01-Data Types-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 02-Data Types and Loops-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 03-Loops and matrix operations-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 04-some more numpy and plotting-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 05-File IO-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 06-Introduction to Object Oriented Programming-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 07-Inheritance (OOP 2)-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Pandas Demo-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/.ipynb_checkpoints/Untitled-checkpoint.ipynb delete mode 100644 code/jupyter/LessonNotes/Simulating effect of voter turnout.ipynb diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 01-Data Types-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 01-Data Types-checkpoint.ipynb deleted file mode 100644 index 6ef8241..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 01-Data Types-checkpoint.ipynb +++ /dev/null @@ -1,622 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#1: Basic data types and functions\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources\n", - "\n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 1\n", - "\n", - "**Theory**:\n", - "Stress transformation\n", - "\n", - "$$\n", - "\\begin{aligned}\n", - "\\sigma_{x}' &= \\sigma_{x} \\cos^2\\theta + \\sigma_{y} \\sin^2\\theta + 2\\tau_{xy} \\sin\\theta \\cos\\theta \\\\\n", - "\\sigma_{y}' &= \\sigma_{x} \\sin^2\\theta + \\sigma_{y} \\cos^2\\theta - 2\\tau_{xy} \\sin\\theta \\cos\\theta \\\\\n", - "\\tau_{xy}' &= (\\sigma_{y} - \\sigma_{x}) \\sin\\theta \\cos\\theta + \\tau_{xy} (\\cos^2\\theta - \\sin^2\\theta) \\\\\n", - "\\end{aligned}\n", - "$$\n", - "\n", - "**Given**:\n", - "Stress state:\n", - "\n", - "$$\n", - "\\sigma_{x} = 12~ksi~,\n", - "~~~\n", - "\\sigma_{y} = -5.5~ksi~,\n", - "~~~\n", - "\\tau_{xy} = 3.5~ksi \n", - "$$\n", - "\n", - "**Find**:\n", - "Components of stress in a rotated coordinate system for $\\theta=25^\\circ$." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# theta needs to be in radians\n", - "# sin and cos are not part of phython\n", - "\n", - "from math import sin, cos, pi, radians" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1.5707963267948966" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "radians(90)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "sigmax = 12.\n", - "sigmay = -5.5\n", - "tau = 3.5" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "theta = radians( 25. )\n", - "\n", - "cs = cos(theta)\n", - "sn = sin(theta)\n", - "\n", - "sigmaxp = sigmax * cs**2 + sigmay * sn**2 + 2 * tau * sn * cs\n", - "sigmayp = sigmax * sn**2 + sigmay * cs**2 - 2 * tau * sn * cs\n", - "taup = (sigmay - sigmax) * sn * cs + tau * (cs*cs - sn*sn)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'= 11.555547, sigy'=-5.055547, tau'=-4.453132\n" - ] - } - ], - "source": [ - "print(f\"sigx'={sigmaxp:12.6f}, sigy'={sigmayp:.6f}, tau'={taup:.6f}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2\n", - "\n", - "Convert the calculation from exercise 1 to a function" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "def stressTransform(sigx, sigy, tauxy, theta):\n", - " # YOUR CODE\n", - " cs = cos(radians(theta))\n", - " sn = sin(radians(theta))\n", - "\n", - " sx = sigx * cs**2 + sigy * sn**2 + 2 * tauxy * sn * cs\n", - " sy = sigx * sn**2 + sigy * cs**2 - 2 * tauxy * sn * cs\n", - " txy = (sigy - sigx) * sn * cs + tauxy * (cs*cs - sn*sn)\n", - " \n", - " return (sx,sy,txy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Test your function for \n", - "\n", - "* $\\theta=0$ (what should the result look like?)\n", - "* $\\theta=25^\\circ$\n", - "* $\\theta=180^\\circ$" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'=12.000000, sigy'=-5.500000, tau'=3.500000\n" - ] - } - ], - "source": [ - "s1,s2,s3 = stressTransform(12., -5.5, 3.5, 0.0)\n", - "\n", - "print(f\"sigx'={s1:.6f}, sigy'={s2:.6f}, tau'={s3:.6f}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'=12.000000, sigy'=-5.500000, tau'=3.500000\n" - ] - } - ], - "source": [ - "stress = stressTransform(12., -5.5, 3.5, 0.0)\n", - "\n", - "print(f\"sigx'={stress[0]:.6f}, sigy'={stress[1]:.6f}, tau'={stress[2]:.6f}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'=12.000000, sigy'=-5.500000, tau'=3.500000\n" - ] - } - ], - "source": [ - "stress = stressTransform(12., -5.5, 3.5, 0.0)\n", - "\n", - "print(\"sigx'={:.6f}, sigy'={:.6f}, tau'={:.6f}\".format(*stress))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "theta= 0.00: sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000\n", - "theta= 25.00: sigx'= 11.555547, sigy'= -5.055547, tau'= -4.453132\n", - "theta= 90.00: sigx'= -5.500000, sigy'= 12.000000, tau'= -3.500000\n", - "theta= 135.00: sigx'= -0.250000, sigy'= 6.750000, tau'= 8.750000\n", - "theta= 180.00: sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000\n" - ] - } - ], - "source": [ - "template = \"theta={:7.2f}: sigx'={:12.6f}, sigy'={:12.6f}, tau'={:12.6f}\"\n", - "\n", - "thetas = [0.0, 25., 90., 135., 180.]\n", - "\n", - "for theta in thetas:\n", - " stress = stressTransform(12., -5.5, 3.5, theta)\n", - " print(template.format(theta, *stress))\n", - " #print(template.format(theta, stress[0], stress[1], stress[2]))" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000 : theta= 0.00\n", - "sigx'= 11.555547, sigy'= -5.055547, tau'= -4.453132 : theta= 25.00\n", - "sigx'= -5.500000, sigy'= 12.000000, tau'= -3.500000 : theta= 90.00\n", - "sigx'= -0.250000, sigy'= 6.750000, tau'= 8.750000 : theta= 135.00\n", - "sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000 : theta= 180.00\n" - ] - } - ], - "source": [ - "template = \"sigx'={:12.6f}, sigy'={:12.6f}, tau'={:12.6f} : theta={:7.2f}\"\n", - "\n", - "thetas = [0.0, 25., 90., 135., 180.]\n", - "\n", - "for theta in thetas:\n", - " stress = stressTransform(12., -5.5, 3.5, theta)\n", - " print(template.format(*stress, theta))" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000 : theta= 0.00\n", - "sigx'= 11.555547, sigy'= -5.055547, tau'= -4.453132 : theta= 25.00\n", - "sigx'= -5.500000, sigy'= 12.000000, tau'= -3.500000 : theta= 90.00\n", - "sigx'= -0.250000, sigy'= 6.750000, tau'= 8.750000 : theta= 135.00\n", - "sigx'= 12.000000, sigy'= -5.500000, tau'= 3.500000 : theta= 180.00\n" - ] - } - ], - "source": [ - "template = \"sigx'={sxx:12.6f}, sigy'={syy:12.6f}, tau'={sxy:12.6f} : theta={th:7.2f}\"\n", - "\n", - "thetas = [0.0, 25., 90., 135., 180.]\n", - "\n", - "for theta in thetas:\n", - " stress = stressTransform(12., -5.5, 3.5, theta)\n", - " print(template.format(th=theta, sxy=stress[2], sxx=stress[0], syy=stress[1]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 3\n", - "\n", - "Let's use this function to study stress transformation. In order to do so,\n", - "\n", - "1. Create a list of 81 evenly spaced $\\theta$-values from $0^\\circ$ to $180^\\circ$.\n", - "2. Compute the transformed stress for each of these values and collect the results in three lists: \n", - "\n", - " sigmax_values = ...\n", - " sigmay_values = ...\n", - " tauxy_values = ...\n", - "\n", - "3. print a nice table with 4 columns: $\\theta$, $\\sigma_x'$, $\\sigma_y'$, $\\tau_{xy}'$" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " 0.0000 12.0000 -5.5000 3.5000\n", - " 2.2500 12.2476 -5.7476 2.8027\n", - " 4.5000 12.4398 -5.9398 2.0881\n", - " 6.7500 12.5753 -6.0753 1.3606\n", - " 9.0000 12.6533 -6.1533 0.6248\n", - " 11.2500 12.6733 -6.1733 -0.1149\n", - " 13.5000 12.6353 -6.1353 -0.8539\n", - " 15.7500 12.5393 -6.0393 -1.5876\n", - " 18.0000 12.3861 -5.8861 -2.3116\n", - " 20.2500 12.1766 -5.6766 -3.0212\n", - " 22.5000 11.9121 -5.4121 -3.7123\n", - " 24.7500 11.5941 -5.0941 -4.3805\n", - " 27.0000 11.2247 -4.7247 -5.0217\n", - " 29.2500 10.8061 -4.3061 -5.6319\n", - " 31.5000 10.3409 -3.8409 -6.2073\n", - " 33.7500 9.8321 -3.3321 -6.7446\n", - " 36.0000 9.2826 -2.7826 -7.2402\n", - " 38.2500 8.6959 -2.1959 -7.6912\n", - " 40.5000 8.0757 -1.5757 -8.0948\n", - " 42.7500 7.4257 -0.9257 -8.4484\n", - " 45.0000 6.7500 -0.2500 -8.7500\n", - " 47.2500 6.0527 0.4473 -8.9976\n", - " 49.5000 5.3381 1.1619 -9.1898\n", - " 51.7500 4.6106 1.8894 -9.3253\n", - " 54.0000 3.8748 2.6252 -9.4033\n", - " 56.2500 3.1351 3.3649 -9.4233\n", - " 58.5000 2.3961 4.1039 -9.3853\n", - " 60.7500 1.6624 4.8376 -9.2893\n", - " 63.0000 0.9384 5.5616 -9.1361\n", - " 65.2500 0.2288 6.2712 -8.9266\n", - " 67.5000 -0.4623 6.9623 -8.6621\n", - " 69.7500 -1.1305 7.6305 -8.3441\n", - " 72.0000 -1.7717 8.2717 -7.9747\n", - " 74.2500 -2.3819 8.8819 -7.5561\n", - " 76.5000 -2.9573 9.4573 -7.0909\n", - " 78.7500 -3.4946 9.9946 -6.5821\n", - " 81.0000 -3.9902 10.4902 -6.0326\n", - " 83.2500 -4.4412 10.9412 -5.4459\n", - " 85.5000 -4.8448 11.3448 -4.8257\n", - " 87.7500 -5.1984 11.6984 -4.1757\n", - " 90.0000 -5.5000 12.0000 -3.5000\n", - " 92.2500 -5.7476 12.2476 -2.8027\n", - " 94.5000 -5.9398 12.4398 -2.0881\n", - " 96.7500 -6.0753 12.5753 -1.3606\n", - " 99.0000 -6.1533 12.6533 -0.6248\n", - " 101.2500 -6.1733 12.6733 0.1149\n", - " 103.5000 -6.1353 12.6353 0.8539\n", - " 105.7500 -6.0393 12.5393 1.5876\n", - " 108.0000 -5.8861 12.3861 2.3116\n", - " 110.2500 -5.6766 12.1766 3.0212\n", - " 112.5000 -5.4121 11.9121 3.7123\n", - " 114.7500 -5.0941 11.5941 4.3805\n", - " 117.0000 -4.7247 11.2247 5.0217\n", - " 119.2500 -4.3061 10.8061 5.6319\n", - " 121.5000 -3.8409 10.3409 6.2073\n", - " 123.7500 -3.3321 9.8321 6.7446\n", - " 126.0000 -2.7826 9.2826 7.2402\n", - " 128.2500 -2.1959 8.6959 7.6912\n", - " 130.5000 -1.5757 8.0757 8.0948\n", - " 132.7500 -0.9257 7.4257 8.4484\n", - " 135.0000 -0.2500 6.7500 8.7500\n", - " 137.2500 0.4473 6.0527 8.9976\n", - " 139.5000 1.1619 5.3381 9.1898\n", - " 141.7500 1.8894 4.6106 9.3253\n", - " 144.0000 2.6252 3.8748 9.4033\n", - " 146.2500 3.3649 3.1351 9.4233\n", - " 148.5000 4.1039 2.3961 9.3853\n", - " 150.7500 4.8376 1.6624 9.2893\n", - " 153.0000 5.5616 0.9384 9.1361\n", - " 155.2500 6.2712 0.2288 8.9266\n", - " 157.5000 6.9623 -0.4623 8.6621\n", - " 159.7500 7.6305 -1.1305 8.3441\n", - " 162.0000 8.2717 -1.7717 7.9747\n", - " 164.2500 8.8819 -2.3819 7.5561\n", - " 166.5000 9.4573 -2.9573 7.0909\n", - " 168.7500 9.9946 -3.4946 6.5821\n", - " 171.0000 10.4902 -3.9902 6.0326\n", - " 173.2500 10.9412 -4.4412 5.4459\n", - " 175.5000 11.3448 -4.8448 4.8257\n", - " 177.7500 11.6984 -5.1984 4.1757\n", - " 180.0000 12.0000 -5.5000 3.5000\n" - ] - } - ], - "source": [ - "\n", - "\n", - "sigmax_values = []\n", - "sigmay_values = []\n", - "tauxy_values = []\n", - "\n", - "# YOUR CODE for 1.\n", - "\n", - "Nsteps = 80\n", - "dtheta = 180/Nsteps\n", - "\n", - "thetas = [ 0.0 ]\n", - "for i in range(Nsteps):\n", - " thetas.append( thetas[-1] + dtheta )\n", - " \n", - "#print(thetas, len(thetas))\n", - "\n", - "# YOUR CODE for 2.\n", - "\n", - "for theta in thetas:\n", - " stress = stressTransform(12., -5.5, 3.5, theta)\n", - " sigmax_values.append(stress[0])\n", - " sigmay_values.append(stress[1])\n", - " tauxy_values.append(stress[2])\n", - " \n", - "#print(sigmax_values)\n", - "\n", - "# YOUR CODE for 3.\n", - "\n", - "template = \"{:12.4f} {:12.4f} {:12.4f} {:12.4f}\"\n", - "\n", - "#for i in range(len(thetas)):\n", - "# print(template.format(thetas[i], sigmax_values[i], sigmay_values[i], tauxy_values[i]))\n", - "\n", - "for data in zip(thetas, sigmax_values, sigmay_values, tauxy_values):\n", - " print(template.format(*data))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 4: Explore plotting in python\n", - "\n", - "For this, check out https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/simple_plot.html#sphx-glr-gallery-lines-bars-and-markers-simple-plot-py\n", - "\n", - "I copied the demo code below so you can modify it to plot $(\\sigma_{x}'/\\tau_{xy}')$ and $(\\sigma_{y}'/-\\tau_{xy}')$ curves from the data collected in `sigmax_values`, `sigmay_values`, `tauxy_values`" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAARsAAAEWCAYAAABWszP/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA730lEQVR4nO3dd3xUVfr48c+TTiqEkJCQ0EPvQURFBStWVKxrXd21+3VXXct31VX3t7uWr7q79rL2ih2xoEgHQQHpNUAgECCEkIQkpEzy/P64N+wQU8nM3JnJeb9e85py75z7nMnMk3PPvfccUVUMwzC8LcTpAAzDaB9MsjEMwydMsjEMwydMsjEMwydMsjEMwydMsjEMwydMsmkjEXlDRP6f03F4g4hcLiLfealsRz83ETleRDY4tf0jJZbXRWS/iPzUgvVVRPrajx39zE2yaSERmW3/gSN9tL2e9hclzBfba4iqvquqpzm1fW9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AMnzDJxjAMnzDJxjAMnzDJxjAMnzDJxvAoEekoIje7PU8TkY+bek8btnWeiDzYxPKhIvKGN7ZttJ459G14lIj0BKap6hAfbGshcK6qNjqliT0z67Wqut3b8RhNMy0bw9MeBfrY48c8ISI968ZhEZFrRORze/yVHBG5VUTuEJFfRGSRiCTa6/URkW/tiyfniciA+hsRkX5AZV2iEZGL7OvUVoiI++UIX2KdCW04zCQbw9PuBTbb48f8qYHlQ4ALgKOAvwHlqjoS+BG4yl7nZeA2Vc0C7gKeb6Cc44Blbs8fBE5X1eHAuW6vLwGOb0N9DA8xlysYvjZLVQ8AB0SkGKvlAbAKGCYiscCxwEf2ZQYAkQ2UkwrsdXu+AHhDRKYAn7q9ng+keTB+4wiZZGP4mvs0ybVuz2uxvo8hQJGqjmimnINAQt0TVb1RRI4GzgKWikiWqu4Doux1DYeZ3SjD0w4AcUf6ZlUtAbaKyEUAYhnewKrrgL51T0Skj6ouVtUHsVo8dUNl9CN4rvQOaCbZGB5ltyYW2J21TxxhMZcD14nICmANDQ9NOhcYKf/d13rCHth8NbAQWGG/PgH46gjjMDzIHPo2ApaI/Av4UlVnNLI8EpiDNVqfy6fBGb9iWjZGIPs7EN3E8u7AvSbR+AfTsjEMwydMy8YwDJ8wycYwDJ8wycYwDJ8wycYwDJ8wycYwDJ/4/+uREYHTwue7AAAAAElFTkSuQmCC\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "#import matplotlib\n", - "import matplotlib.pyplot as plt\n", - "\n", - "fig, ax = plt.subplots()\n", - "ax.plot(sigmax_values, tauxy_values)\n", - "\n", - "ax.set(xlabel='time (s)', ylabel='voltage (mV)',\n", - " title='About as simple as it gets, folks')\n", - "ax.grid()\n", - "ax.set_aspect('equal')\n", - "\n", - "# I comment writing the figure to file ... makes this quicker\n", - "# fig.savefig(\"test.png\")\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Remark**: This was just to wet your appetite! We will talk much more about `numpy` and `matplotlib` next week." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exercise 5: List versus dictionary\n", - "\n", - "You could express the stress state as\n", - "\n", - "1. three independent variables - the way we did it thus far\n", - "\n", - "2. a list of three values: `stress = `$[\\sigma_x, \\sigma_y, \\tau_{xy}]$ and replace\n", - "\n", - " sigma_x --> stress[0]\n", - " sigma_y --> stress[2]\n", - " tau_xy --> stress[3]\n", - " \n", - "3. a dictionary \n", - "\n", - " stress = {'sigx': 12.0, 'sigy': -5.5, 'tau':3.50}\n", - " \n", - " and replace\n", - "\n", - " sigma_x --> stress['sigx']\n", - " sigma_y --> stress['sigy']\n", - " tau_xy --> stress['tau']\n", - "\n", - "**Discuss**:\n", - "\n", - "1. Pros and cons for coding the equations\n", - "2. Pros and cons for coding the function(s)\n", - "3. How woud code and function change when switching from 2D to 3D (6 components instead of 3 components)\n", - "\n", - "Feel free to implement an alternative form of stressTrannsform() that looks like this:" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "def stressTransform(stress, theta):\n", - " # YOUR CODE\n", - " # stress2 is a list or dictionary, just as stress is\n", - " \n", - " return stress2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework questions\n", - "\n", - "We can all learn from your questions!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 02-Data Types and Loops-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 02-Data Types and Loops-checkpoint.ipynb deleted file mode 100644 index 80fd340..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 02-Data Types and Loops-checkpoint.ipynb +++ /dev/null @@ -1,644 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#2 : More on Data Types & Loops\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources (reminder)\n", - "\n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Summary of our previous session\n", - "\n", - "This is the short version of all we achieved working together during our previous session. We will be using this for further examples.\n", - "\n", - "**Theory**:\n", - "Stress transformation\n", - "\n", - "$$\n", - "\\begin{aligned}\n", - "\\sigma_{x}' &= \\sigma_{x} \\cos^2\\theta + \\sigma_{y} \\sin^2\\theta + 2\\tau_{xy} \\sin\\theta \\cos\\theta \\\\\n", - "\\sigma_{y}' &= \\sigma_{x} \\sin^2\\theta + \\sigma_{y} \\cos^2\\theta - 2\\tau_{xy} \\sin\\theta \\cos\\theta \\\\\n", - "\\tau_{xy}' &= (\\sigma_{y} - \\sigma_{x}) \\sin\\theta \\cos\\theta + \\tau_{xy} (\\cos^2\\theta - \\sin^2\\theta) \\\\\n", - "\\end{aligned}\n", - "$$\n", - "\n", - "**Given**:\n", - "Stress state:\n", - "\n", - "$$\n", - "\\sigma_{x} = 12~ksi~,\n", - "~~~\n", - "\\sigma_{y} = -5.5~ksi~,\n", - "~~~\n", - "\\tau_{xy} = 3.5~ksi \n", - "$$\n", - "\n", - "**Find**:\n", - "Components of stress in a rotated coordinate system for $\\theta=25^\\circ$." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "sigma_x= 12.000000 ksi\n", - "sigma_y= -5.500000 ksi\n", - "tau_xy = 3.500000 ksi\n", - "\n", - "sigma_x= 11.555547 ksi\n", - "sigma_y= -5.055547 ksi\n", - "tau_xy = -4.453132 ksi\n", - "\n", - "sigma_x= 12.000000 ksi\n", - "sigma_y= -5.500000 ksi\n", - "tau_xy = 3.500000 ksi\n", - "\n" - ] - } - ], - "source": [ - "# load needed functions from library module math\n", - "from math import sin,cos,radians\n", - "\n", - "# define function(s)\n", - "def stressTransform(sigx, sigy, tauxy, theta):\n", - "\n", - " th = radians(theta)\n", - "\n", - " sx = sigx * cos(th)**2 + sigy * sin(th)**2 + 2*tauxy * sin(th) * cos(th)\n", - " sy = sigx * sin(th)**2 + sigy * cos(th)**2 - 2*tauxy * sin(th) * cos(th)\n", - " txy = (sigy - sigx) * sin(th) * cos(th) + tauxy * (cos(th)**2 - sin(th)**2) \n", - " \n", - " return (sx,sy,txy)\n", - "\n", - "# define some input parameters\n", - "sigma_x = 12.\n", - "sigma_y = -5.5\n", - "tau_xy = 3.5\n", - "\n", - "# use that function\n", - "template = \"sigma_x={:12.6f} ksi\\nsigma_y={:12.6f} ksi\\ntau_xy ={:12.6f} ksi\\n\"\n", - "print(template.format(*stressTransform(sigma_x, sigma_y, tau_xy, 0)))\n", - "print(template.format(*stressTransform(sigma_x, sigma_y, tau_xy, 25)))\n", - "print(template.format(*stressTransform(sigma_x, sigma_y, tau_xy, 180)))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exercise 1: List versus dictionary\n", - "\n", - "You could express the stress state as\n", - "\n", - "1. three independent variables - the way we did it thus far\n", - "\n", - "2. a list of three values: `stress = `$[\\sigma_x, \\sigma_y, \\tau_{xy}]$ and replace\n", - "\n", - " sigma_x --> stress[0]\n", - " sigma_y --> stress[1]\n", - " tau_xy --> stress[2]\n", - " \n", - "3. a dictionary \n", - "\n", - " stress = {'sigx': 12.0, 'sigy': -5.5, 'tau':3.50}\n", - " \n", - " and replace\n", - "\n", - " sigma_x --> stress['sigx']\n", - " sigma_y --> stress['sigy']\n", - " tau_xy --> stress['tau']\n", - "\n", - "**Discuss**:\n", - "\n", - "1. Pros and cons for coding the equations\n", - "2. Pros and cons for coding the function(s)\n", - "3. How woud code and function change when switching from 2D to 3D (6 components instead of 3 components)\n", - "\n", - "**Implement**:\n", - "An alternative version of the `stressTransform(...)` function using a dictionary as defined under item 3. above." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "# load needed functions from library module math\n", - "from math import sin,cos,radians\n", - "\n", - "def stressTransform2(stress, theta):\n", - " # YOUR CODE HERE ...\n", - "\n", - " th = radians(theta)\n", - " \n", - " sigx = stress['sigx']\n", - " sigy = stress['sigy']\n", - " tauxy = stress['tau']\n", - "\n", - " sx = sigx * cos(th)**2 + sigy * sin(th)**2 + 2*tauxy * sin(th) * cos(th)\n", - " sy = sigx * sin(th)**2 + sigy * cos(th)**2 - 2*tauxy * sin(th) * cos(th)\n", - " txy = (sigy - sigx) * sin(th) * cos(th) + tauxy * (cos(th)**2 - sin(th)**2) \n", - " \n", - " stress_out = {'sigx': sx, 'sigy': sy, 'tau':txy}\n", - " \n", - " # stress_out is another dictionary containing the transformed stress\n", - " return stress_out" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Initialize given stress" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "given_stress = {'sigx': 12.0, 'sigy': -5.5, 'tau':3.50}" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'sigx': 11.555547135673642,\n", - " 'sigy': -5.055547135673642,\n", - " 'tau': -4.453132243388171}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "stressTransform2(given_stress, 25.0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Add some nice print out for all transformation angles in the $\\theta$-list " - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " 0.00, 12.000000, -5.500000, 3.500000\n", - " 25.00, 11.555547, -5.055547, -4.453132\n", - " 45.00, 6.750000, -0.250000, -8.750000\n", - " 75.00, -2.577722, 9.077722, -7.406089\n", - " 90.00, -5.500000, 12.000000, -3.500000\n", - " 180.00, 12.000000, -5.500000, 3.500000\n" - ] - } - ], - "source": [ - "theta_list = [0., 25., 45., 75., 90., 180.]\n", - "\n", - "template = \"\"\"theta ={th:8.2f}:\n", - " sigma_x={sigx:12.6f} ksi\n", - " sigma_y={sigy:12.6f} ksi\n", - " tau_xy ={tau:12.6f} ksi\n", - "\"\"\"\n", - "\n", - "template = \"{th:8.2f}, {sigx:12.6f}, {sigy:12.6f}, {tau:12.6f}\"\n", - "\n", - "for theta in theta_list:\n", - " print(template.format(th=theta, **stressTransform2(given_stress, theta)))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2 : Boolean variables\n", - "\n", - "Badly formulated boolean expressions are a common source for faulty code. This exercise shall emphasize how easy it is to misinterpret conditions. Moreover, we will explore ways to test and improve our conditions.\n", - "\n", - "**Your Task**:\n", - "predict the data type and value of the following boolean expressions. Is this `True` or `False`?\n", - "\n", - " 17 <= 365/21 and 'Monday' < 'Friday'\n", - "\n", - " 'Monday' < 'Friday' or cos( 3.1427 )\n", - "\n", - " (100 - 99) and sin( 3.14127/3 ) or 'Friday' > 'Monday'\n", - " \n", - " (100 - 99) and sin( 3.14127/3 ) and 'Friday' > 'Monday'\n", - " \n", - " (100 - 99) or sin( 3.14127/3 ) and 'Friday' > 'Monday'\n", - " \n", - " ( (100 - 99) or sin( 3.14127/3 ) ) and 'Friday' > 'Monday'\n", - " \n", - " ( (100 - 99) and sin( 3.14127/3 ) ) or 'Friday' > 'Monday'\n", - " \n", - "Write a simple test function that tells you how the computer interprets the result:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from math import sin\n", - "\n", - "def test(cond):\n", - " if cond:\n", - " print(\"cond => {} => is True\".format(cond))\n", - " else:\n", - " print(\"cond => {} => is False\".format(cond))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "cd = (100 - 99) and ( sin( 3.14127/3 ) or 'Friday' > 'Monday' )\n", - "test(cd)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if 'False':\n", - " print('True')\n", - "else:\n", - " print('False')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "DEBUG_MODE = False\n", - "\n", - "want_a_beer = False\n", - "\n", - "if DEBUG_MODE:\n", - " ans = want_a_beer or not want_a_beer\n", - " print(ans)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 3 : Writing efficient loops in python\n", - "\n", - "**Given**:\n", - "Three lists containing $\\theta$, $y_1=\\sin\\theta$, and $y_2=\\cos\\theta$.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "list(range(10+1))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from math import pi, sin, cos\n", - "\n", - "# set a parameter: N is an integer >= 1\n", - "N = 10\n", - "\n", - "# initialize the lists\n", - "theta = []\n", - "y1 = []\n", - "y2 = []\n", - "\n", - "# run this to populate the lists\n", - "th = 0.0\n", - "\n", - "for i in range(N+1):\n", - " theta.append(th)\n", - " y1.append(sin(th))\n", - " y2.append(cos(th))\n", - " th += pi/N" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "theta" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "y1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "y2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your Task**:\n", - "Write a loop that prints a table\n", - "\n", - "~~~\n", - "theta sin(theta) cos(theta)\n", - "...\n", - "~~~\n", - "\n", - "1. Assume you do not know how many elements are in those lists => you'll have to figure it out\n", - "2. use as few variables as possible\n", - "3. The shortest working solution requires only two lines of code (more are OK, of course).\n", - "\n", - "**Hint**: \n", - "If you got time left, check out the `zip` command." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from numpy import array\n", - "N = array([ len(theta), len(y1), len(y2) ]).min()\n", - "\n", - "for i in range(N):\n", - " print(\"{:12.6f} {:12.6f} {:12.6f}\".format(theta[i],y1[i],y2[i]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\" theta y1 y2 \")\n", - "print(40*\"=\")\n", - "for row in zip(theta, y1, y2):\n", - " print(\"{:12.6f} {:12.6f} {:12.6f}\".format(*row))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note the important trick:\n", - "\n", - "Loop over **items** in a list, NOT by index! This makes code more compact and much better readable." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt\n", - "\n", - "plt.plot(theta, y1,'-r')\n", - "plt.plot(theta, y2,'--b')\n", - "plt.grid()\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 4: Looping over dictionaries\n", - "\n", - "**Given**:\n", - "A dictionary `your_course` is given as follows (please do a `shift-enter` to initialize it)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "your_course = {\n", - " 'department':'CEE',\n", - " 'group':'CESG',\n", - " 'number':'505 A&B',\n", - " 'complexity':10,\n", - " 'workload':0,\n", - " 'credits':3,\n", - " 'instructor':'Dr Peter'\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your tasks**:\n", - "1. Write a loop to print all keys, one per line" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Change complexity to 6 and workload to 8" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. copy and modify the loop from 1. to print \"key: value\", one per line" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. Write a condition that checks if `your_course` has a field named `'expected_grade'`.\n", - " - If the field DOES exist, print **\"Field exists with value of {:3.1f}\".format(_the value associated with that key_)\"**\n", - " - If the field DOES NOT exist, create it and assign a sensible value, the print **\"Field created with value of {:3.1f}\".format(_the value associated with that key_)\"**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Execute the above code again to verify that the new key/value pair was added" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# just copy the code from two cells above" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# repeat the code that prints key/value pairs" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework questions\n", - "\n", - "We can all learn from your questions!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 03-Loops and matrix operations-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 03-Loops and matrix operations-checkpoint.ipynb deleted file mode 100644 index 51e91bd..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 03-Loops and matrix operations-checkpoint.ipynb +++ /dev/null @@ -1,922 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#3: Loops & Matrix Operations\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources (reminder)\n", - "\n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 1: Looping over dictionaries\n", - "\n", - "**Given**:\n", - "A dictionary `your_course` is given as follows (please do a `shift-enter` to initialize it)" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "your_course = {\n", - " 'department':'CEE',\n", - " 'group': 'CESG',\n", - " 'number': '505 A&B',\n", - " 'complexity': 10,\n", - " 'workload': 0,\n", - " 'credits': 3,\n", - " 'instructor':'Dr Peter'\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your tasks**:\n", - "1. Write a loop to print all keys, one per line" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "department => CEE\n", - "group => CESG\n", - "number => 505 A&B\n", - "complexity => 10\n", - "workload => 0\n", - "credits => 3\n", - "instructor => Dr Peter\n" - ] - } - ], - "source": [ - "for key in your_course:\n", - " print(f\"{key:12} => {your_course[key]}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Change complexity to 6 and workload to 8" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [], - "source": [ - "your_course['complexity'] = 6\n", - "your_course['workload'] = 8" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. copy and modify the loop from 1. to print \"key: value\", one per line" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "department => CEE\n", - "group => CESG\n", - "number => 505 A&B\n", - "complexity => 6\n", - "workload => 8\n", - "credits => 3\n", - "instructor => Dr Peter\n" - ] - } - ], - "source": [ - "for key in your_course:\n", - " print(f\"{key:12} => {your_course[key]}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. Write a condition that checks if `your_course` has a field named `'expected_grade'`.\n", - " - If the field DOES exist, print **\"Field exists with value of {:3.1f}\".format(_the value associated with that key_)\"**\n", - " - If the field DOES NOT exist, create it and assign a sensible value, the print **\"Field created with value of {:3.1f}\".format(_the value associated with that key_)\"**" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Field created with value of 4.0\n" - ] - } - ], - "source": [ - "if 'expected_grade' in your_course:\n", - " print( \"Field exists with value of {:3.1f}\".format(your_course['expected_grade']) )\n", - "else:\n", - " your_course['expected_grade'] = 4.0\n", - " print( \"Field created with value of {:3.1f}\".format(your_course['expected_grade']) )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Execute the above code again to verify that the new key/value pair was added" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Field exists with value of 4.0\n" - ] - } - ], - "source": [ - "if 'expected_grade' in your_course:\n", - " print( \"Field exists with value of {:3.1f}\".format(your_course['expected_grade']) )\n", - "else:\n", - " your_course['expected_grade'] = 4.0\n", - " print( \"Field created with value of {:3.1f}\".format(your_course['expected_grade']) )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2: Looping over Strings\n", - "\n", - "Strings are \"Lists of characters\". Thus, you can loop through a string.\n", - "\n", - "Moreover, multi-line text is also just a single string with newline characters ('\\n') separating lines.\n", - "\n", - "Consider the following string (a poem by Phillis Wheatley, the first African-American author of a published book of poetry):" - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": {}, - "outputs": [], - "source": [ - "s = \"\"\"'Twas mercy brought me from my Pagan land,\n", - "Taught my benighted soul to understand\n", - "That there's a God, that there's a Saviour too:\n", - "Once I redemption neither sought nor knew.\n", - "Some view our sable race with scornful eye,\n", - "\"Their colour is a diabolic die.\"\n", - "Remember, Christians, Negros, black as Cain,\n", - "May be refin'd, and join th' angelic train.\n", - "\n", - " BY PHILLIS WHEATLEY\"\"\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We used `\"\"\"...\"\"\"` to define a multi-line string. While this looks nice, it is still a single string as can be verified by the next command." - ] - }, - { - "cell_type": "code", - "execution_count": 56, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'\\'Twas mercy brought me from my Pagan land,\\nTaught my benighted soul to understand\\nThat there\\'s a God, that there\\'s a Saviour too:\\nOnce I redemption neither sought nor knew.\\nSome view our sable race with scornful eye,\\n\"Their colour is a diabolic die.\"\\nRemember, Christians, Negros, black as Cain,\\nMay be refin\\'d, and join th\\' angelic train.\\n\\n BY PHILLIS WHEATLEY'" - ] - }, - "execution_count": 56, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note the `\\n` in this string? This example actually shows the difference between just typing the variable `s` (above) or using the `print()` command." - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'Twas mercy brought me from my Pagan land,\n", - "Taught my benighted soul to understand\n", - "That there's a God, that there's a Saviour too:\n", - "Once I redemption neither sought nor knew.\n", - "Some view our sable race with scornful eye,\n", - "\"Their colour is a diabolic die.\"\n", - "Remember, Christians, Negros, black as Cain,\n", - "May be refin'd, and join th' angelic train.\n", - "\n", - " BY PHILLIS WHEATLEY\n" - ] - } - ], - "source": [ - "print(s)" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'-T-w-a-s- -m-e-r-c-y- -b-r-o-u-g-h-t- -m-e- -f-r-o-m- -m-y- -P-a-g-a-n- -l-a-n-d-,-\n", - "-T-a-u-g-h-t- -m-y- -b-e-n-i-g-h-t-e-d- -s-o-u-l- -t-o- -u-n-d-e-r-s-t-a-n-d-\n", - "-T-h-a-t- -t-h-e-r-e-'-s- -a- -G-o-d-,- -t-h-a-t- -t-h-e-r-e-'-s- -a- -S-a-v-i-o-u-r- -t-o-o-:-\n", - "-O-n-c-e- -I- -r-e-d-e-m-p-t-i-o-n- -n-e-i-t-h-e-r- -s-o-u-g-h-t- -n-o-r- -k-n-e-w-.-\n", - "-S-o-m-e- -v-i-e-w- -o-u-r- -s-a-b-l-e- -r-a-c-e- -w-i-t-h- -s-c-o-r-n-f-u-l- -e-y-e-,-\n", - "-\"-T-h-e-i-r- -c-o-l-o-u-r- -i-s- -a- -d-i-a-b-o-l-i-c- -d-i-e-.-\"-\n", - "-R-e-m-e-m-b-e-r-,- -C-h-r-i-s-t-i-a-n-s-,- -N-e-g-r-o-s-,- -b-l-a-c-k- -a-s- -C-a-i-n-,-\n", - "-M-a-y- -b-e- -r-e-f-i-n-'-d-,- -a-n-d- -j-o-i-n- -t-h-'- -a-n-g-e-l-i-c- -t-r-a-i-n-.-\n", - "-\n", - "- - - - - - - - - - - - -B-Y- -P-H-I-L-L-I-S- -W-H-E-A-T-L-E-Y-" - ] - } - ], - "source": [ - "for c in s:\n", - " print(c,end='-')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your task**:\n", - "Write code that counts and outputs\n", - "1. The number of lines in the string `s`.\n", - "2. The number of non-whitespace characters (whitespace is `' '`, `'\\t'` (tab), `'\\n'` (newline)\n", - "3. The number of words." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "s = \"\"\"May be refin'd, and join th' angelic train.\n", - " \n", - " BY PHILLIS WHEATLEY\"\"\"\n", - "\n", - "print(s)" - ] - }, - { - "cell_type": "code", - "execution_count": 59, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Found 10 lines\n", - "Found 299 printable characters\n", - "Found 61 words\n" - ] - } - ], - "source": [ - "# list of white space chars (tuple, actually)\n", - "whitespace = (' ','\\n','\\t','\\0')\n", - "\n", - "# initialize counters\n", - "num_lines = 1\n", - "num_chars = 0\n", - "num_words = 0\n", - "\n", - "# do the counting\n", - "\n", - "previous_c = ''\n", - "\n", - "for c in s:\n", - " if c == '\\n':\n", - " num_lines += 1\n", - " if c not in whitespace: \n", - " # c is a character\n", - " num_chars += 1\n", - " else: \n", - " # c is a white space\n", - " if previous_c not in whitespace:\n", - " num_words += 1\n", - " previous_c = c\n", - " \n", - "if previous_c not in whitespace:\n", - " num_words += 1\n", - " \n", - "print(\"Found {} lines\".format(num_lines))\n", - "print(\"Found {} printable characters\".format(num_chars))\n", - "print(\"Found {} words\".format(num_words))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 3: Some linear algebra\n", - "\n", - "**Theory**: \n", - "The eigenvalue problem for a symmetric matrix ${\\bf A}$ is defined as\n", - "$$\n", - " ({\\bf A}-\\lambda_i {\\bf 1})\\,{\\bf n_i} = {\\bf 0}\n", - "$$\n", - "where $\\lambda_i$ is the $i^{th}$ eigenvalue and ${\\bf n}$ is the $i^{th}$ eigenvector.\n", - "\n", - "Pre-multiplying this equation with the eigenvector yields\n", - "$$\n", - " {\\bf n_i}\\cdot({\\bf A}-\\lambda_i {\\bf 1})\\,{\\bf n_i} = 0\n", - " \\quad\\Rightarrow\\quad\n", - " \\lambda_i = \\frac{{\\bf n_i}\\cdot{\\bf A}\\cdot{\\bf n_i}}{{\\bf n_i}\\cdot{\\bf n_i}}\n", - "$$\n", - "The expression for $\\lambda_i$ is the _Rayleigh coefficient_.\n", - "\n", - "**Your tasks**:\n", - "1. use `numpy.linalg.eig` to solve to find eigenvalues and eigenvectors of the given matrix ${\\bf A}$\n", - "2. in a loop, verify that the _Rayleigh coefficient_ indeed yields the eigenvalues.\n", - "3. test, whether or not the following expression is true\n", - " $$\n", - " \\text{for}~~{\\bf v}=\\frac{\\sqrt{2}}{2}({\\bf n}_1+{\\bf n}_2)\n", - " \\quad\\to\\quad\n", - " \\frac{{\\bf v}\\cdot{\\bf A}\\cdot{\\bf v}}{{\\bf v}\\cdot{\\bf v}} = \\frac{\\lambda_1 + \\lambda_2}{2}\n", - " $$\n", - " whill this result hold for ${\\bf v}=({\\bf n}_1+{\\bf n}_2)$?" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1.0, 2.0, 3]\n", - "[1. 2. 3.]\n" - ] - } - ], - "source": [ - "from numpy import array\n", - "\n", - "lvec = [1.,2.,3]\n", - "print(lvec)\n", - "vec = array( [1.,2.,3] )\n", - "print(vec)" - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1.0, 2.0, 3, 1.0, 2.0, 3]\n", - "[2. 4. 6.]\n" - ] - } - ], - "source": [ - "print(lvec + lvec)\n", - "print(vec + vec)" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "2.0" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "vec[1]" - ] - }, - { - "cell_type": "code", - "execution_count": 114, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[3 2 1 0 0]\n", - " [2 3 2 1 0]\n", - " [1 2 3 2 1]\n", - " [0 1 2 3 2]\n", - " [0 0 1 2 3]]\n" - ] - } - ], - "source": [ - "# GIVEN ... please execute this cell to initialize A\n", - "\n", - "from numpy import array\n", - "\n", - "A = array(\n", - " [[3,2,1,0,0],\n", - " [2,3,2,1,0],\n", - " [1,2,3,2,1],\n", - " [0,1,2,3,2],\n", - " [0,0,1,2,3]]\n", - ")\n", - "\n", - "B = [[3,2,1,0,0], [2,3,2,1,0], [1,2,3,2,1], [0,1,2,3,2], [0,0,1,2,3]]\n", - "\n", - "print(A)" - ] - }, - { - "cell_type": "code", - "execution_count": 115, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1" - ] - }, - "execution_count": 115, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "B[1][3]" - ] - }, - { - "cell_type": "code", - "execution_count": 116, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "1" - ] - }, - "execution_count": 116, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "A[1,3]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I define helper functions to compute the Rayleigh coefficient and to perform a relaxed floating point comparison" - ] - }, - { - "cell_type": "code", - "execution_count": 117, - "metadata": {}, - "outputs": [], - "source": [ - "def rayleigh(A,v):\n", - " ans = (v @ A @ v)/(v @ v)\n", - " return ans\n", - "\n", - "#def test_equal(a,b):\n", - "# if abs(b-a) < 1.e-12:\n", - "# return True\n", - "# else:\n", - "# return False\n", - "\n", - "def test_equal(a,b):\n", - " return ( abs(b-a) < 1.e-12 )" - ] - }, - { - "cell_type": "code", - "execution_count": 118, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0.43844719 0.59802377 1.74770274 4.56155281 7.65427349]\n", - "[[ 4.35162146e-01 1.02801351e-01 6.17548407e-01 5.57345410e-01\n", - " -3.28733703e-01]\n", - " [-5.57345410e-01 -4.82004424e-01 -1.78297793e-01 4.35162146e-01\n", - " -4.85676469e-01]\n", - " [-1.60982339e-15 7.17082447e-01 -4.16758592e-01 -1.94289029e-16\n", - " -5.58663621e-01]\n", - " [ 5.57345410e-01 -4.82004424e-01 -1.78297793e-01 -4.35162146e-01\n", - " -4.85676469e-01]\n", - " [-4.35162146e-01 1.02801351e-01 6.17548407e-01 -5.57345410e-01\n", - " -3.28733703e-01]]\n" - ] - } - ], - "source": [ - "from numpy import sqrt\n", - "from numpy.linalg import eig, eigh, norm\n", - "\n", - "# 1. *****************\n", - "\n", - "(lam, nvec) = eigh(A)\n", - "\n", - "# MAYBE SOME PRINT TO SEE HOW THE ANSWER LOOKS LIKE:\n", - "print(lam)\n", - "print(nvec)" - ] - }, - { - "cell_type": "code", - "execution_count": 119, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0.4384471871911694\n", - "[ 4.35162146e-01 -5.57345410e-01 -1.60982339e-15 5.57345410e-01\n", - " -4.35162146e-01]\n", - "[-2.77555756e-17 -9.15933995e-16 -1.29257891e-15 -3.33066907e-16\n", - " -5.55111512e-17]\n", - "1.6200249209257316e-15 True\n" - ] - } - ], - "source": [ - "lam1=lam[0]\n", - "n1 = nvec[:,0]\n", - "\n", - "print(lam1)\n", - "print(n1)\n", - "\n", - "test = A @ n1 - lam1 * n1\n", - "print(test)\n", - "\n", - "print(norm(test), test_equal(norm(test), 0.0))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 120, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "from eig: 0.438447187191 <=> Rayleigh: 0.438447187191 => True\n", - "from eig: 0.598023766437 <=> Rayleigh: 0.598023766437 => True\n", - "from eig: 1.747702740583 <=> Rayleigh: 1.747702740583 => True\n", - "from eig: 4.561552812809 <=> Rayleigh: 4.561552812809 => True\n", - "from eig: 7.654273492980 <=> Rayleigh: 7.654273492980 => True\n" - ] - } - ], - "source": [ - "# 2. *****************\n", - "\n", - "# format string: lambda from eig, Rayleigh coefficient, answer of comparison test_equal\n", - "template = \"from eig: {:16.12f} <=> Rayleigh: {:16.12f} => {}\"\n", - "\n", - "# YOUR CODE HERE ...\n", - "for i in range(5):\n", - " ev = lam[i]\n", - " nv = nvec[:,i]\n", - "\n", - " ll = rayleigh(A,nv)\n", - " print(template.format(ev,ll,test_equal(ev,ll)))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. test, whether or not the following expression is true\n", - " $$\n", - " \\text{for}~~{\\bf v}=\\frac{\\sqrt{2}}{2}({\\bf n}_1+{\\bf n}_2)\n", - " \\quad\\to\\quad\n", - " \\frac{{\\bf v}\\cdot{\\bf A}\\cdot{\\bf v}}{{\\bf v}\\cdot{\\bf v}} = \\frac{\\lambda_1 + \\lambda_2}{2}\n", - " $$\n", - " whill this result hold for ${\\bf v}=({\\bf n}_1+{\\bf n}_2)$?" - ] - }, - { - "cell_type": "code", - "execution_count": 121, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "from eig: 0.518235476814 <=> Rayleigh: 0.518235476814 => True\n" - ] - } - ], - "source": [ - "# 3 *****************\n", - "\n", - "import numpy as np\n", - "\n", - "v = np.sqrt(2.)/2 * (nvec[:,0] + nvec[:,1])\n", - "target = (lam[0] + lam[1])/2.\n", - "rel = rayleigh(A, v)\n", - "\n", - "print(template.format(target,rel,test_equal(target,rel)))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 4: Conversion from MATLAB\n", - "\n", - "You may already have some MATLAB code that you want to migrate to python. Using the `matrix` type is a quick and dirty way, though using `array` is the _highly_ recommended way.\n", - "\n", - "Using the `array` type, try converting this MATLAB code segment into python\n", - "\n", - "```matlab\n", - "x = linspace(0,10,11)';\n", - "x2 = x.*x; # generates a list of x^2\n", - "one = ones(11,1); # a vector full of ones\n", - "y = sin(pi*x/10);\n", - "\n", - "A = [ one'*one, one'*x, one'*x2\n", - " x'*one, x'*x, x'*x2\n", - " x2'*one, x2'*x, x2'*x2 ];\n", - "\n", - "b = [ y'*one; y'*x; y'*x2 ];\n", - "\n", - "p = A\\b\n", - "\n", - "ybar = [ one, x, x2 ]*p;\n", - "\n", - "errvec = y-ybar;\n", - "\n", - "err = sqrt((errvec'*errvec)/length(x))\n", - "```\n", - "\n", - "which generates\n", - "\n", - "~~~\n", - "p =\n", - "\n", - " -0.025578\n", - " 0.399704\n", - " -0.039970\n", - "\n", - "err = 0.021912\n", - "~~~\n", - "\n", - "**hints**:\n", - "1. Think vector as 1D-array and matrix as 2D-array\n", - "2. think matrix or dot product -> @\n", - "3. the `numpy.hstack` or `numpy.vstack` function may come in handy" - ] - }, - { - "cell_type": "code", - "execution_count": 128, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[ 0. 0.5 1. 1.5 2. 2.5 3. 3.5 4. 4.5 5. 5.5 6. 6.5\n", - " 7. 7.5 8. 8.5 9. 9.5 10. ]\n", - "[1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]\n", - "[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n" - ] - } - ], - "source": [ - "from numpy import linspace, sqrt, sin, ones, ones_like, zeros_like, pi, vstack, hstack\n", - "from numpy.linalg import solve\n", - "\n", - "x = linspace(0,10,21)\n", - "print(x)\n", - "print(ones_like(x))\n", - "print(zeros_like(x))" - ] - }, - { - "cell_type": "code", - "execution_count": 130, - "metadata": {}, - "outputs": [], - "source": [ - "from numpy import linspace, sqrt, sin, ones, ones_like, pi, vstack, hstack\n", - "from numpy.linalg import solve\n", - "\n", - "# ***************************************************************\n", - "# I copied the MATLAB code below for you to modify into python\n", - "# ***************************************************************\n", - "\n", - "x = linspace(0,10,11)\n", - "x2 = x*x # generates a list of x^2\n", - "one = ones_like(x) # a vector full of ones\n", - "y = sin(pi*x/10)\n", - "\n", - "A = array(\n", - " [ [one @ one, one @ x, one @ x2],\n", - " [ x @ one, x @ x, x @ x2],\n", - " [ x2 @ one, x2 @ x, x2 @ x2] ]\n", - " )\n", - "\n", - "b = array( [ y @ one, y @ x, y @ x2 ] )\n", - "\n", - "# solve A @ p = b\n", - "p = solve( A, b )\n", - "\n", - "#\n", - "ybar = p @ array( [ one, x, x2 ] )\n", - "\n", - "errvec = y - ybar\n", - "\n", - "err = sqrt((errvec @ errvec)/len(x))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1 x1 y1\n", - "1 x2 y2\n", - "1 x3 y3\n", - "1 x4 y4\n", - "\n", - "[ [1 1 1 1], [x1 x2 x3 x4], [y1 y2 y3 y4]]\n", - "\n", - " 1 1 1 1\n", - "x1 x2 x3 x4\n", - "y1 y2 y3 y4" - ] - }, - { - "cell_type": "code", - "execution_count": 133, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAwu0lEQVR4nO3dd3hUVfrA8e9LKAGSBQSNIJAARqRJCaKIVHEXEEVXVsHQFgRRQZqFFX+iYFxZUJClKFaUICgWsKArmCC6qBRRKRakhIBLiQIJENLO748TwhAS0mbmTnk/z5MnmTt37rwnM/Pm5txz3iPGGJRSSvm/ck4HoJRSyj00oSulVIDQhK6UUgFCE7pSSgUITehKKRUgyjv1xLVq1TJRUVGleuzx48epWrWqewPycdrm4KBtDg5lafPGjRsPG2MuLOg+xxJ6VFQUGzZsKNVjExMT6dKli3sD8nHa5uCgbQ4OZWmziOwp7D7tclFKqQChCV0ppQKEJnSllAoQmtCVUipAaEJXSqkAUWRCF5GXReSgiGwp5H4RkdkiskNEvheRNu4PUykviI+HqCgoV85+j493OiKlSqQ4Z+ivAj3Oc39PIDr3awQwv+xhKeVl8fEwYgTs2QPG2O8jRmhSV36lyIRujPkc+P08u/QBXjPWV0B1EantrgCV8opJk+DEibO3nThhtyvlJ9wxsegSYK/L7eTcbb/l31FERmDP4omIiCAxMbFUT5iWllbqx/orbbNndU5KQgrYbpKSWOPF37u+zsHBY202xhT5BUQBWwq57wPgWpfbq4G2RR0zJibGlFZCQkKpH+uvtM0eFhlpjO1sOfsrMtJ7MRh9nYNFWdoMbDCF5FV3jHLZB9RzuV03d5tS/iMuDqpUOXtblSp2u1J+wh0JfQUwKHe0y9XAUWPMOd0tSvm02FhYsAAiI0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2YAScBvwFFjzH+cjcprIowxv+X+/D8gwl0H9reEHrREJAx4GxhrjDnmdDyeIiK9gYPGmI1Ox+JF5YE2wHxjTGvgOG78N9wX5fYb98H+MasDVBWRAc5G5X3Gjht329hxf0vo+4B6Lrfr5m4LaCJSAZvM440x7zgdj4d1AG4Skd3YLrVuIrLI2ZA8LhlINsac/s9rGTbBB7LuwC5jzCFjTCbwDnCNwzF5ywERqQ2Q+/2guw7sbwl9PRAtIg1EpCL2IsoKh2PyKBERbN/qdmPMM07H42nGmH8YY+oaY6Kwr+9nxpiAPnMzxvwP2CsijXM3XQdsczAkb0gCrhaRKrnv8esI8AvBLlYAg3N/Hgwsd9eB/WoJOmNMloiMAj7BXhV/2Riz1eGwPK0DMBD4QUQ252572BjzkXMhKQ8YDcTnnqjsBP7ucDweZYz5WkSWAZuwI7m+JQBLAIjIG0AXoJaIJAOTgaeAN0VkGLaE+G1uez6d+q+UUoHB37pclFJKFUITulJKBQhN6EopFSA0oSulVIDQhK6UUgFCE7pSSgUITehKKRUg/h+dxIBm0fTvlQAAAABJRU5ErkJggg==\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "import matplotlib.pyplot as plt\n", - "\n", - "plt.plot(x,y,'or', label='raw data')\n", - "plt.plot(x,ybar,'-b', label='quadratic lsq-fit')\n", - "plt.grid()\n", - "plt.legend()\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework questions\n", - "\n", - "We can all learn from your questions!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 04-some more numpy and plotting-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 04-some more numpy and plotting-checkpoint.ipynb deleted file mode 100644 index 42c3399..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 04-some more numpy and plotting-checkpoint.ipynb +++ /dev/null @@ -1,363 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#4: Some more Matrix Operations & Plotting\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources (reminder)\n", - "\n", - " 1. matplotlib: https://matplotlib.org/\n", - " \n", - " 1. **matplotlib gallery**: https://matplotlib.org/gallery/index.html\n", - " \n", - " 1. numpy: https://numpy.org/doc/stable/ \n", - " \n", - " 1. numpy tutorials: https://numpy.org/doc/stable/user/tutorials_index.html\n", - " \n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 1: Linear regression (without using libraries)\n", - "\n", - "**Given**:\n", - "A data set is composed of two lists: input parameters `X` and corresponsing measured answers `Y`. A single data point, $i$, is composed as $(X_i,Y_i)\\to$`(X[i],Y[i])` with $i=0,\\dots,N-1$.\n", - "\n", - "**Find**: The best linear fit for the provided data. You need to develop your own implementation of the computations. DO NOT USE regression library functions for this assignment!\n", - "\n", - "**Theory**:\n", - "The data shall be approximated using a function\n", - "$$ Y=f(X,a,b):=a + b X $$\n", - "Using the _least square fit_ technique requires minimization of the cost function\n", - "$$ \\mathcal{C}(a,b):=\\frac{1}{2} \\sum_{i=0}^{N-1} \\left( f(X_i, a,b) - Y_i \\right)^2 \n", - "~~~\\to~~\\text{min}$$\n", - "\n", - "___Solution:___ \n", - "$$ \n", - "\\frac{\\partial\\mathcal{C}}{\\partial a} \n", - "= \\sum_{i=0}^{N-1} \\left( f(X_i, a,b) - Y_i \\right)\n", - "\\to (\\sum_{i=0}^{N-1} 1) a + (\\sum_{i=0}^{N-1} X_i) b = \\sum_{i=0}^{N-1} Y_i\n", - "$$\n", - "$$ \n", - "\\frac{\\partial\\mathcal{C}}{\\partial b} \n", - "= \\sum_{i=0}^{N-1} \\left( f(X_i, a,b) - Y_i \\right) X_i\n", - "\\to (\\sum_{i=0}^{N-1} X_i) a + (\\sum_{i=0}^{N-1} X_i X_i) b = \\sum_{i=0}^{N-1} Y_i X_i\n", - "$$\n", - "\n", - "**Implementation requirements**:\n", - "Try to identify sums as dot products and use `numpy.array`s to \n", - "1. store data\n", - "2. compute dot products\n", - "3. use `numpy.linalg.solve` to solve the resulting system of equations.\n", - "4. use `matplotlib` to plot the data **and** the regression function.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAfe0lEQVR4nO2dXYwmWVnH/0/3dsftWRD2nQnqst29GqLZcLG4LaCgQaIGJ8bVG4NpNntjRhqIi3JDnAtIzFz5BTGsSauzO9I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uH1OIDX4jC8HocZ5fXoxUdNCCHEHbo+CCGkcCjUhBBSOJ0KtYi8RUS+ISLPish7uzx2iYjIBRH5qoh8WUT2+y5P14jIWRH5noh8rbHubhH5NxH5r9nfl/dZxi7RXI/3i8hzs2fkyyJyss8ydoWI3CsinxWRr4vI0yLy6Gz9KJ+PzoRaRJYBfAjArwO4H8Dvisj9XR2/YH5ZKfXAGHNDATwB4C1z694L4DNKqVcB+Mzs81h4AkevBwD85ewZeUApdb7jMvXFTQDvUUrdD+D1AN4504tRPh9dWtSvBfCsUuqbSqkbAD4G4KEOj08KQyn17wCuza1+CMC52f/nAPxWl2XqE831GCVKqeeVUl+c/f8DAM8AuAcjfT66FOp7AHy78fk7s3VjRgH4tIg8JSKn+i5MIbxCKfX87P//AfCKPgtTCO8Ska/MXCOjaOo3EZFNAK8B8HmM9PlgMLFf3qiU+llU7qB3isgv9V2gklBV7ujY80f/GsBPAXgAwPMA/rzX0nSMiNwF4BMA3q2U+n7zuzE9H10K9XMA7m18fuVs3WhRSj03+/s9AP+Iyj00dr4rIj8OALO/3+u5PL2ilPquUuqWUuo2gL/BiJ4REVlBJdJTpdQnZ6tH+Xx0KdRfAPAqEblPRFYBvBXAkx0evyhE5JiIvKT+H8CvAfia+Vej4EkAj8z+fwTAP/VYlt6pRWnGb2Mkz4iICIC/A/CMUuovGl+N8vnotGfiLLXoAwCWAZxVSp3p7OCFISI/icqKBqpJhj8ytushIh8F8CZUQ1d+F8D7AHwKwD8AWEc1VO7vKKVGEWDTXI83oXJ7KAAXAPx+w0e7sIjIGwF8DsBXAdyerf5jVH7q0T0f7EJOCCGFw2AiIYQUDoWaEEIKh0JNCCGFQ6EmhJDCoVATQkjhUKgJIaRwKNSEEFI4/w9mQwtEKXtWJwAAAABJRU5ErkJggg==\n", - "text/plain": [ - "
" - ] - }, - "metadata": { - "needs_background": "light" - }, - "output_type": "display_data" - } - ], - "source": [ - "# The data -- will be a bit different every time you run it!\n", - "import numpy as np\n", - "\n", - "N = 250\n", - "X = np.random.uniform(0.5,23,N)\n", - "Y = np.pi/4 + 5.*np.sin(X * np.pi/35) + np.random.normal(0.,1,N)\n", - "\n", - "import matplotlib.pyplot as plt\n", - "plt.plot(X,Y,'or')\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**My equations to solve**:\n", - "\n", - "$$ \n", - " ({\\bf 1}\\cdot{\\bf 1}) a + ({\\bf 1}\\cdot{\\bf X}) b = ({\\bf 1}\\cdot{\\bf Y})\n", - "$$\n", - "$$ \n", - " ({\\bf X}\\cdot{\\bf 1}) a + ({\\bf X}\\cdot{\\bf X}) b = ({\\bf X}\\cdot{\\bf Y})\n", - "$$\n", - "where\n", - "$$\n", - "\\begin{aligned}\n", - "{\\bf X} &= [X_0,X_1,X_2,\\dots,X_{N-1}] \\\\\n", - "{\\bf Y} &= [Y_0,Y_1,Y_2,\\dots,Y_{N-1}] \\\\\n", - "{\\bf 1} &= [\\underbrace{1,1,1,\\dots,1}_{N~\\text{entries}}] \n", - "\\end{aligned}\n", - "$$\n", - "\n", - "**Your task**: \n", - "Compute the coefficients and solve for the best fitting parameters" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from numpy import array, linspace, sqrt, ones, vstack\n", - "from numpy.linalg import solve\n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "print(\"parameters p = {}\".format(p))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Next task**: Compute your regression function and **add it to the plot**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# plotting\n", - "N = 10\n", - "x = linspace(X.min(),X.max(),N)\n", - "\n", - "# YOUR CODE HERE:\n", - "#\n", - "# y = ...\n", - "\n", - "plt.plot(X,Y,'or')\n", - "#plt.plot(x,y,'-b')\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2: Regression using numpy\n", - "\n", - "**Resource**: https://numpy.org/doc/stable/reference/generated/numpy.linalg.lstsq.html (scroll down to the example)\n", - "\n", - "**Your task**:\n", - "Use `numpy.linalg.lstsq` to obtain a linear regression fit **and** plot it\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from numpy.linalg import lstsq\n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "print(p)\n", - "\n", - "# ---------------\n", - "# plotting\n", - "# ---------------\n", - "\n", - "N = 10\n", - "x = linspace(X.min(),X.max(),N)\n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "plt.plot(X,Y,'or')\n", - "#plt.plot(x,y,'-b')\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your task**:\n", - "Modify the above to get a quadratic fit **and** add that one to the above plot" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from numpy.linalg import lstsq\n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "\n", - "# ---------------\n", - "# plotting\n", - "# ---------------\n", - "\n", - "N = 10\n", - "x = linspace(X.min(),X.max(),N)\n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "plt.plot(X,Y,'or')\n", - "#plt.plot(x,y,'-b')\n", - "#plt.plot(x,y2,'-g')\n", - "plt.show()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 3: \n", - "\n", - "**Resources**:\n", - "1. **matplotlib gallery**: https://matplotlib.org/3.1.1/gallery/index.html\n", - "\n", - "\n", - "**Your task**:\n", - "1. A landscape shall be descrobed by the function\n", - "$$\n", - " z = (x-1)^2 - 3 x y + 0.2 (y-2)^2\n", - "$$\n", - "where $z$ is the elevation. Plot a map (`contour plot`) over $-2 (X0, X1, X2)\n", - "3. collect all data in a list of data points\n", - "4. plot X1 versus X2 (X1 on the horizontal, X2 on the vertical axis). Set aspect to equal.\n", - "\n", - "**Useful functions**:\n", - "- I found all the useful information on: https://docs.python.org/3.1/library/struct.html#functions-and-exceptions\n", - "- check out `struct.pack`, `struct.unpack`, `struct.calcsize`, and `struct.peek`\n", - "- you may need the `size` argument to `f.read(size)`\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import sys\n", - "import numpy as np\n", - "from struct import *\n", - "import matplotlib.pyplot as plt\n", - "\n", - "\n", - "try:\n", - " f = open('weird_stuff.cesg','rb')\n", - "except IOError:\n", - " print('Cannot open file for binary reading')\n", - " sys.exit(1)\n", - " \n", - "\n", - "# YOUR CODE HERE ...\n", - "\n", - "\n", - "# plot data read from file\n", - "\n", - "ax = plt.subplot(111)\n", - "ax.plot(...)\n", - "ax.grid(True)\n", - "# more of your code ...\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework questions\n", - "\n", - "We can all learn from your questions!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.11.6" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 06-Introduction to Object Oriented Programming-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 06-Introduction to Object Oriented Programming-checkpoint.ipynb deleted file mode 100644 index 3d8e104..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 06-Introduction to Object Oriented Programming-checkpoint.ipynb +++ /dev/null @@ -1,197 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#6 : Introduction to Object Oriented Programming (OOP)\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources (reminder)\n", - " \n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. **Classes**: https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Questions & Discussion\n", - "\n", - "Reserving time for questions on Assignment \\#4\n", - "\n", - "..." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 1: Thinking about Objects\n", - "\n", - "**Given**:\n", - "\n", - "A large project requires collaboration of multiple companies and administrative entities. Each of these collaborators will have to manage their own company, do internal business, and business with (one or many) customers. Each entity will require their own internal organization, hold protected and public information, conduct their business, and communicate and coordinate with customers.\n", - "\n", - "\n", - "**Your Task**:\n", - "\n", - "Each team represents one company:\n", - "* Breakout Room \\#1: ***'BIG BANK'***, a large financial institution.\n", - "* Breakout Room \\#2: ***'PAVE A AWAY'***, a construction firm specializing in road construction.\n", - "* Breakout Room \\#3: ***'WIDE SPAN'***, a company specializing in concrete bridge construction.\n", - "* Breakout Room \\#4: ***'ENGI-NERDS'***, a large structural analysis firm.\n", - "\n", - "Discuss the following and enter the answers in the provided google sheet.\n", - "1. What kind of **internal** information do you keep?\n", - "1. What kind of **public per customer** information do you keep?\n", - "1. What kind of **public for everybody** information do you keep?\n", - "1. What kind of **internal/private** tasks does your company do?\n", - "1. What kind of **public** tasks does your company do?\n", - "\n", - "- Shared work sheet: https://docs.google.com/spreadsheets/d/1L8sMNIizG5wpyNwhykgAmgTtmTOxON5unv1EAfasi6M/edit?usp=sharing\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2: Thinking about access functions\n", - "\n", - "Now that you have established your company's setup, let's look what it takes to actually conduct some business.\n", - "\n", - "**Your Task**:\n", - "\n", - "Discuss the following and enter the answers in the provided google sheet.\n", - "1. What kind of **requests** should your company receive?\n", - "1. What kind of **services** will your company provide? (response to requests)\n", - "1. What kind of **requests** should your company post toward other companies?\n", - "\n", - "- Shared work sheet: https://docs.google.com/spreadsheets/d/1L8sMNIizG5wpyNwhykgAmgTtmTOxON5unv1EAfasi6M/edit?usp=sharing\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 3: Defining an object in Python\n", - "\n", - "In python, pretty much everything is an object - defined as a `class`. Classes can go from very simple to very complex. Let's start by creating an extensed data type that holds data in a form:\n", - "\n", - "| data | variable | type |\n", - "|:----------|:-------------|:-----------|\n", - "| first name | `_.first_name` | string | \n", - "| last name | `_.last_name` | string | \n", - "| email | `_.email` | string | \n", - "| phone number | `_.phone` | string |\n", - "| year of birth | `_.YOB` | integer | \n", - "\n", - "`_` stands for any variable name representing an instance of the class.\n", - "\n", - "**Your tasks**:\n", - "1. Use the provided template and add the missing variables.\n", - "1. Why " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class MyDataType():\n", - " \n", - " def __init__(self):\n", - " self.first_name = 'Jane'\n", - " self.last_name = 'Doe'\n", - " # more here\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**How to use this**:\n", - "\n", - "Executing the above cell did not produce any output. Actually, it didn't run any code either but instead defined the class. Things will be executed once we create some instances of that class.\n", - "\n", - "1. create two instances or `MyDataType` named `student1` and `student1`.\n", - "1. modify the ***instance*** `student2` to hold your information.\n", - "1. create a print statement that shows all the information stored for ***both*** instances" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "student1 = MyDataType()\n", - "student2 = .....\n", - "\n", - "# YOUR CODE HERE" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(student1)\n", - "print(student2)" - ] - } - ], - "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.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 07-Inheritance (OOP 2)-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 07-Inheritance (OOP 2)-checkpoint.ipynb deleted file mode 100644 index cdccc30..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Lesson 07-Inheritance (OOP 2)-checkpoint.ipynb +++ /dev/null @@ -1,814 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# A Python Quick Start Tutorial\n", - "# Lesson \\#7 : Inheritance (OOP cont'd)\n", - "## by Peter Mackenzie-Helnwein\n", - "University of Washington, Seattle, WA\n", - "\n", - "pmackenz@uw.edu \n", - "https://www.ce.washington.edu/facultyfinder/peter-mackenzie-helnwein" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Resources (reminder)\n", - " \n", - " 1. Python Docs: https://docs.python.org/3/\n", - " \n", - " 1. Python Tutorial (comprehensive): https://docs.python.org/3/tutorial/index.html\n", - " \n", - " 1. **Classes**: https://docs.python.org/3/tutorial/classes.html#a-first-look-at-classes\n", - " \n", - " 1. **Inheritance**: https://docs.python.org/3/tutorial/classes.html#inheritance\n", - " \n", - " 1. Python Library Reference (the nitty-gritty details): https://docs.python.org/3/library/index.html\n", - " \n", - " 1. Everything else: http://google.com\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Questions & Discussion\n", - "\n", - "Reserving time for questions on Assignment \\#4\n", - "\n", - "..." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Discussing questions from the self-study assignment\n", - "\n", - "This section is to discuss your questions\n", - "\n", - "...\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Demonstration: Using the debugger\n", - "\n", - "***\"Bug-free code is a soleley theoretical concept!\"***\n", - "\n", - "_This exercise is a continuation of our Lesson 8 exercises._\n", - "\n", - "**Your task**:\n", - "Execute the following *3* cells to\n", - "1. define an alternative form of `MyDataType`\n", - "1. cause an exception\n", - "1. look at the traceback information with the debugger" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "class MyDataType():\n", - " \n", - " def __init__(self,\n", - " first = 'Jane',\n", - " last = 'Doe',\n", - " email = 'jane.doe@gmail.com',\n", - " phone = '(000) 000-0000',\n", - " yob = 2000):\n", - " \n", - " self.first_name = first\n", - " self.last_name = last\n", - " self.email = email\n", - " self.phone = phone\n", - " self.YOB = yob\n", - " \n", - " #raise\n", - " \n", - " def __str__(self):\n", - " s = \"First name: {}\\n\".format(self.first_name)\n", - " s += \"Last name: {}\\n\".format(self.last_name)\n", - " s += \"E-mail: {}\\n\".format(self.email)\n", - " s += \"Phone number: {}\\n\".format(self.phone)\n", - " s += \"Year of birth: {}\\n\".format(self.YOB)\n", - " \n", - " return s" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "<__main__.MyDataType at 0x105990160>" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "student1 = MyDataType()\n", - "student2 = MyDataType(first='John',email='john.doe@hotmail.com')\n", - "\n", - "# sloppy printing statement\n", - "student1" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "> \u001b[0;32m\u001b[0m(16)\u001b[0;36m__init__\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32m 14 \u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mYOB\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0myob\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 15 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m---> 16 \u001b[0;31m \u001b[0;32mraise\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 17 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 18 \u001b[0;31m \u001b[0;32mdef\u001b[0m \u001b[0m__str__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\n", - "ipdb> q\n" - ] - } - ], - "source": [ - "%debug" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**TO DO**:\n", - "remove the `raise` in the above constructor (`__init__(self)`) before moving to the next cell." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: Jane\n", - "Last name: Doe\n", - "E-mail: jane.doe@gmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n" - ] - } - ], - "source": [ - "# the propper printing statement\n", - "\n", - "print(student1)\n", - "print(student2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**What's the difference?**\n", - "\n", - "`print(student1)` => `print(str(student1))` => `print(student1.__str__())` => `print(MyDataType.__str__(student1))`\n", - "\n", - "`student1` => `repr(student1)` => `student1.__repr__()` => `MyDataType.__repr__(student1)`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Your task**: \n", - "Fix the code in the cell below such that the next two cells execute without the exception" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "class MyDataType():\n", - " \n", - " def __init__(self,\n", - " first = 'Jane',\n", - " last = 'Doe',\n", - " email = 'jane.doe@gmail.com',\n", - " phone = '(000) 000-0000',\n", - " yob = 2000):\n", - " \n", - " self.first_name = first\n", - " self.last_name = last\n", - " self.email = email\n", - " self.phone = phone\n", - " self.YOB = yob\n", - " \n", - " #raise\n", - " \n", - " def __str__(self):\n", - " s = \"First name: {}\\n\".format(self.first_name)\n", - " s += \"Last name: {}\\n\".format(self.last_name)\n", - " s += \"E-mail: {}\\n\".format(self.email)\n", - " s += \"Phone number: {}\\n\".format(self.phone)\n", - " s += \"Year of birth: {}\\n\".format(self.YOB)\n", - " \n", - " return s\n", - " \n", - " def __repr__(self):\n", - " tmp = \"MyDataType(first='{}', last='{}', email='{}', phone='{}', yob={} )\"\n", - " s = tmp.format( self.first_name,\n", - " self.last_name,\n", - " self.email,\n", - " self.phone,\n", - " self.YOB )\n", - " return s\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: Jane\n", - "Last name: Doe\n", - "E-mail: jane.doe@gmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "MyDataType(first='Jane', last='Doe', email='jane.doe@gmail.com', phone='(000) 000-0000', yob=2000 )\n", - "MyDataType(first='John', last='Doe', email='john.doe@hotmail.com', phone='(000) 000-0000', yob=2000 )\n" - ] - } - ], - "source": [ - "student1 = MyDataType()\n", - "student2 = MyDataType(first='John',email='john.doe@hotmail.com')\n", - "\n", - "print(student1)\n", - "print(student2)\n", - "\n", - "print(repr(student1))\n", - "print(repr(student2))" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "> \u001b[0;32m\u001b[0m(16)\u001b[0;36m__init__\u001b[0;34m()\u001b[0m\n", - "\u001b[0;32m 14 \u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mYOB\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0myob\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 15 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m---> 16 \u001b[0;31m \u001b[0;32mraise\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 17 \u001b[0;31m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\u001b[0;32m 18 \u001b[0;31m \u001b[0;32mdef\u001b[0m \u001b[0m__str__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0m\n", - "ipdb> a\n", - "self = MyDataType(first='Jane', last='Doe', email='jane.doe@gmail.com', phone='(000) 000-0000', yob=2000 )\n", - "first = 'Jane'\n", - "last = 'Doe'\n", - "email = 'jane.doe@gmail.com'\n", - "phone = '(000) 000-0000'\n", - "yob = 2000\n", - "ipdb> q\n" - ] - } - ], - "source": [ - "%debug" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**IMPORTANT**: The `repr(...)` function shall create a string that, when executed, creates a new instance of `MyDataType` that holds the same data." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "student2_copy = MyDataType(first='John', last='Doe', email='john.doe@hotmail.com', phone='(000) 000-0000', yob=2000 )" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n" - ] - } - ], - "source": [ - "print(student2)\n", - "print(student2_copy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The following is to demonstrate that `student2_copy` is a separate instance of `MyDataType`" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (111) 111-1111\n", - "Year of birth: 2000\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "E-mail: john.doe@hotmail.com\n", - "Phone number: (000) 000-0000\n", - "Year of birth: 2002\n", - "\n" - ] - } - ], - "source": [ - "print(student2)\n", - "print(student2_copy)\n", - "\n", - "student2_copy.YOB = 2002\n", - "student2.phone = '(111) 111-1111'\n", - "\n", - "print(student2)\n", - "print(student2_copy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 2: Designing a Family Tree\n", - "\n", - "We want to create a series of classes to represent entries in a family tree. \n", - "Each entry `Individual` shall provide the following methods:\n", - "\n", - "|method|input|returns|notes|\n", - "|:-----|:----|:-----|:----|\n", - "|`first_name`|none|string||\n", - "|`last_name`|none|string||\n", - "|`full_name`|none|string|as `'first last'`|\n", - "|`gender`|none|string|default to `'unknown'`|\n", - "|`DOB`||string|date of birth as string `'YYYY-MM-DD'`|\n", - "|`children`||tuple|as a list of (pointers to) child objects|\n", - "|`partner`||tuple|as a list of (pointers to) partner objects, most cases empty or one, but ...|\n", - "|`add_child`|child object||adds that child to the list of children|\n", - "|`add_partner`|another individual object||add that partner to partner list|\n", - "|`__str__`||string|a nice representation of this `Individual`|\n", - "\n", - "\n", - "**Your Task**:\n", - "1. Given the `Human` class defined below, create the `Individual` class by deriving it from `Human` through **inheritance** and adding **only necessary** methods, thus, minimizing your effort.\n", - "2. add some simple test that creates a small family with parents and two children. Use `print(mom)` (or similar) to produce nice info." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "class Human():\n", - " \"\"\"\n", - " Representation of a Human\n", - " \n", - " variables:\n", - " self.firstname\n", - " self.lastname\n", - " self.gender\n", - " self.date_of_birth\n", - " \n", - " methods:\n", - " __init__(self,first='unknown',last='unknown',gender='unknown',dob='2000-01-01')\n", - " __str__(self)\n", - " __repr__(self)\n", - " first_name(self) ... returns the first name as a string\n", - " last_name(self) ... returns the last name as a string\n", - " full_name(self) \n", - " \"\"\"\n", - " \n", - " def __init__(self,first='unknown',last='unknown',gender='unknown',dob='2000-01-01'):\n", - " self.firstname = first\n", - " self.lastname = last\n", - " self.gender = gender\n", - " self.date_of_birth = dob\n", - " \n", - " def __str__(self):\n", - " s = \"First name: {}\\n\".format(self.firstname)\n", - " s += \"Last name: {}\\n\".format(self.lastname)\n", - " s += \"Gender: {}\\n\".format(self.gender)\n", - " s += \"date of birth: {}\\n\".format(self.date_of_birth)\n", - " return s\n", - " \n", - " def __repr__(self):\n", - " template=\"Human(first='{}',last='{}',gender='{}',dob='{}')\"\n", - " s = template.format(self.firstname,\n", - " self.lastname,\n", - " self.gender,\n", - " self.date_of_birth)\n", - " return s\n", - " \n", - " def first_name(self):\n", - " return self.firstname\n", - " \n", - " def last_name(self):\n", - " return self.lastname\n", - " \n", - " def full_name(self):\n", - " return \"{} {}\".format(self.firstname, self.lastname)\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: unknown\n", - "Last name: unknown\n", - "Gender: unknown\n", - "date of birth: 2000-01-01\n", - "\n", - "First name: John\n", - "Last name: Doe\n", - "Gender: male\n", - "date of birth: 1950-07-04\n", - "\n" - ] - } - ], - "source": [ - "human1 = Human()\n", - "human2 = Human(first='John',last='Doe',gender='male',dob='1950-07-04')\n", - "\n", - "print(human1)\n", - "print(human2)" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [], - "source": [ - "class Individual(Human):\n", - " \"\"\"\n", - " Representation of an Individual\n", - " \n", - " variables:\n", - " self.the_partner = []\n", - " self.the_children = []\n", - " \n", - " variables (inherited):\n", - " self.firstname\n", - " self.lastname\n", - " self.gender\n", - " self.date_of_birth\n", - " \n", - " methods:\n", - " __init__(self,first='unknown',last='unknown',gender='unknown',dob='2000-01-01')\n", - " __str__(self)\n", - " partner(self)\n", - " children(self)\n", - " add_partner(self, partner)\n", - " add_child(self, child)\n", - " \"\"\"\n", - " \n", - " def __init__(self,first='unknown',last='unknown',gender='unknown',dob='2000-01-01'):\n", - " super().__init__(first=first,last=last,gender=gender,dob=dob)\n", - " self.the_partner = []\n", - " self.the_children = []\n", - " \n", - " def __str__(self):\n", - " s = Human.__str__(self)\n", - " s += \"whatever\\n\"\n", - " return s\n", - " \n", - " def partner(self):\n", - " pass\n", - " \n", - " def children(self):\n", - " pass\n", - " \n", - " def add_partner(self, partner):\n", - " pass\n", - " \n", - " def add_child(self, child):\n", - " pass\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First name: Helen\n", - "Last name: Parr\n", - "Gender: female\n", - "date of birth: 1980-03-04\n", - "whatever\n", - "\n", - "First name: Bob\n", - "Last name: Parr\n", - "Gender: male\n", - "date of birth: 1985-01-02\n", - "whatever\n", - "\n" - ] - } - ], - "source": [ - "# creating Individuals\n", - "\n", - "dad = Individual(first='Bob',last='Parr',gender='male',dob='1985-01-02')\n", - "mom = Individual(first='Helen',last='Parr',gender='female',dob='1980-03-04')\n", - "girl = Individual(first='Violet',last='Parr',gender='female',dob='2002-05-06')\n", - "boy = Individual(first='Jack-Jack',last='Parr',gender='male',dob='2004-07-08')\n", - "\n", - "print(mom)\n", - "print(dad)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# connecting individuals\n", - "\n", - "mom.add_partner(dad)\n", - "dad.add_partner(mom)\n", - "\n", - "mom.add_child(girl)\n", - "mom.add_child(boy)\n", - "dad.add_child(girl)\n", - "dad.add_child(boy)\n", - "\n", - "print(mom)\n", - "print(dad)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. Create a new class `AltIndividual` from `Individual` that adds the ability to store information on parents. \n", - " - What member variables need to be added? \n", - " - What methods need to be added?\n", - " - create a simple test and demonstrate the new feature" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class AltIndividual(Individual):\n", - " \"\"\"\n", - " Modify Individual to incorporate parent information\n", - " \n", - " variables:\n", - " self.the_parents = []\n", - " \n", - " variables (inherited):\n", - " self.firstname\n", - " self.lastname\n", - " self.gender\n", - " self.date_of_birth\n", - " self.the_partner = []\n", - " self.the_children = []\n", - " \n", - " methods:\n", - " __str__(self)\n", - " parents(self)\n", - " add_parent(self, parent)\n", - " \"\"\"\n", - " \n", - " def __init__(self,first='unknown',last='unknown',gender='unknown',dob='2000-01-01'):\n", - " pass\n", - " \n", - " def __str__(self):\n", - " pass\n", - " \n", - " def parents(self):\n", - " pass\n", - " \n", - " def add_parent(self, parent):\n", - " pass\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# creating Individuals\n", - "\n", - "dad = AltIndividual(first='Bob',last='Parr',gender='male',dob='1985-01-02')\n", - "mom = AltIndividual(first='Helen',last='Parr',gender='female',dob='1980-03-04')\n", - "girl = AltIndividual(first='Violet',last='Parr',gender='female',dob='2002-05-06')\n", - "boy = AltIndividual(first='Jack-Jack',last='Parr',gender='male',dob='2004-07-08')\n", - "\n", - "# connecting individuals\n", - "\n", - "mom.add_partner(dad)\n", - "dad.add_partner(mom)\n", - "\n", - "mom.add_child(girl)\n", - "mom.add_child(boy)\n", - "dad.add_child(girl)\n", - "dad.add_child(boy)\n", - "\n", - "girl.add_parent(mom)\n", - "girl.add_parent(dad)\n", - "boy.add_parent(mom)\n", - "boy.add_parent(dad)\n", - "\n", - "print(mom)\n", - "print(dad)\n", - "print(girl)\n", - "print(boy)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# a smarter way of creating connections\n", - "\n", - "class SmartIndividual(AltIndividual):\n", - " \"\"\"\n", - " Modify Individual to automatically generate bi-directional relationships\n", - " \"\"\"\n", - " \n", - " # YOUR CODE HERE ...\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# creating Individuals\n", - "\n", - "dad = SmartIndividual(first='Bob',last='Parr',gender='male',dob='1985-01-02')\n", - "mom = SmartIndividual(first='Helen',last='Parr',gender='female',dob='1980-03-04')\n", - "girl = SmartIndividual(first='Violet',last='Parr',gender='female',dob='2002-05-06')\n", - "boy = SmartIndividual(first='Jack-Jack',last='Parr',gender='male',dob='2004-07-08')\n", - "\n", - "# connecting individuals\n", - "\n", - "mom.add_partner(dad)\n", - " # dad.add_partner(mom) ... done automatically\n", - "\n", - "mom.add_child(girl)\n", - " # girl.add_parent(mom) ... done automatically\n", - "mom.add_child(boy)\n", - " # boy.add_parent(mom) ... done automatically\n", - "dad.add_child(girl)\n", - " # girl.add_parent(dad) ... done automatically\n", - "dad.add_child(boy)\n", - " # boy.add_parent(dad) ... done automatically\n", - "\n", - "print(mom)\n", - "print(dad)\n", - "print(girl)\n", - "print(boy)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. discuss potential issues concerning data duplication when assigning a child to both parents.\n", - "\n", - "..." - ] - } - ], - "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.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Pandas Demo-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Pandas Demo-checkpoint.ipynb deleted file mode 100644 index 363fcab..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Pandas Demo-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/code/jupyter/LessonNotes/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/code/jupyter/LessonNotes/.ipynb_checkpoints/Untitled-checkpoint.ipynb deleted file mode 100644 index 363fcab..0000000 --- a/code/jupyter/LessonNotes/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/code/jupyter/LessonNotes/Simulating effect of voter turnout.ipynb b/code/jupyter/LessonNotes/Simulating effect of voter turnout.ipynb deleted file mode 100644 index a30be18..0000000 --- a/code/jupyter/LessonNotes/Simulating effect of voter turnout.ipynb +++ /dev/null @@ -1,392 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Challenge Problem: Simulating the Effect of Low Voter Turnout\n", - "\n", - "## Basic assumptions\n", - "\n", - "Let $\\mathcal{R}$ be the set of **all** registered voters and $\\mathcal{V}:\\mathcal{R}_i\\to v_i\\in\\mathcal{C}$ the set of votes, with $v_i$ as the individual vote, representing the **opinion** of each of the registered voters. $\\mathcal{C}:=[A,B]$ is the set of candiates with $A$ and $B$ being values representing a vote for candidate $A$ or $B$, respectively.\n", - "\n", - "We declare that candidate the **preferred candidate** who collects most votes out of $\\mathcal{V}$.\n", - "\n", - "\n", - "## Voting procedure\n", - "\n", - "Now let $\\mathcal{R}_v\\subset\\mathcal{R}$ be the subset of registered voters, $\\mathcal{R}$, who actually voted. Let $\\mathcal{V}_v\\subset\\mathcal{V}$ be the set of these votes.\n", - "\n", - "We declare that candidate the **winner of the election** who collected most votes out of $\\mathcal{V}_v$.\n", - "\n", - "## Research question\n", - "\n", - "1. Assume 45% (47.5%) of $\\mathcal{V}$ are votes for candidate $A$ and 55% (52.5%) of $\\mathcal{V}$ are votes for candidate $B$ (everybody has a favorite candidate; no omissions).\n", - "2. Assume further that only a random group $\\mathcal{R}_v = \\mathcal{R}/3$ actually votes, i.e., only $\\frac{1}{3}$rd of registered voters actually vote.\n", - "\n", - "What is the probability that the **winner of the election** is **NOT** the **preferred candidate** of the electorate?\n", - "\n", - "## Approach\n", - "\n", - "Develop \n", - "1. a function that randomly generates a list $\\mathcal{R}_v$ and their votes $\\mathcal{V}_v$ by picking the respective votes out of $\\mathcal{V}$.\n", - "2. a function that analyzes a set $\\mathcal{V}$ (or $\\mathcal{V}_v$) and returns the **winner of the election**\n", - "3. a driver function that takes a `number of elections` as argument and simulates that number of random voters and collects the election results.\n", - "4. analyze the set of election results for probability of each candidate to be the **winner of the election**\n", - "\n", - "**Hints**: For plausibility test cases.\n", - "- if $\\mathcal{R}_v = \\mathcal{R}$, then $\\mathcal{V}_v = \\mathcal{V}$, and the **preferred candidate** should win at 100%\n", - "- if $\\mathcal{R}_v$ consists of just one single voter, the **preferred candidate** and the **opposing candiate** should win in 66.67% and 33.33% of the elections, respectively." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Defining the electorate and their choices" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "# candidates (9:11)\n", - "C = ('A','A','A','A','A','A','A','A','A','B','B','B','B','B','B','B','B','B','B','B')\n", - "C = ('A','A','A','A','A','A','A','A','A','B','B','B','B','B','B','B','B','B','B')\n", - "\n", - "# voters\n", - "N_voters = 1000000\n", - "\n", - "R = np.arange(N_voters)\n", - "V = np.array([ C[k%len(C)] for k in range(N_voters) ])\n", - "\n", - "# reduce to unique candidates\n", - "C = ('A','B')" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\t 47.37%\n", - "Candidate B\t 52.63%\n" - ] - } - ], - "source": [ - "# verify that the generated set satisfies\n", - " \n", - "for candidate in C:\n", - " print(\"Candidate {}\\t{:6.2f}%\".format(candidate,100*sum(1 for i in V if i==candidate)/N_voters))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Defining election functions" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def pick_voters(R,V,turnout=1./3.):\n", - " \n", - " N = len(R)\n", - " M = int(N*turnout)\n", - " idx = np.random.randint(0,N,size=M)\n", - " Rv = R[idx]\n", - " Vv = V[idx]\n", - " \n", - " return (Rv,Vv)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "def count_election(Rv,Vv,Candidates):\n", - " N = len(Rv)\n", - " \n", - " winner = {'name': 'unknown',\n", - " 'result': 0.00}\n", - " \n", - " for candidate in Candidates:\n", - " result = sum(1 for i in Vv if i==candidate)/N\n", - " if result > winner['result']:\n", - " winner['name'] = candidate\n", - " winner['result'] = result\n", - " \n", - " return winner\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "def run_elections(R,V,Candidates,n=1,turnout=1./3.):\n", - " results = []\n", - " \n", - " for e in range(n):\n", - " (Rv,Vv) = pick_voters(R,V,turnout)\n", - " winner = count_election(Rv,Vv,C)\n", - " results.append(winner)\n", - " \n", - " return results" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "def analyze_elections(Candidates,Results):\n", - " ans = {}\n", - " for candidate in Candidates:\n", - " rec = {'name':candidate, 'wins':0, 'percent_wins':0.0, 'results':[]}\n", - " ans[candidate] = rec\n", - " \n", - " for winner in Results:\n", - " if winner['name'] in ans:\n", - " rec = ans[winner['name']]\n", - " rec['wins'] += 1\n", - " rec['results'].append(winner['result'])\n", - " \n", - " for candidate in Candidates:\n", - " rec = ans[candidate]\n", - " rec['percent_wins'] = 100.*rec['wins']/len(Results)\n", - " \n", - " return ans" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Run the election simulation" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 0.00% of the time\n", - "Candidate B\twins 100.00% of the time\n", - "[0.526676, 0.525981, 0.526498, 0.526727, 0.52656, 0.525674, 0.52653, 0.526725, 0.52593, 0.526365]\n" - ] - } - ], - "source": [ - "# this should yield the perfect result\n", - "results = run_elections(R,V,C,10,1.0)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))\n", - " \n", - "print(analysis[C[1]]['results'])" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 46.72% of the time\n", - "Candidate B\twins 53.28% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,10000,1./N_voters)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 55.74% of the time\n", - "Candidate B\twins 44.26% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,10000,0.00001)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 32.82% of the time\n", - "Candidate B\twins 67.18% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,10000,0.0001)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 0.00% of the time\n", - "Candidate B\twins 100.00% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,10000,0.01)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))\n", - " \n", - "#print(analysis[C[1]]['results'])" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 0.00% of the time\n", - "Candidate B\twins 100.00% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,1000,0.1)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Candidate A\twins 0.00% of the time\n", - "Candidate B\twins 100.00% of the time\n" - ] - } - ], - "source": [ - "results = run_elections(R,V,C,100,0.3333333333333333)\n", - "analysis = analyze_elections(C,results)\n", - "\n", - "# print(analysis)\n", - "\n", - "for candidate in analysis:\n", - " print(\"Candidate {name}\\twins {percent_wins:6.2f}% of the time\".format(**analysis[candidate]))" - ] - }, - { - "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.8.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -}