Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not refer to NumPy array using the term list #1067

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions episodes/10-defensive.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ This violates another important rule of programming:
## Pre- and Post-Conditions

Suppose you are writing a function called `average` that calculates
the average of the numbers in a list.
the average of the numbers in a NumPy array.
What pre-conditions and post-conditions would you write for it?
Compare your answer to your neighbor's:
can you think of a function that will pass your tests but not his/hers or vice versa?
Expand All @@ -467,9 +467,9 @@ can you think of a function that will pass your tests but not his/hers or vice v

```python
# a possible pre-condition:
assert len(input_list) > 0, 'List length must be non-zero'
assert len(input_array) > 0, 'List length must be non-zero'
ineelhere marked this conversation as resolved.
Show resolved Hide resolved
# a possible post-condition:
assert numpy.amin(input_list) <= average <= numpy.amax(input_list),
assert numpy.amin(input_array) <= average <= numpy.amax(input_array),
'Average should be between min and max of input values (inclusive)'
```

Expand Down
Loading