-
Notifications
You must be signed in to change notification settings - Fork 81
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
Kunzite - Celina B and Diana S #67
base: main
Are you sure you want to change the base?
Conversation
…passing all but Ada-C19#9, Celina's implementation (commented out) passing all but Ada-C19#9 and Ada-C19#10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good going, Celina and Diana! I've left suggestions and feedback below in your code.
Some things to consider:
- Make sure your variables are descriptive so that anyone reading your code will immediately understand what the function or code block is trying to accomplish
- Use
get_most_watched_genre
to help completeget_new_rec_by_genre
movie = {} | ||
if not title or not genre or not rating: | ||
return None | ||
else: | ||
movie.update({"title" : title, "genre" : genre, "rating" : rating}) | ||
return movie |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job on the guard clause! Let's move it to the top, though. That way we aren't creating data in memory that will be immediately tossed if the function hits lines 7-8.
Let's also bring the main focus of the function (creating a movie and returning it) outside a code block.
if not title or not genre or not rating:
return None
movie = {"title" : title, "genre" : genre, "rating" : rating}
return movie
user_data["watched"].append(movie) | ||
return user_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating our inputs first to check that movie
and/or user_data
is what we think it is:
if movie:
user_data["watched"].append(movie)
It's small and not necessarily important when passing these tests, but we never want to assume that a user will use our functions correctly.
user_data["watchlist"].append(movie) | ||
return user_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above! Let's check input validity!
return user_data | ||
|
||
def watch_movie(user_data, title): | ||
print(user_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always remember to delete any print statements for debugging purposes when submitting a finale project!
print(user_data) |
def watch_movie(user_data, title): | ||
print(user_data) | ||
watchlist_list_of_dict = user_data.get("watchlist") | ||
print(watchlist_list_of_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(watchlist_list_of_dict) |
for i in friends_recommendations_list_of_dict: | ||
if i.get("genre") == frequently_watched_genre_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's come up with a variable name that's more descriptive than i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is frequently_watched_genre_list
? Is it the most watched genre type, or is it a list? Can we compare a string to a list? Or, should frequently_watched_genre_list
be something else?
What if we call one of our functions to get us the most watched genre type, then use it to compare against our recommendation list?
assert movie_to_watch not in updated_data["watchlist"] | ||
assert movie_to_watch in updated_data["watched"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# ******************************************************************************************* | ||
# ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
# ******************************************************************************************* | ||
|
||
@pytest.mark.skip() | ||
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
assert INTRIGUE_3 in friends_unique_movies | ||
assert HORROR_1 in friends_unique_movies | ||
assert FANTASY_4 in friends_unique_movies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
highest_genre = None | ||
highest_count_sofar = 0 | ||
# loop through most watched dict to update | ||
for genre, count in most_watched_genre_dict.items(): | ||
if count > highest_count_sofar: | ||
highest_count_sofar = count | ||
highest_genre = genre | ||
#this better work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solely argument's sake, what's another way we might calculate the highest watched genre with our most_watched_genre_dict
dictionary and, say, the max
function? In what ways might max
help make our function more efficient? Or not?
No description provided.