Skip to content

Commit

Permalink
Merge pull request #187 from rsokl/fix-typos
Browse files Browse the repository at this point in the history
Fix typos
  • Loading branch information
rsokl committed Jan 28, 2022
2 parents 98e0934 + 22065c3 commit 237e24d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Python/Module3_IntroducingNumpy/Broadcasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Generate a random array of 10,000 2D points using `np.random.rand`. Compute the
### Inserting Size-1 Dimensions into An Array
As conveyed by the broadcasting rules, dimensions of size-1 are special in that they can be broadcasted to any size. Here we will learn about introducing size-1 dimensions into an array, for the purpose of tailoring its shape for broadcasting.

You can introduce size-1 dimensions to an array without changing the overall size (i.e. total number of entries in an array. Thus we are free to add size-1 dimensions to an array via the `reshape` function. Let's reshape a shape-(3,) array into a shape-(1, 3, 1, 1) array:
You can introduce size-1 dimensions to an array without changing the overall size (i.e. total number of entries in an array). Thus we are free to add size-1 dimensions to an array via the `reshape` function. Let's reshape a shape-(3,) array into a shape-(1, 3, 1, 1) array:
```python
>>> import numpy as np

Expand Down Expand Up @@ -528,7 +528,7 @@ array([[ 3.678 , 8.4524, 10.3057, 7.3711, 6.2152, 5.5548],

<!-- #region -->
### Pairwise Distances Using Broadcasting (Unoptimized)
Now, let's use of vectorization to perform this distance computation. It must be established immediately that the method that we about to develop here is memory-inefficient. We will address this issue in detail at the end of this subsection.
Now, let's make use of vectorization to perform this distance computation. It must be established immediately that the method that we are about to develop here is memory-inefficient. We will address this issue in detail at the end of this subsection.

We start off our vectorized computation by shrewdly inserting size-1 dimensions into `x` and `y`, so that we can perform $M \times N$ subtractions between their pairs of length-$D$ rows. *This creates a shape-*$(M, N, D)$ *array*.

Expand Down Expand Up @@ -652,7 +652,7 @@ In terms of pure mathematics, `x_y_sqrd - x_y_prod` must be a strictly non-negat
\sum_{i=0}^{D-1}{(x_{i} - y_{i})^2}
\end{equation}

That being said, are working with floating-point numbers, which do not always behave exactly like rational numbers when we do arithmetic with them.
That being said, we are working with floating-point numbers, which do not always behave exactly like rational numbers when we do arithmetic with them.
Indeed, we saw earlier that the [quirks of floating-point arithmetic](https://www.pythonlikeyoumeanit.com/Module2_EssentialsOfPython/Basic_Objects.html#Understanding-Numerical-Precision) can lead to surprising results.
Here, the strange behavior is that `x_y_sqrd - x_y_prod` **can produce negative numbers**!

Expand Down
2 changes: 1 addition & 1 deletion Python/Module4_OOP/Applications_of_OOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Let's create a shopping list class, where an instance of this class stores a lis
- mark items on the list as "purchased"
- remove items, purchased or not, from the list
- list the name of the items to-be purchased (in alphabetical order)
- list the name of the items have been purchased (in alphabetical order)
- list the name of the items that have been purchased (in alphabetical order)

We do not want redundant items to be included on our shopping list - if someone enters "apples" twice, we should only list it once. Thus we will make use of [sets](http://www.pythonlikeyoumeanit.com/Module2_EssentialsOfPython/DataStructures_III_Sets_and_More.html#The-%E2%80%9CSet%E2%80%9D-Data-Structure), which store unique elements, to store the items on our list.

Expand Down
2 changes: 1 addition & 1 deletion Python/Module4_OOP/ClassDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jupyter:
<!-- #region -->
# Defining a New Class of Object

This section will introduce the basic syntax for defining a new class (a.k.a. type) of Python object. Recall that the phrase `def` is used to denote the definition of a function. Similarly, `class` is used to denote the beginning of a class definition. The body of the class definition, which is the indented region below a `class` statement, is used to define the class' various **attributes**.
This section will introduce the basic syntax for defining a new class (a.k.a. type) of Python object. Recall that the statement `def` is used to denote the definition of a function. Similarly, `class` is used to denote the beginning of a class definition. The body of the class definition, which is the indented region below a `class` statement, is used to define the class' various **attributes**.

The following defines a new class of object, named `MyGuy`, specifying four attributes `x`, `y`, `z`, and `f`

Expand Down
4 changes: 2 additions & 2 deletions Python/Module4_OOP/Inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Having defined our subclass, we can leverage the other methods of `Rectangle` as
# create a square of side-length 2
>>> my_square = Square(2)

# using the inherited `get_area` method
>>> my_square.get_area()
# using the inherited `compute_area` method
>>> my_square.compute_area()
4

# a square is a rectangle with equal height/width
Expand Down
3 changes: 1 addition & 2 deletions Python/Module4_OOP/Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ True
# even when `class_func` is called from an instance
>>> inst = Dummy()
>>> inst.class_func()
>>> inst.class_func()
__main__.Dummy
```
<!-- #endregion -->
Expand Down Expand Up @@ -288,7 +287,7 @@ What will happen if you try to call `Dummy.func("hi")`? Why?
```python
# Dummy.func("hi") would raise an error
>>> Dummy(None, "hi")
>>> Dummy.func(None, "hi")
'hi'
```
<!-- #endregion -->

0 comments on commit 237e24d

Please sign in to comment.