Skip to content

Ocelots - McKay#16

Open
mckay1818 wants to merge 4 commits intoada-ac2:masterfrom
mckay1818:master
Open

Ocelots - McKay#16
mckay1818 wants to merge 4 commits intoada-ac2:masterfrom
mckay1818:master

Conversation

@mckay1818
Copy link
Copy Markdown

No description provided.

Comment thread tests/test_wave_03.py
assert len(friends_unique_movies) == 3

raise Exception("Test needs to be completed.")
assert INTRIGUE_3 in friends_unique_movies
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job testing the content, as well

Comment thread viewing_party/party.py
@@ -1,23 +1,121 @@
# ------------- WAVE 1 --------------------

from shutil import move
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why did this line get included?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I am actually not sure how this line got into my code! I had never heard of the shutil module until noticing this comment, so this is as much a mystery to me as it is to you!

Comment thread viewing_party/party.py

def create_movie(title, genre, rating):
pass
if title and genre and rating:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job making use of "truthiness" to validate against "" and None here

Comment thread viewing_party/party.py
return user_data

def watch_movie(user_data, title):
for movie in user_data["watchlist"]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note, while this may work here, it's considered dangerous practice to modify the content of a data structure that you're looping over. Especially in more complex code, this can open you up to complex errors. A simple alternative here could be to save a copy of what you get from movie in user_data["watchlist"] and iterate over that, so that as you modify user_data["watchlist"], there's no risk.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it would be helpful for me to talk through what this alternative would look like in code. Just flagging here that I'll probably swing by your office hours next week to ask about this!

Comment thread viewing_party/party.py
num_of_movies = len(user_data["watched"])
for movie in user_data["watched"]:
total_rating_score += movie["rating"]
if num_of_movies == 0:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good check on div by zero

Comment thread viewing_party/party.py
else:
genres[movie["genre"]] = 1
#review this concept
return max(genres, key=genres.get)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of max() plus using the dict.get() as key to sort your dict!

Comment thread viewing_party/party.py
return total_rating_score / num_of_movies

def get_most_watched_genre(user_data):
genres = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of a dict as part of your data processing

Comment thread viewing_party/party.py
# ------------- WAVE 3 --------------------
# -----------------------------------------

def get_unique_watched(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could sets have been an alternate to the nested loop logic in these functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants