Skip to content

Commit

Permalink
updates to objects/class material
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor-phil committed Jul 19, 2023
1 parent d195c65 commit a7a940c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion lectures/python_fundamentals/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ b = A(3, 4)
a == b
```

Tell people how to see the `type`:
You can see that `a` and `b` are both instances of the `A` class by using the `type` function.

```{code-cell} python
Expand Down
4 changes: 2 additions & 2 deletions lectures/scientific/randomness.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ For more information see the

### Aside: Using Class to Hold Parameters

We have been using objects and classes both internal to python (e.g. `list`) from external libraries (e.g. `numpy.array`). Sometimes it is convenient to create your own classes to organize parameter, data, and functions.
We have been using objects and classes both internal to python (e.g. `list`) from external libraries (e.g. `numpy.array`). Sometimes it is convenient to create your own classes to organize parameter, data, and functions.

In this section we will reimplement our function using new classes to hold parameters.

Expand Down Expand Up @@ -374,7 +374,7 @@ print(params2)
print(np.mean(simulate_loan_repayments_2(N, params2)))
```

The `@dataclass` is an example of a python decorator (see [documentation](https://docs.python.org/3/glossary.html#term-decorator)). Decorators take in a class (or function) and return a new class (or function) with some additional features. In this case, it automatically creates the `__init__` function, allows for default values, and adds a new `__repr__` function which determines how the object is printed.
The `@dataclass` is an example of a python decorator (see [documentation](https://docs.python.org/3/glossary.html#term-decorator)). Decorators take in a class (or function) and return a new class (or function) with some additional features. In this case, it automatically creates the `__init__` function, allows for default values, and adds a new `__repr__` function which determines how the object is printed.

#### Profitability Threshold

Expand Down

1 comment on commit a7a940c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.