From ec28983ab07f2749082a59ba206d2cbac4e04751 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 13:53:18 -0800 Subject: [PATCH 01/15] Update Using notebooks.ipynb --- Using notebooks.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Using notebooks.ipynb b/Using notebooks.ipynb index cab8a54..09beb7d 100644 --- a/Using notebooks.ipynb +++ b/Using notebooks.ipynb @@ -53,7 +53,7 @@ "1. Log in at https://notebooks.azure.com/.\n", "1. Go to 'Libraries' (top left of the page).\n", "1. Click 'New Library' to create a library (give it a suitable name, e.g. 'IA exercises').\n", - "1. You should now be in your new library. Click 'Open in Jupyter' 'to get a Jupyter environment.\n", + "1. You should now be in your new library. Click 'Open in Jupyter' to get a Jupyter environment.\n", "1. At the top-right of the page, click `New -> Python 3`. You will now have a new notebook, and you're\n", " ready to start working.\n", "\n", From 6fca3e4ba9aad965d84bbbd91cb3866cdf2a320f Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 13:53:57 -0800 Subject: [PATCH 02/15] Update Using notebooks.ipynb --- Using notebooks.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Using notebooks.ipynb b/Using notebooks.ipynb index 09beb7d..64f730f 100644 --- a/Using notebooks.ipynb +++ b/Using notebooks.ipynb @@ -58,7 +58,7 @@ " ready to start working.\n", "\n", "By default, the name of your new notebook will be 'Untitled'. Click on 'Untitled' to give your notebook\n", - "and different name, e.g. 'Activity 02 exercises'. \n", + "a different name, e.g. 'Activity 02 exercises'. \n", "\n", "You can return to https://notebooks.azure.com/ at any time, and go to 'Libraries' to see your collection\n", "of notebook libraries.\n", From a5b8421a5c4effcb9b871f11cc5a5119043bee0a Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 13:55:01 -0800 Subject: [PATCH 03/15] Update Using notebooks.ipynb --- Using notebooks.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Using notebooks.ipynb b/Using notebooks.ipynb index 64f730f..e1edd08 100644 --- a/Using notebooks.ipynb +++ b/Using notebooks.ipynb @@ -79,7 +79,7 @@ "You can use `Insert` from the menu bar to insert a new cell.\n", "\n", "The current cell can be 'run' using `shift-return` (the current cell is highlighted by a bar on the left-hand\n", - "side of the page). When run, a text cell will be typeset, and the code in a 'code cell' will be executed. \n", + "side of the page). When run, a 'text cell' will be typeset, and the code in a 'code cell' will be executed. \n", "Any output from a code cell will appear below the code.\n", "\n", "Often you will want to run all cells from the start of a notebook. You can do this with `Kernel -> Restart & Run All` from the notebook menu bar. In this case the cells are executed in order (first through to last).\n", From 4aabb0e0c575e250dacffe19597fb7a22eea8f1f Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 13:56:26 -0800 Subject: [PATCH 04/15] Update Using notebooks.ipynb --- Using notebooks.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Using notebooks.ipynb b/Using notebooks.ipynb index e1edd08..2a4e924 100644 --- a/Using notebooks.ipynb +++ b/Using notebooks.ipynb @@ -151,9 +151,9 @@ "\n", "`A passage of text`\n", "\n", - "*Some more text*\n", + "*Some more text in italics*\n", "\n", - "**Yet more text**\n", + "**Yet more text in bold**\n", "\n", "```\n", "\n", From 94d7c35c69763f6e7953efb37c5454ea53f3190a Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 13:58:28 -0800 Subject: [PATCH 05/15] Update Using notebooks.ipynb --- Using notebooks.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Using notebooks.ipynb b/Using notebooks.ipynb index 2a4e924..a483cf4 100644 --- a/Using notebooks.ipynb +++ b/Using notebooks.ipynb @@ -241,7 +241,7 @@ "```\n", "which will appear as:\n", "\n", - "'The term of interest in this case is $\\exp(-2x) \\sin(\\alpha x^{4})$.'\n", + "'The term of interest in this case is $\\exp(-2x) \\sin(3 x^{4})$.'\n", "\n", "For a displayed equation, from\n", "```\n", From 4f9dc3a0e62b3806313c5045796034545e769219 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:03:26 -0800 Subject: [PATCH 06/15] Update 02 Control statements.ipynb --- 02 Control statements.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02 Control statements.ipynb b/02 Control statements.ipynb index f98bc4f..2049226 100644 --- a/02 Control statements.ipynb +++ b/02 Control statements.ipynb @@ -235,7 +235,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The meaning of the statement becomes clear if read it left-to-right.\n", + "The meaning of the statement becomes clear if read from left-to-right.\n", "\n", "Below is a very simple example that, given the current time of day reports \n", "\n", From 06246e7173cfcf8e1263bdfd7ce1ac61dbb9d5b5 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:06:29 -0800 Subject: [PATCH 07/15] Update 02 Control statements.ipynb --- 02 Control statements.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/02 Control statements.ipynb b/02 Control statements.ipynb index 2049226..eee57e1 100644 --- a/02 Control statements.ipynb +++ b/02 Control statements.ipynb @@ -815,7 +815,7 @@ "source": [ "since we might not know beforehand how many steps are required before `x > 0.001` becomes false. \n", "\n", - "If $x \\ge 1$, the above would lead to an infinite loop. To make a code robust, it would be good practice to check that $x < 1$ before entering the `while` loop." + "If $x \\ge 1$, the above would lead to an infinite loop. To make the code robust, it would be good practice to check that $x < 1$ before entering the `while` loop." ] }, { From 3dadddfb5b0a5d3f7747eccf6037e29b470b6bff Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:16:24 -0800 Subject: [PATCH 08/15] Update 03 Types, type conversions and floating point arithmetic.ipynb --- ...conversions and floating point arithmetic.ipynb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/03 Types, type conversions and floating point arithmetic.ipynb b/03 Types, type conversions and floating point arithmetic.ipynb index 78cf9b0..91e43e1 100644 --- a/03 Types, type conversions and floating point arithmetic.ipynb +++ b/03 Types, type conversions and floating point arithmetic.ipynb @@ -6,12 +6,12 @@ "source": [ "# Introduction\n", "\n", - "We have thus far avoided discussing directly *types*. The '*type*' is the type of object that a variable is associated with. This affects how a computer stores the object in memory, and how operations, such as multiplication and division, are performed.\n", + "We have thus far avoided discussing directly *types*. The '*type*' is the kind of object that a variable is associated with. This affects how a computer stores the object in memory, and how operations, such as multiplication and division, are performed.\n", "\n", "In *statically typed* languages, like C and C++, types come up from the very beginning because \n", "you usually need to specify types explicitly in your programs. Python is a *dynamically typed* language, which means types are deduced when a program is run. This is why we have been able to postpone the discussion until now.\n", "It is important to have a basic understanding of types, and how types can affect how your programs behave. One can go very deep into this topic, especially for numerical computations, but we will cover the general concept from a high level, \n", - "show some examples, and highlight some potential pitfalls for engineering computations. \n", + "show some examples, and highlight some potential pitfalls in engineering computations. \n", "\n", "This is a dry topic - it contains important background information that you need to know for later, so hang in there. The below account highlights what can go wrong without an awareness of types and how computers process numbers." ] @@ -255,7 +255,7 @@ "# Get first six characters, print and check type\n", "s3 = my_string[0:6]\n", "print(s3)\n", - "print(type(s2))\n", + "print(type(s3))\n", "\n", "# Get last four characters and print\n", "s3 = my_string[-4:]\n", @@ -522,7 +522,7 @@ "source": [ "### Floats\n", "\n", - "We can declare a float by adding a decimal point:" + "We can declare a variable as a float by adding a decimal point:" ] }, { @@ -1186,7 +1186,7 @@ "earlier. However, this was a little misleading because computers do not use base 10\n", "to store the significand and the exponent, but base 2. \n", "\n", - "When using the familiar base 10, we cannot represent $1/3$ exactly as a decimal. If we liked using base 3 (ternary numeral system) for our mental arithmetic (which we really don't), we could represent $1/3$ exactly. However, fractions that are simple to represent exactly in base 10 might not be representable in another base.\n", + "When using the familiar base 10, we cannot represent $1/3$ exactly as a decimal. If we liked using base 3 (ternary numeral system) for our mental arithmetic (which we really don't), we could represent $1/3$ exactly. However, fractions that are simple to represent exactly in base 10 might not be exactly representable in another base.\n", "A consequence is that fractions that are simple in base 10 cannot necessarily be represented exactly by computers using binary.\n", "\n", "A classic example is $1/10 = 0.1$. This simple number cannot be represented exactly in\n", @@ -1283,7 +1283,7 @@ "If $x = 0.1$, we can write\n", "\n", "$$\n", - "x = 11x - 1\n", + "x = 1.1x - 1\n", "$$\n", "\n", "Now, starting with $x = 0.1$ we evaluate the right-hand side to get a 'new' $x$, and use this new $x$ to then evaluate the right-hand side again. The arithmetic is trivial: $x$ should remain equal to $0.1$.\n", @@ -1528,7 +1528,7 @@ "- The size of an integer that a computer can store is determined by the number of bits used to represent the \n", " integer.\n", "- Computers do not perform exact arithmetic with non-integer numbers. This does not usually cause a problem, but \n", - " it can in cases. Problems can often be avoided with careful programming.\n", + " it can in some cases. Problems can often be avoided with careful programming.\n", "- Be thoughtful when converting between types - undesirable consequences can follow when careless with \n", " conversions." ] From be65aed78fc1e5451f3d234e53098d9479a0e035 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:19:49 -0800 Subject: [PATCH 09/15] Update 04 Functions.ipynb --- 04 Functions.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/04 Functions.ipynb b/04 Functions.ipynb index 881afbc..5e3bb22 100644 --- a/04 Functions.ipynb +++ b/04 Functions.ipynb @@ -115,7 +115,7 @@ "source": [ "# Purpose\n", "\n", - "Functions allow computer code to be re-used multiple times with different input data. It is good to re-use code as much as possible because we then focus testing and debugging efforts, and maybe also optimisations, on small pieces of code that are then re-used. The more code that is written, the less frequently sections of code are used, and as a consequence the greater the likelihood of errors.\n", + "Functions allow computer code to be re-used multiple times with different input data. It is good to re-use code as much as possible because we then focus our testing and debugging efforts, and maybe also optimisations, on small pieces of code that are then re-used. The more code that is written, the less frequently sections of code are used, and as a consequence the greater the likelihood of errors.\n", "\n", "Functions can also enhance the readability of a program, and make it easier to collaborate with others. Functions allow us to focus on *what* a program does at a high level \n", "rather than the details of *how* it does it. Low-level implementation details are *encapsulated* in functions. To understand at a high level what a program does, we usually just need to know what data is passed into a function and what the function returns. It is not necessary to know the precise details of how a function is implemented to grasp the structure of a program and how it works. For example, we might need to know that a function computes and returns $\\sin(x)$; we don't usually need to know *how* it computes sine.\n", @@ -178,7 +178,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Using a function, we did not have to duplicate the `if-elif-else` statement inside each loop\n", + "Using a function, we did not have to duplicate the `if-elif-else` statement inside each loop,\n", "we re-used it.\n", "With a function we only have to change the way in which we process the number `x` in one place." ] From e1aef30d6a3f72b445f649fcb04efccc69fd2acf Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:22:55 -0800 Subject: [PATCH 10/15] Update 05 Library functions.ipynb --- 05 Library functions.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/05 Library functions.ipynb b/05 Library functions.ipynb index 2c85ea9..911d99d 100644 --- a/05 Library functions.ipynb +++ b/05 Library functions.ipynb @@ -7,7 +7,7 @@ "# Introduction\n", "\n", "A feature of modern programming languages is an extensive library of standard functions. This means that we can make use of standard, well-tested and optimised functions\n", - "for performing common tasks rather than writing our own. This makes our programs shorter and of higher quality, and in most cases faster.\n", + "for performing common tasks rather than writing our own. This makes our programs shorter, of higher quality, and in most cases faster.\n", "\n", "\n", "\n", @@ -174,7 +174,7 @@ "metadata": {}, "source": [ "Renaming functions at import can be helpful to keep code short, and we will see below it can be useful for switching between different functions.\n", - "However the above choice of name is very poor practice - the name '`some_math_function`' is not descriptive.\n", + "However, the above choice of name is very poor practice - the name '`some_math_function`' is not descriptive.\n", "Below is a more sensible example." ] }, @@ -477,7 +477,7 @@ "source": [ "We see from the output that three different processes have worked on our problem - one for each sorting task.\n", "\n", - "We use parallel processing the make computations faster. Let's time our computation using different numbers\n", + "We use parallel processing to make computations faster. Let's time our computation using different numbers\n", "of processes to see how it affects performance. \n", "To perform the timing, we first encapsulate our problem in a function:" ] From eacb5f34d6f0cfcdc505b22fcf763fecbe11d06d Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:27:22 -0800 Subject: [PATCH 11/15] Update 07 Numerical computation.ipynb --- 07 Numerical computation.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/07 Numerical computation.ipynb b/07 Numerical computation.ipynb index 8adb085..98b9885 100644 --- a/07 Numerical computation.ipynb +++ b/07 Numerical computation.ipynb @@ -353,7 +353,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The function `linspace` creates an array with prescribed start and end values (both are included), and a prescribed number on values, all equally spaced:" + "The function `linspace` creates an array with prescribed start and end values (both are included), and a prescribed number of values, all equally spaced:" ] }, { @@ -420,7 +420,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "and multiplication of components by a scalar," + "and multiplication of each element by a scalar," ] }, { @@ -445,7 +445,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "and raising components to a power:" + "and raising each element to a power:" ] }, { @@ -558,7 +558,7 @@ "followed by taking the square root.\n", "To compute the norm, we could loop/iterate over the entries of the vector and sum the square of each entry, and then take the square root of the result.\n", "\n", - "We will evaluate the norm using two methods for computing the norm of an array of length 10 million to compare their performance. We first create a vector with 10 million random entries, using NumPy:" + "We will use two methods for computing the norm of an array of length 10 million to compare their performance. We first create a vector with 10 million random entries, using NumPy:" ] }, { @@ -613,8 +613,8 @@ "source": [ "The time output of interest is '`Wall time`'.\n", "\n", - "> The details of how `%time` works are not important for this course. We use it as a compact and covenient tool to \n", - "> measure how much time a command takes to execute.\n", + "The details of how `%time` works are not important for this course. We use it as a compact and covenient tool to \n", + "measure how much time a command takes to execute.\n", "\n", "We now perform the same operation with our own function for computing the norm:" ] From e66a3f1c5bddca8aa73fd3438ecdabf42d897609 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:37:50 -0800 Subject: [PATCH 12/15] Update 08 Plotting.ipynb --- 08 Plotting.ipynb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/08 Plotting.ipynb b/08 Plotting.ipynb index 4cc50ae..98af98e 100644 --- a/08 Plotting.ipynb +++ b/08 Plotting.ipynb @@ -20,7 +20,7 @@ "We will use the tools presented in this notebook to visualise results in subsequent notebooks.\n", "\n", "> This is a long activity - this a reflection of the importance of plotting. The next activity\n", - "> is shorter in compensation.\n", + "is shorter in compensation.\n", "\n", "> Some exercises in this notebook are challenging. Use the forum to get help.\n", "\n", @@ -67,7 +67,7 @@ "```\n", "\n", "Below we install the `quandl` package which will be used further down to fetch and plot stock prices.\n", - "You can skip over the details, and it should just work. The code is a little complex because it is designed work for a range of different Python environments. If you get an error message in the following code blocks, send a message with the error to the Moodle forum.\n", + "You can skip over the details, and it should just work. The code is a little complex because it is designed to work for a range of different Python environments. If you get an error message in the following code blocks, send a message with the error to the Moodle forum.\n", "\n", "To install the `quandl` package:" ] @@ -81,7 +81,7 @@ "import sys\n", "if 'conda' in sys.version: # Install using conda if we're using Anaconda Python\n", " !conda install -yc conda-forge quandl\n", - "else: # Install using pip on others systems\n", + "else: # Install using pip on other systems\n", " try:\n", " !{sys.executable} -m pip -q install quandl --user # Try to install in userspace\n", " import quandl\n", @@ -102,7 +102,7 @@ "metadata": {}, "source": [ "We will be using the `ipywidgets` module for interactive plots. It has already been configured for you on\n", - "https://notebooks.azure.com/, so the below is necessary only if using other environments." + "https://notebooks.azure.com/, so the code below is necessary only if using other environments." ] }, { @@ -204,7 +204,7 @@ "8 | 13\n", "10 | 1\n", "\n", - "we want to create a line plot of $x$-values (horizontal axis) against the $f$ values (vertical axis).\n", + "we want to create a line plot of $f$ values (vertical axis) against the $x$-values (horizontal axis).\n", "\n", "We first create a list of `x` values and a list of `f` values:" ] @@ -279,7 +279,7 @@ "# Attach labels and title (using LaTeX syntax)\n", "plt.xlabel('$x$')\n", "plt.ylabel('$f$')\n", - "plt.title(\"Simple plot of $x$ vs $f$\")\n", + "plt.title(\"Simple plot of $f$ vs $x$\")\n", "plt.show()" ] }, @@ -288,7 +288,7 @@ "metadata": {}, "source": [ "To change the colour of the line to red and use crosses at the data points, and to save the\n", - "plot to the file `my-plot.png`, we can do the following:" + "plot to the file `my-plot.pdf`, we can do the following:" ] }, { @@ -386,7 +386,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To evaluate $\\sin(x)$ for each value in the array `x`, we use the NumPy `sin` function, which can be applied entry-wise to `x`:" + "To evaluate $\\sin(x)$ for each value in the array `x`, we use the NumPy `sin` function, which can be applied element-wise to `x`:" ] }, { @@ -718,7 +718,7 @@ "# Plot normed histogram of data\n", "n, bins, patches = plt.hist(x, 20, normed=1.0, facecolor='green', alpha=0.75);\n", "\n", - "# Create array of 100 equally spaces points, stating from the first value in the bins\n", + "# Create array of 100 equally spaced points, starting from the first value in the bins\n", "# through to the last values in the bins\n", "xf = np.linspace(bins[0], bins[-1], 100)\n", "\n", @@ -892,10 +892,10 @@ "metadata": {}, "source": [ "(Remember, to get $\\omega$ and $\\alpha$ use `\\omega` + `Tab` key and `\\alpha` + `Tab` key.)\n", - "We have used default function arguments - these will be the initial parameters for out interactive plot.\n", + "We have used default function arguments - these will be the initial parameters for our interactive plot.\n", "\n", "Next, we use the `interact` function, passing to it the name of our function that does the plotting \n", - "(`plot` in this case), and a tuple for each parameters:" + "(`plot` in this case), and a tuple for each parameter:" ] }, { @@ -1178,7 +1178,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The below plots the function $f(x, y)$ in three-dimensions:" + "The code below plots the function $f(x, y)$ in three-dimensions:" ] }, { From 55e8fb65b2698371a4f3c7d17cf6b2c4e0ce73ab Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:41:47 -0800 Subject: [PATCH 13/15] Update 10 Algorithms.ipynb --- 10 Algorithms.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/10 Algorithms.ipynb b/10 Algorithms.ipynb index d4f2295..1179b68 100644 --- a/10 Algorithms.ipynb +++ b/10 Algorithms.ipynb @@ -19,7 +19,7 @@ "## Characterising algorithms\n", "\n", "There is usually more than one way to solve a problem, hence there will\n", - "usually be more than one algorithm to solve a given problem. Some algorithms may be fast but\n", + "usually be more than one algorithm that can solve a given problem. Some algorithms may be fast but\n", "inaccurate, others slow and accurate; some can be fast but use a lot of memory, while others may be \n", "low-memory but slower. Some will be simple to program, others much harder.\n", "We will look more at characterising the performance of algorithms in the next notebook on \n", @@ -135,7 +135,7 @@ "source": [ "## Linear search\n", "\n", - "The simplest search is linear search, where we iterate over all entries in a list/tuple/dictionary, etc, and check for the value(s) we are looking for. Here is an example of searching if a given colour is in a list:" + "The simplest search is linear search, where we iterate over all entries in a list/tuple/dictionary, etc, and check for the value(s) we are looking for. Here is an example of searching for a given colour in a list:" ] }, { @@ -486,7 +486,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We do not want to focus on details of the quicksort algorithm, but do wish to highlight the close resemblance between the pseudocode and the Python implementation.\n", + "We do not want to focus on the details of the quicksort algorithm, but do wish to highlight the close resemblance between the pseudocode and the Python implementation.\n", "\n", "We now test the implementation for an array of random numbers:" ] From 572454373e72901e5329777707e3d71a1e9fad8c Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:49:42 -0800 Subject: [PATCH 14/15] Update 11 Complexity.ipynb --- 11 Complexity.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/11 Complexity.ipynb b/11 Complexity.ipynb index 4786f87..7221882 100644 --- a/11 Complexity.ipynb +++ b/11 Complexity.ipynb @@ -445,7 +445,7 @@ "x = np.arange(N[-1])\n", "x = np.sort(x)\n", "\n", - "# Initlise an empty array to capture time taken\n", + "# Initialise an empty array to capture time taken\n", "times = []\n", "\n", "# Time search for different problem sizes\n", @@ -815,7 +815,7 @@ "plt.loglog(N, 1e-6*N*np.log(N), '--', label=r'$O(n\\log n)$')\n", "\n", "# Show reference line of O(n^2)\n", - "plt.loglog(N, 1e-6*N**2, '--', label=r'$O(n^2$)')\n", + "plt.loglog(N, 1e-6*N**2, '-.', label=r'$O(n^2$)')\n", "\n", "# Add labels\n", "plt.xlabel('$n$')\n", @@ -906,7 +906,7 @@ "\n", "# Show reference lines of O(n*log(n)) and O(n^2)\n", "plt.loglog(N, 1e-6*N*np.log(N), '--', label=r'$O(n\\log n)$')\n", - "plt.loglog(N, 1e-6*N**2, '--', label=r'$O(n^2$)')\n", + "plt.loglog(N, 1e-6*N**2, '-.', label=r'$O(n^2$)')\n", "\n", "# Show legend\n", "plt.legend(loc=0);\n", From af3e33872ee8505e0a96be9a7365ce6d8a941f39 Mon Sep 17 00:00:00 2001 From: Matt Moelter Date: Tue, 5 Dec 2017 14:53:28 -0800 Subject: [PATCH 15/15] Update 12 Object-oriented design.ipynb --- 12 Object-oriented design.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/12 Object-oriented design.ipynb b/12 Object-oriented design.ipynb index 6a137fb..e1781b7 100644 --- a/12 Object-oriented design.ipynb +++ b/12 Object-oriented design.ipynb @@ -226,7 +226,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Methods are functions, and as functions can take arguments. For example, we can use the method `sort` to sort the rows of an array: " + "Methods are functions, and as functions they can take arguments. For example, we can use the method `sort` to sort the rows of an array: " ] }, { @@ -499,7 +499,7 @@ "outputs": [], "source": [ "class crazynumber:\n", - " \"A crazy number class that switches the mutliplcation and division operations\"\n", + " \"A crazy number class that switches the mutliplication and division operations\"\n", " \n", " # Initialiser\n", " def __init__(self, x):\n", @@ -523,7 +523,7 @@ "metadata": {}, "source": [ "> *Note:* the method names `__mul__`, ` __truediv__`, `__repr__`, etc, should not be called directly. They \n", - "> are mapped by Python to operators (`*` and `/` in the first two cases). The method `__repr__` is called behind the scenes when using `print`.\n", + "are mapped by Python to operators (`*` and `/` in the first two cases). The method `__repr__` is called behind the scenes when using `print`.\n", "\n", "We now create two `crazynumber` objects:" ] @@ -605,7 +605,7 @@ "we might have a `StudentEntry` class, and then have a list with a `StudentEntry` object for each student.\n", "The built-in sort functions cannot know how we want to sort our list.\n", "\n", - "Another case is if we have a list of numbers, and we we want to sort according to a custom rule?\n", + "Another case is if we have a list of numbers, and we we want to sort according to a custom rule.\n", "\n", "The built-in sort functions do not care about the details of our data. All they rely on\n", "are *comparisons*, e.g. the `<`, `>`, and `==` operators. If we equip our class with comparison operators,\n", @@ -678,7 +678,7 @@ "metadata": {}, "source": [ "We can perform some simple tests on the operators (insert print statements into the methods if you want\n", - "to verify which function is called)" + "to verify which function is called)." ] }, {