Skip to content

Commit

Permalink
code review prep
Browse files Browse the repository at this point in the history
  • Loading branch information
colevandersWands committed Dec 18, 2024
1 parent 33f8c9b commit ada3cde
Show file tree
Hide file tree
Showing 32 changed files with 384 additions and 51 deletions.
File renamed without changes
3 changes: 2 additions & 1 deletion 1_development_workflows/deliverables.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ interests, and anything else you'd like to share.

- [ ] You created your Profile README repository using
[the template `username` repository](https://github.com/MIT-Emerging-Talent/username)
- [ ] All of the CI checks pass under the Actions tab
- [ ] Your repository’s name matches your GitHub username.
- [ ] All of the CI checks pass under the Actions tab. _Or_ you commented the lines that failed CI checks explaining why you broke the rule to get the README you wanted. (eg. “I used HTML to align the image in the center”)

## Suggested Study

Expand Down
2 changes: 1 addition & 1 deletion 2_predictive_stepping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ then communicating with everyone involved to deliver quality software within
your project's constraints. This diagram shows the different channels of
communication in a simple Python program:

![a program](./.assets/what_is_programming.png)
![a program](../.assets/what_is_programming.png)

> PS. In the examples and exercises for this chapter you will be both the
> developer and the user, running the program and interacting with it from
Expand Down
2 changes: 1 addition & 1 deletion 2_predictive_stepping/lesson_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class: center

## What is Programming?

<img alt="What is programming?" src="./.assets/what_is_programming.png" height="100%" width="100%">
<img alt="What is programming?" src="../.assets/what_is_programming.png" height="100%" width="100%">

---

Expand Down
12 changes: 6 additions & 6 deletions 3_documenting_and_testing/behavior_strategy_implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ for index in range(2, 500):

assert two_back + one_back == current, f"entry {index} is not correct"

# %% does the function return the same or different arrays?
# %% does the function return the same or different lists?

array_1 = fibonacci_list(4)
array_2 = fibonacci_list(6)
list_1 = fibonacci_list(4)
list_2 = fibonacci_list(6)

# the function returned two different arrays with the same values
assert array_1 == array_2, "the arrays store the same values"
assert array_1 is not array_2, "the variables do not reference the same array"
# the function returned two different lists with the same values
assert list_1 == list_2, "the lists store the same values"
assert list_1 is not list_2, "the variables do not reference the same list"
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion 4_debugging/philosophy_of_debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ simple. For the above example the symptom corresponds to the line where the
variable went out of bounds or to the `print`s which produced the garbage output.
The incorrect behavior will correspond to a variable with a bad value. Identify
the variable(s) with bad values. For this example, suppose that the program
crashes on line 112 because i is -1 and tries to index an array.
crashes on line 112 because i is -1 and tries to index an list.

The critical question is: where did i get its value? There are basically three
ways a variable can get a value: the variable appears on the left hand side of a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def f(lst, key):
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def f(lst, key):
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def f(lst, key):
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def f(lst, key):
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def f(lst, sort_key):
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def filter_and_sort_dictionaries(
This function does not modify the argument list.
Parameters:
list[dict[str, str]]: an array of dicts with string keys and string values
list[dict[str, str]]: an list of dicts with string keys and string values
str: the function will remove all dicts that don't have this key
Returns: a list of dicts where each dict contains the given key,
Expand Down
2 changes: 1 addition & 1 deletion 6_recursion/2_visualize_recursion/exercises/count_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- comment @trace_recursion and debug the function
or copy the function into one of these sites:
- https://www.recursionvisualizer.com
- (https://recursion.vercel.app
- https://recursion.vercel.app
- https://recursion-visualizer.vercel.app
- https://visualgo.net/en/recursion
Expand Down
2 changes: 1 addition & 1 deletion 6_recursion/2_visualize_recursion/exercises/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- comment @trace_recursion and debug the function
or copy the function into one of these sites:
- https://www.recursionvisualizer.com
- (https://recursion.vercel.app
- https://recursion.vercel.app
- https://recursion-visualizer.vercel.app
- https://visualgo.net/en/recursion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- comment @trace_recursion and debug the function
or copy the function into one of these sites:
- https://www.recursionvisualizer.com
- (https://recursion.vercel.app
- https://recursion.vercel.app
- https://recursion-visualizer.vercel.app
- https://visualgo.net/en/recursion
Expand Down
6 changes: 2 additions & 4 deletions 6_recursion/3_use_recursion/1_debug/fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

@trace_recursion
def fibonacci(n: int) -> int:
"""
"""
if n < 0:
if n <= 0:
return 0

if n == 1:
Expand All @@ -30,6 +27,7 @@ def fibonacci(n: int) -> int:
print(fibonacci(0), 'should be', 0)
print(fibonacci(1), 'should be', 1)
print(fibonacci(2), 'should be', 1)
print(fibonacci(3), 'should be', 2)
print(fibonacci(4), 'should be', 3)
print(fibonacci(6), 'should be', 8)
print(fibonacci(8), 'should be', 21)
1 change: 1 addition & 0 deletions 6_recursion/3_use_recursion/1_debug/fibonacci_memo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def fibonacci_memo(n: int, memo: dict = {}) -> int:
print(fibonacci_memo(0), 'should be', 0)
print(fibonacci_memo(1), 'should be', 1)
print(fibonacci_memo(2), 'should be', 1)
print(fibonacci_memo(3), 'should be', 2)
print(fibonacci_memo(4), 'should be', 3)
print(fibonacci_memo(6), 'should be', 8)
print(fibonacci_memo(8), 'should be', 21)
11 changes: 1 addition & 10 deletions 6_recursion/code_along_using_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@

@trace_recursion
def reverse_list(to_reverse: list) -> list:
"""
behavior description
base case :
argument description -> turn-around description
recursive case:
argument description -> ƒ(break-down description) build-up description
"""
base_case = _ # must use to_reverse
if base_case:
turn_around = _
Expand All @@ -36,7 +28,6 @@ def reverse_list(to_reverse: list) -> list:


print(reverse_list([]), 'should be', [])
print(reverse_list([1]), 'should be', [1])
print(reverse_list(['a', 'b']), 'should be', ['a', 'b'])
print(reverse_list([1, 2]), 'should be', [2, 1])
print(reverse_list([1, 2, 3]), 'should be', [3, 2, 1])
print(reverse_list([3, 2, 1, 0, -1, -2, 3]), 'should be', [3, -2, -1, 0, 1, 2, 3])
27 changes: 14 additions & 13 deletions 6_recursion/lesson_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ class: middle, center
```py
# a recursive strategy for counting the items in a list
def count_items(list_of_things: list) -> int:
# base case: an empty array
# base case: an empty list
if len(list_of_things) == 0:
return 0 # turn-around: an empty list has 0 items

# break-down: create an array with 1 fewer items
# break-down: create an list with 1 fewer items
list_without_last_item = list_of_things[:-1]
# recursion: recursively count items in the smaller list
previously_counted = count_items(list_without_last_item)
Expand Down Expand Up @@ -217,10 +217,10 @@ def count_items(list_of_things: list) -> int:
recursive case:
a non-empty list -> ƒ(the list one item removed) + 1
"""
if len(list_of_things) == 0: # base case
return 0 # turn-around
# recursion, break-down, build-up
return count_items(list_of_things[:-1]) + 1
if len(list_of_things) == 0: # base case
return 0 # turn-around
# recursion, break-down, build-up
return count_items(list_of_things[:-1]) + 1

# use the recursive solution to count items in this list
count_items(['a', 'b', 'c', 'd'])
Expand Down Expand Up @@ -260,14 +260,15 @@ class: middle, center
# breaking down & recursing
count_items(['a', 'b', 'c', 'd'])
count_items(['a', 'b', 'c']) + 1
count_items(['a', 'b']) + 1 + 1
count_items(['a']) + 1 + 1 + 1
(count_items(['a', 'b']) + 1) + 1
((count_items(['a']) + 1) + 1) + 1
# base case
count_items([]) + 1 + 1 + 1 + 1
# turning around & building up
0 + 1 + 1 + 1 + 1
1 + 1 + 1 + 1
2 + 1 + 1
(((count_items([]) + 1) + 1) + 1) + 1
# turning around
(((0 + 1) + 1) + 1) + 1
# building up
((1 + 1) + 1) + 1
(2 + 1) + 1
3 + 1
4
```
Expand Down
Binary file added 7_code_review/.assets/collaborative_coding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 7_code_review/.assets/collaborative_writing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion 7_code_review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ colleague's code and let them know what is good, what could be better, and
suggest improvements if you can. The most important thing to keep in mind when
writing a code review is:

- _Talk about the code, not the person._
- _Review the code, not the person._

If there is something you would change in the code don't say "_you_ used a bad
variable name", say something like "_this variable name_ could be more clear".
Expand Down
22 changes: 22 additions & 0 deletions 7_code_review/deliverables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Deliverables

Working in a shared repository, you will each:

- push 2+ completed code challenges with documentation and tests
- review 2+ of your classmates’ solutions using the code review checklist

This is a chance to practice using GitHub features for code review, project management, and code quality automation. What you learn in this exercise will prepare you for the group Data Science projects in the certificate program.

## Checklist

- [ ] Your group used the repository we create for you
- [ ] Your group’s collaboration documents are all completed
- [ ] Your group’s project board is well-maintained
- [ ] All issues and pull requests have the correct labels (if necessary) so they are easy to find
- [ ] The code review checklist for each PR is completed before merging to `main`
- [ ] Each pull request either passes CI checks, or the failing CI checks are discussed in code review
- [ ] Each pull request is reviewed by at least one classmate using GitHub code review features before merging to `main`
- [ ] All code review discussions are positive and constructive - _review the code, not the person_
- [ ] Your group used helpful branch naming conventions

!! **Note** !! _You will not be assessed on how hard your coding challenges are_ !! !!
Loading

0 comments on commit ada3cde

Please sign in to comment.