Skip to content

Commit

Permalink
Update docs links and correct typos in tools_numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
vi3itor committed May 13, 2022
1 parent d07f0ec commit b2ba41f
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions tools_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"It's just as easy to create a 2D array (ie. a matrix) by providing a tuple with the desired number of rows and columns. For example, here's a 3x4 matrix:"
"It's just as easy to create a 2D array (i.e. a matrix) by providing a tuple with the desired number of rows and columns. For example, here's a 3x4 matrix:"
]
},
{
Expand Down Expand Up @@ -122,7 +122,7 @@
"* An array's list of axis lengths is called the **shape** of the array.\n",
" * For example, the above matrix's shape is `(3, 4)`.\n",
" * The rank is equal to the shape's length.\n",
"* The **size** of an array is the total number of elements, which is the product of all axis lengths (eg. 3*4=12)"
"* The **size** of an array is the total number of elements, which is the product of all axis lengths (e.g. 3*4=12)"
]
},
{
Expand Down Expand Up @@ -275,7 +275,7 @@
"metadata": {},
"source": [
"## `np.ones`\n",
"Many other NumPy functions create `ndarrays`.\n",
"Many other NumPy functions create `ndarray`s.\n",
"\n",
"Here's a 3x4 matrix full of ones:"
]
Expand Down Expand Up @@ -368,7 +368,7 @@
"metadata": {},
"source": [
"## np.array\n",
"Of course you can initialize an `ndarray` using a regular python array. Just call the `array` function:"
"Of course, you can initialize an `ndarray` using a regular python array. Just call the `array` function:"
]
},
{
Expand Down Expand Up @@ -453,7 +453,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Of course you can provide a step parameter:"
"Of course, you can provide a step parameter:"
]
},
{
Expand All @@ -480,7 +480,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"However, when dealing with floats, the exact number of elements in the array is not always predictible. For example, consider this:"
"However, when dealing with floats, the exact number of elements in the array is not always predictable. For example, consider this:"
]
},
{
Expand Down Expand Up @@ -679,7 +679,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"NumPy first creates three `ndarrays` (one per dimension), each of shape `(3, 2, 10)`. Each array has values equal to the coordinate along a specific axis. For example, all elements in the `z` array are equal to their z-coordinate:\n",
"NumPy first creates three `ndarray`s (one per dimension), each of shape `(3, 2, 10)`. Each array has values equal to the coordinate along a specific axis. For example, all elements in the `z` array are equal to their z-coordinate:\n",
"\n",
" [[[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n",
" [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]]\n",
Expand Down Expand Up @@ -770,7 +770,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Available data types include `int8`, `int16`, `int32`, `int64`, `uint8`|`16`|`32`|`64`, `float16`|`32`|`64` and `complex64`|`128`. Check out [the documentation](http://docs.scipy.org/doc/numpy-1.10.1/user/basics.types.html) for the full list.\n",
"Available data types include signed `int8`, `int16`, `int32`, `int64`, unsigned `uint8`|`16`|`32`|`64`, `float16`|`32`|`64` and `complex64`|`128`. Check out the documentation for the [basic types](https://numpy.org/doc/stable/user/basics.types.html) and [sized aliases](https://numpy.org/doc/stable/reference/arrays.scalars.html#sized-aliases) for the full list.\n",
"\n",
"## `itemsize`\n",
"The `itemsize` attribute returns the size (in bytes) of each item:"
Expand Down Expand Up @@ -862,7 +862,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Several `ndarrays` can share the same data buffer, meaning that modifying one will also modify the others. We will see an example in a minute."
"Several `ndarray`s can share the same data buffer, meaning that modifying one will also modify the others. We will see an example in a minute."
]
},
{
Expand Down Expand Up @@ -1333,7 +1333,7 @@
"metadata": {},
"source": [
"Broadcasting rules are used in many NumPy operations, not just arithmetic operations, as we will see below.\n",
"For more details about broadcasting, check out [the documentation](https://docs.scipy.org/doc/numpy-dev/user/basics.broadcasting.html)."
"For more details about broadcasting, check out [the documentation](https://numpy.org/doc/stable/user/basics.broadcasting.html)."
]
},
{
Expand Down Expand Up @@ -1384,7 +1384,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that `int16` is required to represent all *possible* `int8` and `uint8` values (from -128 to 255), even though in this case a uint8 would have sufficed."
"Note that `int16` is required to represent all *possible* `int8` and `uint8` values (from -128 to 255), even though in this case a `uint8` would have sufficed."
]
},
{
Expand Down Expand Up @@ -2258,15 +2258,15 @@
],
"source": [
"a[3] = 4000\n",
"another_slice # similary, modifying the original array does not affect the slice copy"
"another_slice # similarly, modifying the original array does not affect the slice copy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Multi-dimensional arrays\n",
"Multi-dimensional arrays can be accessed in a similar way by providing an index or slice for each axis, separated by commas:"
"## Multidimensional arrays\n",
"Multidimensional arrays can be accessed in a similar way by providing an index or slice for each axis, separated by commas:"
]
},
{
Expand Down Expand Up @@ -3119,7 +3119,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This was possible because q1, q2 and q3 all have the same shape (except for the vertical axis, but that's ok since we are stacking on that axis).\n",
"It was possible because q1, q2 and q3 all have the same shape (except for the vertical axis, but that's ok since we are stacking on that axis).\n",
"\n",
"## `hstack`\n",
"We can also stack arrays horizontally using `hstack`:"
Expand Down Expand Up @@ -3172,7 +3172,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This is possible because q1 and q3 both have 3 rows. But since q2 has 4 rows, it cannot be stacked horizontally with q1 and q3:"
"It is possible because q1 and q3 both have 3 rows. But since q2 has 4 rows, it cannot be stacked horizontally with q1 and q3:"
]
},
{
Expand Down Expand Up @@ -3691,7 +3691,7 @@
"metadata": {},
"source": [
"# Linear algebra\n",
"NumPy 2D arrays can be used to represent matrices efficiently in python. We will just quickly go through some of the main matrix operations available. For more details about Linear Algebra, vectors and matrics, go through the [Linear Algebra tutorial](math_linear_algebra.ipynb).\n",
"NumPy 2D arrays can be used to represent matrices efficiently in python. We will just quickly go through some of the main matrix operations available. For more details about Linear Algebra, vectors and matrices, go through the [Linear Algebra tutorial](math_linear_algebra.ipynb).\n",
"\n",
"## Matrix transpose\n",
"The `T` attribute is equivalent to calling `transpose()` when the rank is ≥2:"
Expand Down Expand Up @@ -3927,7 +3927,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"**Caution**: as mentionned previously, `n1*n2` is *not* a matric multiplication, it is an elementwise product (also called a [Hadamard product](https://en.wikipedia.org/wiki/Hadamard_product_(matrices)))."
"**Caution**: as mentioned previously, `n1*n2` is *not* a matrix multiplication, it is an elementwise product (also called a [Hadamard product](https://en.wikipedia.org/wiki/Hadamard_product_(matrices)))."
]
},
{
Expand Down Expand Up @@ -4019,7 +4019,7 @@
"metadata": {},
"source": [
"## Identity matrix\n",
"The product of a matrix by its inverse returns the identiy matrix (with small floating point errors):"
"The product of a matrix by its inverse returns the identity matrix (with small floating point errors):"
]
},
{
Expand Down Expand Up @@ -4048,7 +4048,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"You can create an identity matrix of size NxN by calling `eye`:"
"You can create an identity matrix of size NxN by calling `eye(N)` function:"
]
},
{
Expand Down Expand Up @@ -4637,7 +4637,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As you can see, both `X` and `Y` are 768x1024 arrays, and all values in `X` correspond to the horizontal coordinate, while all values in `Y` correspond to the the vertical coordinate.\n",
"As you can see, both `X` and `Y` are 768x1024 arrays, and all values in `X` correspond to the horizontal coordinate, while all values in `Y` correspond to the vertical coordinate.\n",
"\n",
"Now we can simply compute the result using array operations:"
]
Expand Down Expand Up @@ -4678,7 +4678,6 @@
],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.cm as cm\n",
"\n",
"fig = plt.figure(1, figsize=(7, 6))\n",
"plt.imshow(data, cmap=\"hot\")\n",
Expand Down Expand Up @@ -4733,7 +4732,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Done! Since the file name contains no file extension was provided, NumPy automatically added `.npy`. Let's take a peek at the file content:"
"Done! Since the file name contains no file extension, NumPy automatically added `.npy`. Let's take a peek at the file content:"
]
},
{
Expand Down Expand Up @@ -5031,9 +5030,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# What next?\n",
"Now you know all the fundamentals of NumPy, but there are many more options available. The best way to learn more is to experiment with NumPy, and go through the excellent [reference documentation](http://docs.scipy.org/doc/numpy/reference/index.html) to find more functions and features you may be interested in."
]
"# What's next?\n",
"Now you know all the fundamentals of NumPy, but there are many more options available. The best way to learn more is to experiment with NumPy, and go through the excellent [reference documentation](https://numpy.org/doc/stable/reference/index.html) to find more functions and features you may be interested in."
}
],
"metadata": {
Expand Down

0 comments on commit b2ba41f

Please sign in to comment.