diff --git a/.gitignore b/.gitignore index fab25de59..d01e1bd25 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,4 @@ content/notebooks_gallery/ # Notebook outputs core/pandas/nino_analyzed_output.csv +core/matplotlib/animate.gif diff --git a/core/numpy.md b/core/numpy.md index 63b4903bb..8229b0c8a 100644 --- a/core/numpy.md +++ b/core/numpy.md @@ -1,8 +1,6 @@ -# NumPy +NumPy Logo -```{note} -This content is under construction! -``` +# NumPy This section contains tutorials on array computing with [NumPy](https://numpy.org). diff --git a/core/numpy/intermediate-numpy.ipynb b/core/numpy/intermediate-numpy.ipynb index d1388954a..0a660cf22 100644 --- a/core/numpy/intermediate-numpy.ipynb +++ b/core/numpy/intermediate-numpy.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "source": [ "## Imports\n", - "We will be including [matplotlib](../matplotlib) to illustrate some of our examples, but you don't need knowledge of it to complete this notebook." + "We will be including [Matplotlib](../matplotlib) to illustrate some of our examples, but you don't need knowledge of it to complete this notebook." ] }, { @@ -76,7 +76,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This calculates the total of all values in the array" + "This calculates the total of all values in the array." ] }, { @@ -582,7 +582,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "i.e., our lowest value is at index `52`, next `47`, and so on. We can use this array of indices as an index for `temp`," + "i.e., our lowest value is at index `52`, next `57`, and so on. We can use this array of indices as an index for `temp`," ] }, { @@ -668,7 +668,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.2" } }, "nbformat": 4, diff --git a/core/numpy/numpy-basics.ipynb b/core/numpy/numpy-basics.ipynb index 8cd09075a..7dfb5f7f5 100644 --- a/core/numpy/numpy-basics.ipynb +++ b/core/numpy/numpy-basics.ipynb @@ -772,7 +772,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now to actually make our own slice, let's select select all elements from `m=0` to `m=2`" + "Now to actually make our own slice, let's select all elements from `m=0` to `m=2`" ] }, { @@ -1025,7 +1025,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.2" }, "toc-autonumbering": false }, diff --git a/core/numpy/numpy-broadcasting.ipynb b/core/numpy/numpy-broadcasting.ipynb index 996feeb0b..160fed17e 100644 --- a/core/numpy/numpy-broadcasting.ipynb +++ b/core/numpy/numpy-broadcasting.ipynb @@ -14,7 +14,7 @@ "metadata": {}, "source": [ "## Overview\n", - "Before we begin, broadcasting is a valuable part of the power that NumPy provides. However, there's no looking past the fact that broadcasting can be conceptually difficult to digest. This information can be helpful and very powerful, but we also suggest moving on to take a look at some of the label-based corners of the Python ecosystem, namely [pandas](../pandas) and [xarray](../xarray) for the ways that they make some of these concepts simpler or easier to use for real-world data.\n", + "Before we begin, broadcasting is a valuable part of the power that NumPy provides. However, there's no looking past the fact that broadcasting can be conceptually difficult to digest. This information can be helpful and very powerful, but we also suggest moving on to take a look at some of the label-based corners of the Python ecosystem, namely [Pandas](../pandas) and [Xarray](../xarray) for the ways that they make some of these concepts simpler or easier to use for real-world data.\n", "\n", "1. An introduction to broadcasting\n", "1. Avoiding loops with vectorization" @@ -83,7 +83,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This works even though 5 is not an array; it works like as we would expect, adding 5 to each of the elements in `a`. This also works if 5 is an array:" + "This works even though 5 is not an array; it works like we would expect, adding 5 to each of the elements in `a`. This also works if 5 is an array:" ] }, { @@ -655,7 +655,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Another option to solve this is not using slicing but by using a powerful numpy tool: `as_strided`. This tool can result in some odd behavior, so take care when using--the trade-off is that this can be used to do some powerful operations. What we're doing here is altering how NumPy is interpreting the values in the memory that underpins the array. So for this array:" + "Another option to solve this is not using slicing but by using a powerful NumPy tool: `as_strided`. This tool can result in some odd behavior, so take care when using--the trade-off is that this can be used to do some powerful operations. What we're doing here is altering how NumPy is interpreting the values in the memory that underpins the array. So for this array:" ] }, { @@ -671,7 +671,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "we can create a view of the array with a new, bigger shape, with rows made up of overlapping values. We do this by specifying a new shape of 8x3, one row for each of the length 3 blocks we can fit in the original 1-D array of data. We then use the `strides` argument to control how numpy walks between items in each dimension. The last item in the strides tuple is just as normal--it says that the number of bytes to walk between items is just the size of an item. (Increasing this would skip items.) The first item says that when we go to a new, in this case row, only advance the size of a single item. This is what gives us overlapping rows." + "we can create a view of the array with a new, bigger shape, with rows made up of overlapping values. We do this by specifying a new shape of 8x3, one row for each of the length 3 blocks we can fit in the original 1-D array of data. We then use the `strides` argument to control how NumPy walks between items in each dimension. The last item in the strides tuple is just as normal--it says that the number of bytes to walk between items is just the size of an item. (Increasing this would skip items.) The first item says that when we go to a new, in this case row, only advance the size of a single item. This is what gives us overlapping rows." ] }, { @@ -848,14 +848,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We can use this to select all the indices on the other dimensions of our temperature array. We will also need to use the magic of broadcasting to combine arrays of indices across dimensions:" + "We can use this to select all the indices on the other dimensions of our temperature array. We will also need to use the magic of broadcasting to combine arrays of indices across dimensions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now vectorized solution:" + "Now let's consider a vectorized solution:" ] }, { @@ -900,7 +900,7 @@ "We've previewed some advanced NumPy capabilities with a focus on _vectorization_, or using clever broadcasting and windows of our data to enhance the speed and readability of our calculations. Doing so can reduce explicit construction of loops in your code and keep calculations running quickly!\n", "\n", "### What's next\n", - "This is an advanced NumPy topic, and important to designing your own calculations in a way for them to be as scalable and quick as possible. Please check out some of the following links to explore this topic further. We also suggest diving into label-based indexing and subsetting with [pandas](../pandas) and [xarray](../xarray), where some of this broadcasting can be simplified or have added context." + "This is an advanced NumPy topic, and important to designing your own calculations in a way for them to be as scalable and quick as possible. Please check out some of the following links to explore this topic further. We also suggest diving into label-based indexing and subsetting with [Pandas](../pandas) and [Xarray](../xarray), where some of this broadcasting can be simplified or have added context." ] }, { @@ -929,7 +929,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.10.2" } }, "nbformat": 4,