Conversation
tgoslee
left a comment
There was a problem hiding this comment.
Theresa this was a good start to your project. I think that I can see why a few of your tests are failing. We do not want to make our own data/override user_data. You want to use the given parameters. When the functions are invoked that's when data would be added using the parameters. Let's schedule a time to talk through it.
|
|
||
| keys = ["title", "genre", "rating"] | ||
| values = [movie_title, genre, rating] | ||
| new_movie = {} |
There was a problem hiding this comment.
Instead of creating an empty dictionary, you can build a dictionary literal an example could look like
if title and genre and rating:
movie = {
"title": title,
"genre": genre,
"rating": rating
}
return movie| values = [movie_title, genre, rating] | ||
| new_movie = {} | ||
|
|
||
| if movie_title == None: |
There was a problem hiding this comment.
Here you are supposed to check if this is truthy but this only checks for None. To check if it's truthy you could so something like if not title or not genre or not rating:
| user_data = { | ||
| "watched": [] | ||
| } | ||
| new_list = [ ] | ||
| new_list.append(movie) | ||
|
|
||
| user_data["watched"]= new_list |
There was a problem hiding this comment.
you do not need to create user_data because its already being passed in as a parameter you would just need to do
# add movie to what user has watched
user_data["watched"].append(movie)
return user_data| user_data = { | ||
| "watchlist": [] | ||
| } | ||
| new_list = [ ] | ||
| new_list.append(movie) | ||
|
|
||
| user_data["watchlist"]= new_list | ||
| return user_data |
There was a problem hiding this comment.
same as above you could just do
def add_to_watchlist(user_data, movie):
# add movie to user's watchlist
user_data["watchlist"].append(movie)
return user_data| user_data["watchlist"]= new_list | ||
| return user_data | ||
|
|
||
| def watch_movie(user_data, MOVIE_TITLE_1): |
There was a problem hiding this comment.
Careful here! We don't want to accidentally overwrite the user_data's "watchlist" that's already been supplied to us in the tests in test_wave_01.py. It did pass the tests, but unfortunately, the tests did not account for "watchlist" with more than one movie in them.
Make sure we use the user_data instead, update it there, then return the user_data
| INTRIGUE_1, | ||
| INTRIGUE_3, | ||
| ] | ||
| def get_unique_watched(user_data): |
There was a problem hiding this comment.
how could you create a helper function to get the data you need for this function and for get_friends_unique_watched ?
| friends_watched = [] | ||
| comparison_list =[] | ||
| recommendations = [] | ||
| def get_available_recs(user_data): |
There was a problem hiding this comment.
think about the function get_friends_unique_watched(). How could it be used in this function?
| for movie in comparison_list: | ||
| if movie["host"] in user_data["subscriptions"]: | ||
| recommendations.append(movie) | ||
| # print(f"friends watched: {friends_watched}") |
|
|
||
| def get_rec_from_favorites(user_data): | ||
| favorites_rec = [] | ||
| user_watched_list = get_unique_watched(user_data) |
|
|
||
| new_list= [] | ||
| recommendations_list = [] | ||
| def get_new_rec_by_genre(USER_DATA_5): |
There was a problem hiding this comment.
we don't want to override user_data here. Change the parameter back to user_data and think about what helper function you could use here.
|
Yes I understand now. I can definitely work on rewriting the code and have also schedule a time on Monday to meet with you.
Thank you for your feedback.
Theresa
…Sent from my iPhone
On Apr 1, 2022, at 10:48 AM, Trenisha Goslee ***@***.***> wrote:
@tgoslee commented on this pull request.
Theresa this was a good start to your project. I think that I can see why a few of your tests are failing. We do not want to make our own data/override user_data. You want to use the given parameters. When the functions are invoked that's when data would be added using the parameters. Let's schedule a time to talk through it.
In viewing_party/party.py:
> # ------------- WAVE 1 --------------------
-def create_movie(title, genre, rating):
- pass
+def create_movie(movie_title, genre, rating):
+
+ keys = ["title", "genre", "rating"]
+ values = [movie_title, genre, rating]
+ new_movie = {}
Instead of creating an empty dictionary, you can build a dictionary literal an example could look like
if title and genre and rating:
movie = {
"title": title,
"genre": genre,
"rating": rating
}
return movie
In viewing_party/party.py:
> # ------------- WAVE 1 --------------------
-def create_movie(title, genre, rating):
- pass
+def create_movie(movie_title, genre, rating):
+
+ keys = ["title", "genre", "rating"]
+ values = [movie_title, genre, rating]
+ new_movie = {}
+
+ if movie_title == None:
Here you are supposed to check if this is truthy but this only checks for None. To check if it's truthy you could so something like if not title or not genre or not rating:
In viewing_party/party.py:
> + user_data = {
+ "watched": []
+ }
+ new_list = [ ]
+ new_list.append(movie)
+
+ user_data["watched"]= new_list
you do not need to create user_data because its already being passed in as a parameter you would just need to do
# add movie to what user has watched
user_data["watched"].append(movie)
return user_data
In viewing_party/party.py:
> + user_data = {
+ "watchlist": []
+ }
+ new_list = [ ]
+ new_list.append(movie)
+
+ user_data["watchlist"]= new_list
+ return user_data
same as above you could just do
def add_to_watchlist(user_data, movie):
# add movie to user's watchlist
user_data["watchlist"].append(movie)
return user_data
In viewing_party/party.py:
> +
+ user_data["watched"]= new_list
+ return user_data
+
+
+def add_to_watchlist(user_data, movie):
+ user_data = {
+ "watchlist": []
+ }
+ new_list = [ ]
+ new_list.append(movie)
+
+ user_data["watchlist"]= new_list
+ return user_data
+
+def watch_movie(user_data, MOVIE_TITLE_1):
Careful here! We don't want to accidentally overwrite the user_data's "watchlist" that's already been supplied to us in the tests in test_wave_01.py. It did pass the tests, but unfortunately, the tests did not account for "watchlist" with more than one movie in them.
Make sure we use the user_data instead, update it there, then return the user_data
In viewing_party/party.py:
> + if user_data["watched"] == []:
+ average = 0.0
+ return average
+ else:
+ for value in user_data.values():
+ ratings =[]
+ rate_list= value[0]
+ ratings.append(rate_list["rating"])
+ rate_list= value[1]
+ ratings.append(rate_list["rating"])
+ rate_list= value[2]
+ ratings.append(rate_list["rating"])
+ rate_list= value[3]
+ ratings.append(rate_list["rating"])
+ rate_list= value[4]
+ ratings.append(rate_list["rating"])
+ rate_list= value[5]
+ ratings.append(rate_list["rating"])
+ average = sum(ratings)/ len(ratings)
+ return average
+
Instead of appending each value you can do
def get_watched_avg_rating(user_data):
total = 0
movies = user_data["watched"]
n = len(movies)
if n == 0:
return 0
for movie in movies:
total += movie["rating"]
return total/n
In viewing_party/party.py:
> + average = sum(ratings)/ len(ratings)
+ return average
+
+def get_most_watched_genre(user_data):
+ genre_count = {}
+ if user_data["watched"] == []:
+ most_watched = None
+ return most_watched
+
+ else:
+ for movie in user_data["watched"]:
+ if movie["genre"] not in genre_count.keys():
+ genre_count[movie["genre"]] = 1
+ elif movie["genre"] in genre_count.keys():
+ genre_count[movie["genre"]] += 1
+ most_watched = max(genre_count, key=genre_count.get)
good use of max here. If you didn't use this method how would you handle this instead?
In viewing_party/party.py:
> +user_watched= [FANTASY_1,
+ FANTASY_2,
+ FANTASY_3,
+ ACTION_1,
+ INTRIGUE_1,
+ INTRIGUE_2,
+]
+
+first_friend_watched_data = [
+ FANTASY_1,
+ FANTASY_3,
+ FANTASY_4,
+ HORROR_1
+
+ ]
+second_friend_watched_data = [ FANTASY_1,
+ ACTION_1,
+ INTRIGUE_1,
+ INTRIGUE_3,
+ ]
If you wanted to do this for testing/debugging that's fine but you don't need these for your functions. When the functions are called/invoked that's when the data will be passed in
In viewing_party/party.py:
> + INTRIGUE_2,
+]
+
+first_friend_watched_data = [
+ FANTASY_1,
+ FANTASY_3,
+ FANTASY_4,
+ HORROR_1
+
+ ]
+second_friend_watched_data = [ FANTASY_1,
+ ACTION_1,
+ INTRIGUE_1,
+ INTRIGUE_3,
+ ]
+def get_unique_watched(user_data):
how could you create a helper function to get the data you need for this function and for get_friends_unique_watched ?
In viewing_party/party.py:
>
# -----------------------------------------
# ------------- WAVE 4 --------------------
# -----------------------------------------
+
+user_watched = []
+friends_watched = []
+comparison_list =[]
+recommendations = []
+def get_available_recs(user_data):
think about the function get_friends_unique_watched(). How could it be used in this function?
In viewing_party/party.py:
> + else:
+
+ for i in range(len(user_data["watched"])):
+ # user_watched = user_data["watched"][i]
+ user_watched.append(user_data["watched"][i])
+ for i in range(len(user_data["friends"])):
+ for j in range(len(user_data["friends"][i]["watched"])):
+ friends_watched.append(user_data["friends"][i]["watched"][j])
+ # user_watched.append(user_data["watched"][i])
+ for movie in friends_watched:
+ if movie not in user_watched:
+ comparison_list.append(movie)
+ for movie in comparison_list:
+ if movie["host"] in user_data["subscriptions"]:
+ recommendations.append(movie)
+ # print(f"friends watched: {friends_watched}")
remove these comments you aren't using
In viewing_party/party.py:
> # -----------------------------------------
# ------------- WAVE 5 --------------------
# -----------------------------------------
+new_list= []
+recommendations_list = []
+def get_new_rec_by_genre(USER_DATA_5):
+ for friend in USER_DATA_5["friends"]:
+ for movie in friend["watched"]:
+ if movie not in USER_DATA_5["watched"] and movie not in new_list:
+ new_list.append(movie)
+ for movie in new_list:
+ if movie["genre"]== "Fantasy":
+ recommendations_list.append(movie)
+ return recommendations_list
+
+def get_rec_from_favorites(user_data):
+ favorites_rec = []
+ user_watched_list = get_unique_watched(user_data)
great use of a helper function here.
In viewing_party/party.py:
> # -----------------------------------------
# ------------- WAVE 5 --------------------
# -----------------------------------------
+new_list= []
+recommendations_list = []
+def get_new_rec_by_genre(USER_DATA_5):
we don't want to override user_data here. Change the parameter back to user_data and think about what helper function you could use here.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
project 1 view_party submission