From 78eceb59d36ab4f731c15abb4eac7a92910a513f Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 11:39:09 -0700 Subject: [PATCH 01/40] READ ME was changed Co-authored-by: Jennifer Tam --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ba28bf2ab..017644342 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ # Viewing Party +#Pair Plan: +Access needs - In Person and then if needed zoom/liveshare. (Possibly evening works for both of us for zoom) + +Your learning style - Getting errors and failed tests, also making print tests. Comments to help catch what the code is doing behind the scenes. + +How you prefer to receive feedback - Communicating ideas to each other and finding common ground or compromise for ideas that we are split on. + +One team communication skill you want to improve with this experience - New to team collaboration so we want to see what we might need to improve and what we excel at. + + ## Skills Assessed Solving problems with... From 1874fc50d195ae363d672006c841be23ece42f3f Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Mon, 27 Mar 2023 11:44:05 -0700 Subject: [PATCH 02/40] edited README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 017644342..602d4d507 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Viewing Party +## MEL & JEN #Pair Plan: Access needs - In Person and then if needed zoom/liveshare. (Possibly evening works for both of us for zoom) From 45fba942060f979c22d30b00674bb9a9478c0594 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 12:03:54 -0700 Subject: [PATCH 03/40] Changed test watchlist to empty watched Co-authored-by: Jennifer Tam --- tests/test_wave_01.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 669efee6a..8a843c5e6 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -159,7 +159,9 @@ def test_moves_movie_from_watchlist_to_empty_watched(): assert len(updated_data["watchlist"]) == 0 assert len(updated_data["watched"]) == 1 - raise Exception("Test needs to be completed.") + assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 + assert updated_data["watched"][0]["genre"] == GENRE_1 + assert updated_data["watched"][0]["rating"] == RATING_1 # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* @@ -184,6 +186,9 @@ def test_moves_movie_from_watchlist_to_watched(): assert len(updated_data["watched"]) == 2 raise Exception("Test needs to be completed.") + assert len(updated_data["watched"]) == 2 + assert movie in updated_data["watched"] + assert FANTASY_2 in updated_data["watched"] # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* From a68e40e589b2f6a81a3cb75bd67ca7ded4ca9f85 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 12:13:02 -0700 Subject: [PATCH 04/40] changes to test moves from watchlist to watched --- tests/test_wave_01.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 8a843c5e6..39712c409 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -184,11 +184,9 @@ def test_moves_movie_from_watchlist_to_watched(): # Assert assert len(updated_data["watchlist"]) == 1 assert len(updated_data["watched"]) == 2 - - raise Exception("Test needs to be completed.") - assert len(updated_data["watched"]) == 2 - assert movie in updated_data["watched"] - assert FANTASY_2 in updated_data["watched"] + assert watchlist in updated_data["watched"] + assert FANTASY_1 in updated_data["watched"] + # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* From ce827ea22d98f8ded9503a622779b8650345c00f Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Mon, 27 Mar 2023 19:42:27 -0700 Subject: [PATCH 05/40] Wave 2 - 2 failed/3 passed --- tests/test_wave_02.py | 10 +++++----- viewing_party/party.py | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 19f045c79..64b62729d 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_calculates_watched_average_rating(): # Arrange janes_data = clean_wave_2_data() @@ -14,7 +14,7 @@ def test_calculates_watched_average_rating(): assert average == pytest.approx(3.58333) assert janes_data == clean_wave_2_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_empty_watched_average_rating_is_zero(): # Arrange janes_data = { @@ -27,7 +27,7 @@ def test_empty_watched_average_rating_is_zero(): # Assert assert average == pytest.approx(0.0) -@pytest.mark.skip() +# @pytest.mark.skip() def test_most_watched_genre(): # Arrange janes_data = clean_wave_2_data() @@ -39,7 +39,7 @@ def test_most_watched_genre(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_most_watched_genre_order_mixed(): # Arrange janes_data = clean_wave_2b_data() @@ -51,7 +51,7 @@ def test_most_watched_genre_order_mixed(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2b_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_genre_is_None_if_empty_watched(): # Arrange janes_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..2cdbdc5dd 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -7,12 +7,37 @@ def create_movie(title, genre, rating): # ------------- WAVE 2 -------------------- # ----------------------------------------- +def get_watched_avg_rating(user_data): + # average_rating = 0.0 + # sum_rating = 0 + # for movies in user_data: + # sum_rating += sum(["rating"]) + # average_rating = sum_rating / len(movies) + + # return average_rating + sum_rating = 0 + average_rating = 0.0 + watched_movies = user_data.get("watched") + if not watched_movies: + return 0.0 + for movie in watched_movies: + sum_rating += movie.get("rating", 0) + average_rating = sum_rating / len(watched_movies) + return average_rating + +def get_most_watched_genre(user_data): + most_watched_genre = None + # genre_list = user_data.get("watched") + + return most_watched_genre # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- - +# def get_unique_watched(user_data): + + # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- From 7e874ab319b61224e455ebb284e100d6b6f29d60 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Mon, 27 Mar 2023 20:34:13 -0700 Subject: [PATCH 06/40] Wave 2 passed all tests --- viewing_party/party.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 2cdbdc5dd..905aadd63 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,3 +1,4 @@ +from statistics import multimode,mode # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): @@ -8,28 +9,34 @@ def create_movie(title, genre, rating): # ----------------------------------------- def get_watched_avg_rating(user_data): - # average_rating = 0.0 - # sum_rating = 0 - # for movies in user_data: - # sum_rating += sum(["rating"]) - # average_rating = sum_rating / len(movies) - - # return average_rating + # Set initial value of sum_rating to 0 sum_rating = 0 - average_rating = 0.0 - watched_movies = user_data.get("watched") - if not watched_movies: + # Create a new list of "watched" movies in user_data dict + movie_list = user_data["watched"] + + # Iterate through movies in list of movies + for movie in movie_list: + # Find the sum of the integers in value for "rating" in the movie dict + sum_rating += movie["rating"] + # If the input is an empty list, return 0.0 for average + if len(movie_list) == 0: return 0.0 - for movie in watched_movies: - sum_rating += movie.get("rating", 0) - average_rating = sum_rating / len(watched_movies) - return average_rating + else: + # Return the sum of movie ratings divided by the number of movies in input user_data dict + return sum_rating / len(movie_list) + def get_most_watched_genre(user_data): - most_watched_genre = None - # genre_list = user_data.get("watched") + genre_list = [] + + movie_list = user_data["watched"] + for movie in movie_list: + genre_list.append(movie["genre"]) + if len(genre_list) == 0: + return None + else: + return(multimode(genre_list)[0]) - return most_watched_genre # ----------------------------------------- # ------------- WAVE 3 -------------------- From 0f3fb4b002b5ff00fd7793c7adbaaabbb87f6c88 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 20:40:47 -0700 Subject: [PATCH 07/40] Started create movie wave 1 --- viewing_party/party.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 2cdbdc5dd..c9cfff65b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,8 +1,29 @@ # ------------- WAVE 1 -------------------- +#Create definition to store movie def create_movie(title, genre, rating): + #create empty dictionary to store the movie + movie = { "title": "", "genre" : "", "rating" : 0} + + #Check for edge case of one item being empty + if title is False or genre is False or rating is False: + return None + else: + movie["title"]= title + movie["genre"]= genre + movie["rating"]= rating + + return movie + +def add_to_watched(user_data, movie): + pass + +def add_to_watchlist(user_data, movie): pass + + + # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From 62dcb922cf098ffc9d5d4f4ec2d6b0d53f8cf387 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 20:46:13 -0700 Subject: [PATCH 08/40] Passed create movie tests and reskipped tests --- tests/test_wave_01.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 39712c409..9f13dfe95 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -4,7 +4,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +#@pytest.mark.skip() def test_create_successful_movie(): # Arrange movie_title = MOVIE_TITLE_1 @@ -19,7 +19,7 @@ def test_create_successful_movie(): assert new_movie["genre"] == GENRE_1 assert new_movie["rating"] == pytest.approx(RATING_1) -@pytest.mark.skip() +#@pytest.mark.skip() def test_create_no_title_movie(): # Arrange movie_title = None @@ -32,7 +32,7 @@ def test_create_no_title_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +#@pytest.mark.skip() def test_create_no_genre_movie(): # Arrange movie_title = "Title A" @@ -45,7 +45,7 @@ def test_create_no_genre_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +#@pytest.mark.skip() def test_create_no_rating_movie(): # Arrange movie_title = "Title A" @@ -58,7 +58,7 @@ def test_create_no_rating_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +#@pytest.mark.skip() def test_adds_movie_to_user_watched(): # Arrange movie = { @@ -79,7 +79,7 @@ def test_adds_movie_to_user_watched(): assert updated_data["watched"][0]["genre"] == GENRE_1 assert updated_data["watched"][0]["rating"] == RATING_1 -@pytest.mark.skip() +#@pytest.mark.skip() def test_adds_movie_to_non_empty_user_watched(): # Arrange movie = { @@ -99,7 +99,7 @@ def test_adds_movie_to_non_empty_user_watched(): assert movie in updated_data["watched"] assert FANTASY_2 in updated_data["watched"] -@pytest.mark.skip() +#@pytest.mark.skip() def test_adds_movie_to_user_watchlist(): # Arrange movie = { @@ -120,7 +120,7 @@ def test_adds_movie_to_user_watchlist(): assert updated_data["watchlist"][0]["genre"] == GENRE_1 assert updated_data["watchlist"][0]["rating"] == RATING_1 -@pytest.mark.skip() +#@pytest.mark.skip() def test_adds_movie_to_non_empty_user_watchlist(): # Arrange movie = { @@ -140,7 +140,7 @@ def test_adds_movie_to_non_empty_user_watchlist(): assert movie in updated_data["watchlist"] assert FANTASY_2 in updated_data["watchlist"] -@pytest.mark.skip() +#@pytest.mark.skip() def test_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -166,7 +166,7 @@ def test_moves_movie_from_watchlist_to_empty_watched(): # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +#@pytest.mark.skip() def test_moves_movie_from_watchlist_to_watched(): # Arrange movie_to_watch = HORROR_1 @@ -191,7 +191,7 @@ def test_moves_movie_from_watchlist_to_watched(): # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +#@pytest.mark.skip() def test_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 From 192b56488650ae3242b6b2c99fbb870828510715 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Mon, 27 Mar 2023 20:46:36 -0700 Subject: [PATCH 09/40] added notes to Wave 2 --- viewing_party/party.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 905aadd63..70bbc6fa5 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -29,12 +29,17 @@ def get_watched_avg_rating(user_data): def get_most_watched_genre(user_data): genre_list = [] + # Create a new list of "watched" movies in user_data dict movie_list = user_data["watched"] + # Iterate through movies in list of movies for movie in movie_list: + # Append genre values to the empty list genre_list genre_list.append(movie["genre"]) + # If genre_list is empty, return None if len(genre_list) == 0: return None else: + # It was returning as a string in a list, so I used [0] to return genre as a string return(multimode(genre_list)[0]) From 4e8d6b85170ab84b57b9e125c89a91bc28c56910 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 20:46:50 -0700 Subject: [PATCH 10/40] create movie passed all tests --- viewing_party/party.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index ccdf7aa72..105465f10 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -7,7 +7,7 @@ def create_movie(title, genre, rating): movie = { "title": "", "genre" : "", "rating" : 0} #Check for edge case of one item being empty - if title is False or genre is False or rating is False: + if title is None or genre is None or rating is None: return None else: movie["title"]= title From 6a6728ec5fa52bf3ece48f37844f457d8ffce7e6 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 21:24:39 -0700 Subject: [PATCH 11/40] completed add to watched function --- viewing_party/party.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5e7ced5aa..1ff16be74 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -6,7 +6,7 @@ def create_movie(title, genre, rating): #create empty dictionary to store the movie movie = { "title": "", "genre" : "", "rating" : 0} - #Check for edge case of one item being empty + #Check for edge case of one item being none if title is None or genre is None or rating is None: return None else: @@ -17,8 +17,12 @@ def create_movie(title, genre, rating): return movie def add_to_watched(user_data, movie): - pass + #add movie a dictionary to watchlist + user_data["watched"].append(movie) + return user_data + + def add_to_watchlist(user_data, movie): pass @@ -50,17 +54,12 @@ def get_watched_avg_rating(user_data): def get_most_watched_genre(user_data): genre_list = [] - # Create a new list of "watched" movies in user_data dict movie_list = user_data["watched"] - # Iterate through movies in list of movies for movie in movie_list: - # Append genre values to the empty list genre_list genre_list.append(movie["genre"]) - # If genre_list is empty, return None if len(genre_list) == 0: return None else: - # It was returning as a string in a list, so I used [0] to return genre as a string return(multimode(genre_list)[0]) From 4a278a135cfe716fdf4366621d6fa65b30ba1b53 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 21:32:18 -0700 Subject: [PATCH 12/40] Finished third function and passed tests --- viewing_party/party.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 1ff16be74..f826a180b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -17,16 +17,18 @@ def create_movie(title, genre, rating): return movie def add_to_watched(user_data, movie): - #add movie a dictionary to watchlist + #add movie a dictionary to watched user_data["watched"].append(movie) return user_data - - def add_to_watchlist(user_data, movie): - pass - + #add movie a dictionary to watchlist + user_data["watchlist"].append(movie) + return user_data +def watch_movie(user_data, title): + + # ----------------------------------------- From 90d22793a290d9ab4ea7b962f783c58b10ee3798 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Mon, 27 Mar 2023 22:39:25 -0700 Subject: [PATCH 13/40] Finished last function watchmovie & assertions fix --- tests/test_wave_01.py | 10 ++++++++-- viewing_party/party.py | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 9f13dfe95..a5cc1e78a 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -184,8 +184,14 @@ def test_moves_movie_from_watchlist_to_watched(): # Assert assert len(updated_data["watchlist"]) == 1 assert len(updated_data["watched"]) == 2 - assert watchlist in updated_data["watched"] - assert FANTASY_1 in updated_data["watched"] + + # Had to fix the assertions + assert updated_data["watchlist"][0] == FANTASY_1 + assert movie_to_watch in updated_data["watched"] + + # Old assertions + #assert watchlist in updated_data["watched"] + #assert FANTASY_1 in updated_data["watched"] # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** diff --git a/viewing_party/party.py b/viewing_party/party.py index f826a180b..55d905275 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -28,6 +28,12 @@ def add_to_watchlist(user_data, movie): def watch_movie(user_data, title): + #check if title is in watchlist, add it to watched + for movie in user_data["watchlist"]: + if title in movie["title"]: + add_to_watched(user_data, movie) + user_data["watchlist"].remove(movie) + return user_data From 55309e2ad3239bf1c66caa7b727fcc45ff4e40f6 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Tue, 28 Mar 2023 09:57:54 -0700 Subject: [PATCH 14/40] started Wave 3 --- viewing_party/party.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5e7ced5aa..1c063197c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -68,7 +68,9 @@ def get_most_watched_genre(user_data): # ------------- WAVE 3 -------------------- # ----------------------------------------- -# def get_unique_watched(user_data): +def get_unique_watched(user_data): + pass + # ----------------------------------------- @@ -77,5 +79,4 @@ def get_most_watched_genre(user_data): # ----------------------------------------- # ------------- WAVE 5 -------------------- -# ----------------------------------------- - +# ----------------------------------------- \ No newline at end of file From 9827d546207d44438e5d387903023f680684466f Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Tue, 28 Mar 2023 13:42:03 -0700 Subject: [PATCH 15/40] edited test comments for 1 --- tests/test_wave_01.py | 2 +- viewing_party/party.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index a5cc1e78a..7e0f1ad92 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -191,7 +191,7 @@ def test_moves_movie_from_watchlist_to_watched(): # Old assertions #assert watchlist in updated_data["watched"] - #assert FANTASY_1 in updated_data["watched"] + # assert FANTASY_1 in updated_data["watchlist"] # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** diff --git a/viewing_party/party.py b/viewing_party/party.py index a4e88a29d..2d2262a16 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,12 +1,12 @@ from statistics import multimode,mode # ------------- WAVE 1 -------------------- -#Create definition to store movie +# Create definition to store movie def create_movie(title, genre, rating): - #create empty dictionary to store the movie + # Create empty dictionary to store the movie movie = { "title": "", "genre" : "", "rating" : 0} - #Check for edge case of one item being none + # Check for edge case of one item being none if title is None or genre is None or rating is None: return None else: @@ -17,18 +17,18 @@ def create_movie(title, genre, rating): return movie def add_to_watched(user_data, movie): - #add movie a dictionary to watched + # Add movie a dictionary to watched user_data["watched"].append(movie) return user_data def add_to_watchlist(user_data, movie): - #add movie a dictionary to watchlist + # Add movie a dictionary to watchlist user_data["watchlist"].append(movie) return user_data def watch_movie(user_data, title): - #check if title is in watchlist, add it to watched + # Check if title is in watchlist, add it to watched for movie in user_data["watchlist"]: if title in movie["title"]: add_to_watched(user_data, movie) @@ -79,6 +79,8 @@ def get_unique_watched(user_data): pass +def get_friends_unique_watched(user_data): + pass # ----------------------------------------- # ------------- WAVE 4 -------------------- From 9c78cfb058569ebae888455f1045125b3f22d485 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Tue, 28 Mar 2023 15:11:37 -0700 Subject: [PATCH 16/40] Started wave 4 errors --- tests/test_wave_04.py | 6 +++--- viewing_party/party.py | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/test_wave_04.py b/tests/test_wave_04.py index 499669077..67f432045 100644 --- a/tests/test_wave_04.py +++ b/tests/test_wave_04.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() + def test_get_available_friend_rec(): # Arrange amandas_data = clean_wave_4_data() @@ -16,7 +16,7 @@ def test_get_available_friend_rec(): assert FANTASY_4b in recommendations assert amandas_data == clean_wave_4_data() -@pytest.mark.skip() + def test_no_available_friend_recs(): # Arrange amandas_data = { @@ -38,7 +38,7 @@ def test_no_available_friend_recs(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() + def test_no_available_friend_recs_watched_all(): # Arrange amandas_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 2d2262a16..090bf7d75 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,12 +1,12 @@ from statistics import multimode,mode # ------------- WAVE 1 -------------------- -# Create definition to store movie +#Create function to store movie def create_movie(title, genre, rating): - # Create empty dictionary to store the movie + #create empty dictionary to store the movie movie = { "title": "", "genre" : "", "rating" : 0} - # Check for edge case of one item being none + #Check for edge case of one item being none if title is None or genre is None or rating is None: return None else: @@ -17,12 +17,12 @@ def create_movie(title, genre, rating): return movie def add_to_watched(user_data, movie): - # Add movie a dictionary to watched + #add movie a dictionary to watched user_data["watched"].append(movie) return user_data def add_to_watchlist(user_data, movie): - # Add movie a dictionary to watchlist + #add movie a dictionary to watchlist user_data["watchlist"].append(movie) return user_data @@ -75,17 +75,19 @@ def get_most_watched_genre(user_data): # ------------- WAVE 3 -------------------- # ----------------------------------------- -def get_unique_watched(user_data): - pass - +# def get_unique_watched(user_data): -def get_friends_unique_watched(user_data): - pass # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- - +def get_available_recs(user_data): + recs = [] + for movie in user_data["friends"]["watched"]: + if movie not in user_data["watched"] and user_data["subscription"] in user_data["friends"]["watched"]["host"]: + recs.append(movie) + return recs # ----------------------------------------- # ------------- WAVE 5 -------------------- -# ----------------------------------------- \ No newline at end of file +# ----------------------------------------- + From 2cb342ec9bfa2023585e4fe9a928ac6d61fb2451 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Tue, 28 Mar 2023 15:15:49 -0700 Subject: [PATCH 17/40] additions made to Wave 3 --- tests/test_constants.py | 10 ++++++++++ tests/test_wave_03.py | 6 +++--- viewing_party/party.py | 6 ++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index b778463e9..7930587ee 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -91,6 +91,16 @@ #-----WAVE 3-------- USER_DATA_3 = copy.deepcopy(USER_DATA_2) +# USER_DATA_2 = { +# "watched": [ +# FANTASY_1, +# FANTASY_2, +# FANTASY_3, +# ACTION_1, +# INTRIGUE_1, +# INTRIGUE_2 +# ], +# } USER_DATA_3["friends"] = [ { "watched": [ diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 046429360..a67805ca6 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -16,7 +16,7 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_my_not_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -54,8 +54,8 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 + assert INTRIGUE_3 in amandas_data["friends"][0]["watched"] - raise Exception("Test needs to be completed.") # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** diff --git a/viewing_party/party.py b/viewing_party/party.py index 2d2262a16..438c8a89b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -76,8 +76,10 @@ def get_most_watched_genre(user_data): # ----------------------------------------- def get_unique_watched(user_data): - pass - + user_watched = user_data["watched"] + friends_watched = [friend["watched"] for friend in user_data["friends"]] + unique_watched = [movie for movie in user_watched if movie not in friends_watched] + return unique_watched def get_friends_unique_watched(user_data): pass From 98f8a75e072099b724738f331d9adc3fc793ee9f Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Tue, 28 Mar 2023 23:16:45 -0700 Subject: [PATCH 18/40] updated wave 4, not done --- viewing_party/party.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index c17e1fc34..b88a1a841 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -87,11 +87,19 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- -def get_available_recs(user_data): - recs = [] - for movie in user_data["friends"]["watched"]: - if movie not in user_data["watched"] and user_data["subscription"] in user_data["friends"]["watched"]["host"]: - recs.append(movie) +def get_available_recs(user_data): + recommended =[] + user_watched = user_data["watched"] + print(user_watched) + friends_watched = [friend["watched"] for friend in user_data["friends"]] + print("*****moo***") + print(friends_watched) + recs = [movie for movie in friends_watched if not user_watched] + print(recs) + if user_data["subscriptions"] in recs[0]["host"]: + recommended.append(recs) + print("~~~more~~~") + print(recommended) return recs # ----------------------------------------- # ------------- WAVE 5 -------------------- From 8fdd41381645f429dfa6042516a1f29aac67ad6c Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 09:00:36 -0700 Subject: [PATCH 19/40] Wave 3 4 passed/1 failed --- tests/test_wave_03.py | 10 ++++++---- viewing_party/party.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index a67805ca6..cd9a5e963 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -28,7 +28,7 @@ def test_my_not_unique_movies(): # Assert assert len(amandas_unique_movies) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -43,7 +43,7 @@ def test_friends_unique_movies(): assert FANTASY_4 in friends_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies_not_duplicated(): # Arrange amandas_data = clean_wave_3_data() @@ -54,13 +54,15 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 - assert INTRIGUE_3 in amandas_data["friends"][0]["watched"] + assert INTRIGUE_3 in friends_unique_movies + assert HORROR_1 in friends_unique_movies + assert FANTASY_4 in friends_unique_movies # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_not_unique_movies(): # Arrange amandas_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index c17e1fc34..c9a0818e3 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -77,12 +77,34 @@ def get_most_watched_genre(user_data): def get_unique_watched(user_data): user_watched = user_data["watched"] - friends_watched = [friend["watched"] for friend in user_data["friends"]] - unique_watched = [movie for movie in user_watched if movie not in friends_watched] - return unique_watched + friends_watched = [] + + for friend in user_data["friends"]: + friends_watched += friend["watched"] + unique_movies = [] + + for movie in user_watched: + if movie not in friends_watched and movie not in unique_movies: + unique_movies.append(movie) + + return unique_movies def get_friends_unique_watched(user_data): - pass + # Get the list of watched movies from the user + watched_movies = user_data["watched"] + # Set up an empty list to store movies that the user's friends have watched + friends_unique_watched = [] + # Iterate through each friend in the user's list of friends + for friend in user_data["friends"]: + # Iterate through each movie that the friend has watched + for movie in friend["watched"]: + # Check if the user has watched the movie + if movie not in watched_movies: + # If not, add the movie to the friends_unique_watched list + friends_unique_watched.append(movie) + # Return the list of movies + return friends_unique_watched + # ----------------------------------------- # ------------- WAVE 4 -------------------- From 705628d7f046b81d5984d804af3e312326ce96c7 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Wed, 29 Mar 2023 11:35:44 -0700 Subject: [PATCH 20/40] passing 2 tests wave 4 --- viewing_party/party.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5d8663623..9d35a6e29 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -111,18 +111,26 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- def get_available_recs(user_data): recommended =[] - user_watched = user_data["watched"] - print(user_watched) - friends_watched = [friend["watched"] for friend in user_data["friends"]] - print("*****moo***") - print(friends_watched) - recs = [movie for movie in friends_watched if not user_watched] - print(recs) - if user_data["subscriptions"] in recs[0]["host"]: - recommended.append(recs) - print("~~~more~~~") - print(recommended) - return recs + watched_movies = user_data["watched"] + # Set up an empty list to store movies that the user's friends have watched + friends_watched = [] + # Iterate through each friend in the user's list of friends + for friend in user_data["friends"]: + # Iterate through each movie that the friend has watched + for movie in friend["watched"]: + # Check if the user has watched the movie + if movie not in watched_movies: + # If not, add the movie to the friends_unique_watched list + friends_watched.append(movie) + print(friends_watched) + print("***********") + # Check if movie is available in the user's subscription + if friends_watched[0]["host"] in watched_movies: + # If so, then add movie to recommended list + recommended.append(movie) + + return recommended + # Return the list of movies # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- From 4c035bb1fb0015cd56fd50cc2a2b5809614cea03 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 11:56:25 -0700 Subject: [PATCH 21/40] Wave 3 passed all tests. yayyyy --- viewing_party/party.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5d8663623..873513cdc 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -81,8 +81,8 @@ def get_unique_watched(user_data): for friend in user_data["friends"]: friends_watched += friend["watched"] - unique_movies = [] + unique_movies = [] for movie in user_watched: if movie not in friends_watched and movie not in unique_movies: unique_movies.append(movie) @@ -99,7 +99,7 @@ def get_friends_unique_watched(user_data): # Iterate through each movie that the friend has watched for movie in friend["watched"]: # Check if the user has watched the movie - if movie not in watched_movies: + if movie not in watched_movies and movie not in friends_unique_watched: # If not, add the movie to the friends_unique_watched list friends_unique_watched.append(movie) # Return the list of movies From 8a63e96b28ad967d1fe57fec8dfb2c49b35ab6c5 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 20:07:42 -0700 Subject: [PATCH 22/40] Wave 5 passed 2 tests / left earlier implementations commented --- tests/test_wave_05.py | 10 ++++---- viewing_party/party.py | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index b2ba9ad33..0b3407d28 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_new_genre_rec(): # Arrange sonyas_data = clean_wave_5_data() @@ -17,7 +17,7 @@ def test_new_genre_rec(): assert FANTASY_4b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_new_genre_rec_from_empty_watched(): # Arrange sonyas_data = { @@ -58,7 +58,7 @@ def test_new_genre_rec_from_empty_friends(): # ****** Complete the Act and Assert Portions of these tests ********** # ********************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() def test_unique_rec_from_favorites(): # Arrange sonyas_data = clean_wave_5_data() @@ -72,7 +72,7 @@ def test_unique_rec_from_favorites(): assert INTRIGUE_2b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_unique_from_empty_favorites(): # Arrange sonyas_data = { @@ -94,7 +94,7 @@ def test_unique_from_empty_favorites(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_new_rec_from_empty_friends(): # Arrange sonyas_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 06b8450b0..92b8df9c9 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -135,3 +135,57 @@ def get_available_recs(user_data): # ------------- WAVE 5 -------------------- # ----------------------------------------- +# def get_new_rec_by_genre(user_data): +# reccommended_movies = [] +# user_watched = user_data["watched"] +# genre = get_most_watched_genre(user_watched) +# for movie in user_watched: +# if movie["genre"] == genre and movie not in user_watched: + +# reccommended_movies.append(movie) +# return reccommended_movies + + +# def get_new_rec_by_genre(user_data): +# most_watched_genre = get_most_watched_genre(user_data) +# recommended_movies = [] +# [friend for friend in user_data["friends"]]: +# for movie in friend["watched"]: +# if movie["genre"] == most_watched_genre and movie not in user_data["watched"]: +# recommended_movies.append(movie) + +# return recommended_movies + +def get_new_rec_by_genre(user_data): + # get most frequent genre + genre = get_most_watched_genre(user_data) + + # get list of friends + friends = user_data["friends"] + + # get list of movies user has watched + watched_movies = user_data["watched"] + # watchlist = get_friends_unique_watched(user_data) + + # create empty list of recommended movies + rec_movies = [] + + # loop over friends + for friend in friends: + # get list of movies watched by friend + friend_movies = friend["watched"] + + # loop over movies watched by friend + for movie in friend_movies: + # check if movie meets criteria + if movie["genre"] == genre and movie not in watched_movies and movie not in rec_movies: + # if so, add to list of recommended movies + rec_movies.append(movie) + + # return list of recommended movies + return rec_movies + + +def get_rec_from_favorites(user_data): + favorites = [] + pass \ No newline at end of file From ce10bf78c9c2fa841da65d2256ced386fb94301a Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 20:10:09 -0700 Subject: [PATCH 23/40] edited out earlier implementations --- viewing_party/party.py | 50 ++++++++++-------------------------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 92b8df9c9..fa06982f6 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -135,55 +135,29 @@ def get_available_recs(user_data): # ------------- WAVE 5 -------------------- # ----------------------------------------- -# def get_new_rec_by_genre(user_data): -# reccommended_movies = [] -# user_watched = user_data["watched"] -# genre = get_most_watched_genre(user_watched) -# for movie in user_watched: -# if movie["genre"] == genre and movie not in user_watched: - -# reccommended_movies.append(movie) -# return reccommended_movies - - -# def get_new_rec_by_genre(user_data): -# most_watched_genre = get_most_watched_genre(user_data) -# recommended_movies = [] -# [friend for friend in user_data["friends"]]: -# for movie in friend["watched"]: -# if movie["genre"] == most_watched_genre and movie not in user_data["watched"]: -# recommended_movies.append(movie) - -# return recommended_movies - def get_new_rec_by_genre(user_data): - # get most frequent genre + # Get most frequent genre genre = get_most_watched_genre(user_data) - - # get list of friends + # List of friends friends = user_data["friends"] - - # get list of movies user has watched + # List of movies user has watched watched_movies = user_data["watched"] - # watchlist = get_friends_unique_watched(user_data) - - # create empty list of recommended movies - rec_movies = [] + # Create empty list of recommended movies + recommended_movies = [] - # loop over friends + # Loop over friends for friend in friends: - # get list of movies watched by friend + # List of movies watched by friend friend_movies = friend["watched"] - - # loop over movies watched by friend + # Loop over movies watched by friend for movie in friend_movies: - # check if movie meets criteria - if movie["genre"] == genre and movie not in watched_movies and movie not in rec_movies: + # Conditional if movie is favorite genre/user has not watched + if movie["genre"] == genre and movie not in watched_movies and movie not in recommended_movies: # if so, add to list of recommended movies - rec_movies.append(movie) + recommended_movies.append(movie) # return list of recommended movies - return rec_movies + return recommended_movies def get_rec_from_favorites(user_data): From cb2e98e90695387d36c195780debe676fe5ed8fc Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 20:46:15 -0700 Subject: [PATCH 24/40] added assertion to Wave 5 test --- tests/test_wave_05.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index 0b3407d28..c2ffafad9 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -38,7 +38,7 @@ def test_new_genre_rec_from_empty_watched(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_new_genre_rec_from_empty_friends(): # Arrange sonyas_data = { @@ -53,7 +53,10 @@ def test_new_genre_rec_from_empty_friends(): ] } - raise Exception("Test needs to be completed.") + recommendations = get_new_rec_by_genre(sonyas_data) + + assert len(recommendations) == 0 + # ********************************************************************* # ****** Complete the Act and Assert Portions of these tests ********** # ********************************************************************* From a243ae8ef3a04ad991507a33efe0a058328e1488 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 20:47:36 -0700 Subject: [PATCH 25/40] wrote second function for Wave 5 // 2 failed tests --- viewing_party/party.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index fa06982f6..8e83fb159 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -161,5 +161,22 @@ def get_new_rec_by_genre(user_data): def get_rec_from_favorites(user_data): - favorites = [] - pass \ No newline at end of file + # List of friends + friends = user_data["friends"] + # Create empty list of recommended movies + recommended_movies = [] + + # # Loop over friends + for friend in friends: + # List of movies watched by friend + friend_movies = friend["watched"] + + # Loop over movies watched by friend + for movie in friend_movies: + # Conditional if movie is favorite genre/user has not watched + if movie in user_data["favorites"] and movie not in friend_movies: + # if so, add to list of recommended movies + recommended_movies.append(movie) + + # return list of recommended movies + return recommended_movies From 17352afe9fc40c47f95793d486dd10c686b1e58e Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 20:55:51 -0700 Subject: [PATCH 26/40] edited notes in Wave 5 --- viewing_party/party.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 8e83fb159..3b5d59de5 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -173,7 +173,7 @@ def get_rec_from_favorites(user_data): # Loop over movies watched by friend for movie in friend_movies: - # Conditional if movie is favorite genre/user has not watched + # Conditional if movie is in favorites/friends have not watched if movie in user_data["favorites"] and movie not in friend_movies: # if so, add to list of recommended movies recommended_movies.append(movie) From 2e2574c0376aa2bee9de6e0824d274ad699db822 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 21:43:51 -0700 Subject: [PATCH 27/40] alternate implementation for Wave 2 without using multimode --- viewing_party/party.py | 43 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 3b5d59de5..56654b01b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -71,6 +71,45 @@ def get_most_watched_genre(user_data): return(multimode(genre_list)[0]) +# My super long implementation w/o using multimode +# def get_most_watched_genre(user_data): +# # Check if user_data has a watched list +# if "watched" not in user_data: +# return None + +# # Get the watched list +# watched_list = user_data["watched"] + +# # Check if the watched list is empty +# if len(watched_list) == 0: +# return None + +# # Create a dictionary to store the count of each genre +# genre_count = {} + +# # Iterate through the watched list +# for movie in watched_list: +# genre = movie["genre"] + +# # Check if the genre is already in the dictionary +# if genre in genre_count: +# # Increment the count +# genre_count[genre] += 1 +# else: +# # Initialize the count +# genre_count[genre] = 1 + +# # Get the most frequent genre +# most_frequent_genre = None +# most_frequent_count = 0 + +# for genre, count in genre_count.items(): +# if count > most_frequent_count: +# most_frequent_count = count + +# return most_frequent_count + + # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- @@ -163,6 +202,8 @@ def get_new_rec_by_genre(user_data): def get_rec_from_favorites(user_data): # List of friends friends = user_data["friends"] + # List of users favorite movies + user_favorites = user_data["favorites"] # Create empty list of recommended movies recommended_movies = [] @@ -174,7 +215,7 @@ def get_rec_from_favorites(user_data): # Loop over movies watched by friend for movie in friend_movies: # Conditional if movie is in favorites/friends have not watched - if movie in user_data["favorites"] and movie not in friend_movies: + if movie in user_favorites and movie not in friend_movies: # if so, add to list of recommended movies recommended_movies.append(movie) From f9d9a14221664de999ded407488b3060fcf74ef5 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Wed, 29 Mar 2023 21:50:41 -0700 Subject: [PATCH 28/40] edited super long implementation for second function of Wave 2 --- viewing_party/party.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 56654b01b..7299adc84 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -71,12 +71,8 @@ def get_most_watched_genre(user_data): return(multimode(genre_list)[0]) -# My super long implementation w/o using multimode +# # My super long implementation w/o using multimode # def get_most_watched_genre(user_data): -# # Check if user_data has a watched list -# if "watched" not in user_data: -# return None - # # Get the watched list # watched_list = user_data["watched"] @@ -106,7 +102,7 @@ def get_most_watched_genre(user_data): # for genre, count in genre_count.items(): # if count > most_frequent_count: # most_frequent_count = count - + # return most_frequent_count From a165862f6274c1b140d6cfe675f1d0d64202f012 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Wed, 29 Mar 2023 22:19:08 -0700 Subject: [PATCH 29/40] Made more progress on wave 4 --- viewing_party/party.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 3b5d59de5..9625dd413 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -110,27 +110,26 @@ def get_friends_unique_watched(user_data): # ------------- WAVE 4 -------------------- # ----------------------------------------- def get_available_recs(user_data): - recommended =[] + # List of friends + friends = user_data["friends"] + # List of movies user has watched watched_movies = user_data["watched"] - # Set up an empty list to store movies that the user's friends have watched - friends_watched = [] - # Iterate through each friend in the user's list of friends - for friend in user_data["friends"]: - # Iterate through each movie that the friend has watched - for movie in friend["watched"]: - # Check if the user has watched the movie - if movie not in watched_movies: - # If not, add the movie to the friends_unique_watched list - friends_watched.append(movie) - print(friends_watched) - print("***********") - # Check if movie is available in the user's subscription - if friends_watched[0]["host"] in watched_movies: - # If so, then add movie to recommended list - recommended.append(movie) - - return recommended - # Return the list of movies + # Create empty list of recommended movies + recommendations = [] + + # Loop over friends + for friend in friends: + # List of movies watched by friend + friend_movies = friend["watched"] + # Loop over movies watched by friend + for movie in friend_movies: + # Conditional if movie user has not watched and movie has available host + if movie["host"] in user_data["subscriptions"] and movie not in watched_movies and movie not in recommendations: + # if so, add to list of recommended movies + recommendations.append(movie) + print(movie) + # return list of recommended movies + return recommendations # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- From 13bae3b4d5f99c0fd3ddce06e57070a9146688a7 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Wed, 29 Mar 2023 23:22:57 -0700 Subject: [PATCH 30/40] Finished wave 4 test passed --- viewing_party/party.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 703d636e3..c766a609f 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -144,6 +144,7 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- + def get_available_recs(user_data): # List of friends friends = user_data["friends"] @@ -151,20 +152,19 @@ def get_available_recs(user_data): watched_movies = user_data["watched"] # Create empty list of recommended movies recommendations = [] - + friend_movies = [] # Loop over friends for friend in friends: # List of movies watched by friend friend_movies = friend["watched"] # Loop over movies watched by friend - for movie in friend_movies: - # Conditional if movie user has not watched and movie has available host - if movie["host"] in user_data["subscriptions"] and movie not in watched_movies and movie not in recommendations: - # if so, add to list of recommended movies - recommendations.append(movie) - print(movie) + for movie in friend_movies: + if movie["host"] in user_data["subscriptions"] and movie not in watched_movies and movie not in recommendations: + # if so, add to list of recommended movies + recommendations.append(movie) # return list of recommended movies return recommendations + # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- @@ -184,11 +184,11 @@ def get_new_rec_by_genre(user_data): # List of movies watched by friend friend_movies = friend["watched"] # Loop over movies watched by friend - for movie in friend_movies: - # Conditional if movie is favorite genre/user has not watched - if movie["genre"] == genre and movie not in watched_movies and movie not in recommended_movies: - # if so, add to list of recommended movies - recommended_movies.append(movie) + for movie in friend_movies: + # Conditional if movie is favorite genre/user has not watched + if movie["genre"] == genre and movie not in watched_movies and movie not in recommended_movies: + # if so, add to list of recommended movies + recommended_movies.append(movie) # return list of recommended movies return recommended_movies From bbe931c053685113c8dcb07a6c1ecc330b44e726 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Thu, 30 Mar 2023 10:28:21 -0700 Subject: [PATCH 31/40] Wave 5 passed all tests --- viewing_party/party.py | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 7299adc84..2de99a83f 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -191,29 +191,17 @@ def get_new_rec_by_genre(user_data): # if so, add to list of recommended movies recommended_movies.append(movie) - # return list of recommended movies + # Return list of recommended movies return recommended_movies def get_rec_from_favorites(user_data): - # List of friends - friends = user_data["friends"] - # List of users favorite movies - user_favorites = user_data["favorites"] - # Create empty list of recommended movies - recommended_movies = [] + favorites = user_data["favorites"] + unique_watched = get_unique_watched(user_data) + reccomendation_list = [] - # # Loop over friends - for friend in friends: - # List of movies watched by friend - friend_movies = friend["watched"] + for movie in favorites: + if movie in unique_watched: + reccomendation_list.append(movie) - # Loop over movies watched by friend - for movie in friend_movies: - # Conditional if movie is in favorites/friends have not watched - if movie in user_favorites and movie not in friend_movies: - # if so, add to list of recommended movies - recommended_movies.append(movie) - - # return list of recommended movies - return recommended_movies + return reccomendation_list \ No newline at end of file From 7ae2262be719c014948c8a7bba50a20ea83fc718 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Thu, 30 Mar 2023 10:37:48 -0700 Subject: [PATCH 32/40] edited notes --- viewing_party/party.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index f00e78b4a..468d8185c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,12 +1,12 @@ from statistics import multimode,mode # ------------- WAVE 1 -------------------- -#Create function to store movie +# Create function to store movie def create_movie(title, genre, rating): - #create empty dictionary to store the movie + # Create empty dictionary to store the movie movie = { "title": "", "genre" : "", "rating" : 0} - #Check for edge case of one item being none + # Check for edge case of one item being none if title is None or genre is None or rating is None: return None else: @@ -17,12 +17,12 @@ def create_movie(title, genre, rating): return movie def add_to_watched(user_data, movie): - #add movie a dictionary to watched + # Add movie a dictionary to watched user_data["watched"].append(movie) return user_data def add_to_watchlist(user_data, movie): - #add movie a dictionary to watchlist + # Add movie a dictionary to watchlist user_data["watchlist"].append(movie) return user_data @@ -160,9 +160,9 @@ def get_available_recs(user_data): # Loop over movies watched by friend for movie in friend_movies: if movie["host"] in user_data["subscriptions"] and movie not in watched_movies and movie not in recommendations: - # if so, add to list of recommended movies + # If so, add to list of recommended movies recommendations.append(movie) - # return list of recommended movies + # Return list of recommended movies return recommendations # ----------------------------------------- @@ -187,7 +187,7 @@ def get_new_rec_by_genre(user_data): for movie in friend_movies: # Conditional if movie is favorite genre/user has not watched if movie["genre"] == genre and movie not in watched_movies and movie not in recommended_movies: - # if so, add to list of recommended movies + # If so, add to list of recommended movies recommended_movies.append(movie) # Return list of recommended movies From 04f78a8e436f64a7d5328831339d904c1bc8adc9 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 13:59:26 -0700 Subject: [PATCH 33/40] Refactored & made it DRY-er Co-authored-by: Jennifer Tam --- viewing_party/party.py | 61 +++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 468d8185c..4ea6f001c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -19,24 +19,28 @@ def create_movie(title, genre, rating): def add_to_watched(user_data, movie): # Add movie a dictionary to watched user_data["watched"].append(movie) + return user_data def add_to_watchlist(user_data, movie): # Add movie a dictionary to watchlist user_data["watchlist"].append(movie) + return user_data def watch_movie(user_data, title): - # Check if title is in watchlist, add it to watched + # Iterate through movies in user watchlist for movie in user_data["watchlist"]: + # Conditional if title is in user movie in watched if title in movie["title"]: add_to_watched(user_data, movie) + # Then remove the watched movie from watchlist user_data["watchlist"].remove(movie) + return user_data - # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- @@ -60,14 +64,20 @@ def get_watched_avg_rating(user_data): def get_most_watched_genre(user_data): + # Create variable that is a list genre_list = [] + # Set variable to user's watched list movie_list = user_data["watched"] + # Loop through movies in user's watched list for movie in movie_list: + # Add movie genre to genre list genre_list.append(movie["genre"]) + # If genre list has 0 genres, then return None if len(genre_list) == 0: return None else: + # Multimode returns most commonly occurring element in list return(multimode(genre_list)[0]) @@ -111,17 +121,25 @@ def get_most_watched_genre(user_data): # ----------------------------------------- def get_unique_watched(user_data): + # Get the list of watched movies from user user_watched = user_data["watched"] + # Create variable of friends watched movies friends_watched = [] + # Loop through friends for friend in user_data["friends"]: + # Adding friends watched movies to list friends_watched friends_watched += friend["watched"] + # Set variable to list of unique movies unique_movies = [] + # Iterate through movies of user's watched list for movie in user_watched: + # Conditional that movie is not in friends watched and not in unique movies lists if movie not in friends_watched and movie not in unique_movies: + # Add that movie to unique movies list unique_movies.append(movie) - + return unique_movies def get_friends_unique_watched(user_data): @@ -137,7 +155,7 @@ def get_friends_unique_watched(user_data): if movie not in watched_movies and movie not in friends_unique_watched: # If not, add the movie to the friends_unique_watched list friends_unique_watched.append(movie) - # Return the list of movies + return friends_unique_watched @@ -146,25 +164,19 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- def get_available_recs(user_data): - # List of friends - friends = user_data["friends"] - # List of movies user has watched - watched_movies = user_data["watched"] + friend_unique_watched = get_friends_unique_watched(user_data) # Create empty list of recommended movies recommendations = [] - friend_movies = [] - # Loop over friends - for friend in friends: - # List of movies watched by friend - friend_movies = friend["watched"] # Loop over movies watched by friend - for movie in friend_movies: - if movie["host"] in user_data["subscriptions"] and movie not in watched_movies and movie not in recommendations: - # If so, add to list of recommended movies - recommendations.append(movie) - # Return list of recommended movies + for movie in friend_unique_watched: + # Conditional if host is in subscriptions and in friends watched and movie not in recommendations list + if movie["host"] in user_data["subscriptions"] and movie in friend_unique_watched and movie not in recommendations: + # If so, add to list of recommended movies + recommendations.append(movie) + return recommendations + # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- @@ -186,21 +198,28 @@ def get_new_rec_by_genre(user_data): # Loop over movies watched by friend for movie in friend_movies: # Conditional if movie is favorite genre/user has not watched - if movie["genre"] == genre and movie not in watched_movies and movie not in recommended_movies: + if (movie["genre"] == genre) and (movie not in watched_movies) and (movie not in recommended_movies): # If so, add to list of recommended movies recommended_movies.append(movie) - # Return list of recommended movies + return recommended_movies def get_rec_from_favorites(user_data): + + # Set favorites to user's favorite movies favorites = user_data["favorites"] + # Set unique watched variable to unique watched movies from function call unique_watched = get_unique_watched(user_data) + # Set variable to an empty list reccomendation_list = [] + # Iterate through favorite movies for movie in favorites: + # Conditional if movie is in the unique watched list if movie in unique_watched: + # Add movie to the recommendation list reccomendation_list.append(movie) - + return reccomendation_list \ No newline at end of file From 57ae7e2afd085c6c9a9fc7bbbecc3715a3ff09f6 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Thu, 30 Mar 2023 14:14:52 -0700 Subject: [PATCH 34/40] edited notes --- viewing_party/party.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 4ea6f001c..5b8b8b19d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -125,14 +125,14 @@ def get_unique_watched(user_data): user_watched = user_data["watched"] # Create variable of friends watched movies friends_watched = [] + # Set variable to list of unique movies + unique_movies = [] # Loop through friends for friend in user_data["friends"]: # Adding friends watched movies to list friends_watched friends_watched += friend["watched"] - # Set variable to list of unique movies - unique_movies = [] # Iterate through movies of user's watched list for movie in user_watched: # Conditional that movie is not in friends watched and not in unique movies lists @@ -170,7 +170,7 @@ def get_available_recs(user_data): # Loop over movies watched by friend for movie in friend_unique_watched: # Conditional if host is in subscriptions and in friends watched and movie not in recommendations list - if movie["host"] in user_data["subscriptions"] and movie in friend_unique_watched and movie not in recommendations: + if (movie["host"] in user_data["subscriptions"]) and (movie in friend_unique_watched) and (movie not in recommendations): # If so, add to list of recommended movies recommendations.append(movie) @@ -202,7 +202,6 @@ def get_new_rec_by_genre(user_data): # If so, add to list of recommended movies recommended_movies.append(movie) - return recommended_movies From 77ba054c5cdfc58041ddfc921c21287d3cfed3e8 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 14:23:11 -0700 Subject: [PATCH 35/40] doing .get --- viewing_party/party.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5b8b8b19d..adc1650d8 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -54,7 +54,8 @@ def get_watched_avg_rating(user_data): # Iterate through movies in list of movies for movie in movie_list: # Find the sum of the integers in value for "rating" in the movie dict - sum_rating += movie["rating"] + #sum_rating += movie["rating"] + sum_rating += movie.get("rating") # If the input is an empty list, return 0.0 for average if len(movie_list) == 0: return 0.0 From 44d99ac863dfcd45d321ae2e8d0a22d6dc67c157 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 14:25:32 -0700 Subject: [PATCH 36/40] Never mind --- viewing_party/party.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index adc1650d8..5b8b8b19d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -54,8 +54,7 @@ def get_watched_avg_rating(user_data): # Iterate through movies in list of movies for movie in movie_list: # Find the sum of the integers in value for "rating" in the movie dict - #sum_rating += movie["rating"] - sum_rating += movie.get("rating") + sum_rating += movie["rating"] # If the input is an empty list, return 0.0 for average if len(movie_list) == 0: return 0.0 From 8109e1b98ac2a9bc845b795993b89559940edb56 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 14:43:54 -0700 Subject: [PATCH 37/40] Revert "Never mind" This reverts commit 44d99ac863dfcd45d321ae2e8d0a22d6dc67c157. --- viewing_party/party.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5b8b8b19d..adc1650d8 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -54,7 +54,8 @@ def get_watched_avg_rating(user_data): # Iterate through movies in list of movies for movie in movie_list: # Find the sum of the integers in value for "rating" in the movie dict - sum_rating += movie["rating"] + #sum_rating += movie["rating"] + sum_rating += movie.get("rating") # If the input is an empty list, return 0.0 for average if len(movie_list) == 0: return 0.0 From 682d9ac4c582a3fc9de2b08565bf25984867810a Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 14:45:40 -0700 Subject: [PATCH 38/40] Revert "doing .get" This reverts commit 77ba054c5cdfc58041ddfc921c21287d3cfed3e8. --- viewing_party/party.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index adc1650d8..5b8b8b19d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -54,8 +54,7 @@ def get_watched_avg_rating(user_data): # Iterate through movies in list of movies for movie in movie_list: # Find the sum of the integers in value for "rating" in the movie dict - #sum_rating += movie["rating"] - sum_rating += movie.get("rating") + sum_rating += movie["rating"] # If the input is an empty list, return 0.0 for average if len(movie_list) == 0: return 0.0 From c15cde3cbc9fea93d7a469e0d907fc6e6b33fcc5 Mon Sep 17 00:00:00 2001 From: Melinda Mott Date: Thu, 30 Mar 2023 15:29:54 -0700 Subject: [PATCH 39/40] Did doc strings! --- viewing_party/party.py | 112 ++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5b8b8b19d..9ec0fab29 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -46,38 +46,47 @@ def watch_movie(user_data, title): # ----------------------------------------- def get_watched_avg_rating(user_data): - # Set initial value of sum_rating to 0 + """Set initial value of sum_rating to 0. + Create a new list of "watched" movies in user_data dict. + Iterate through movies in list of movies + Iterate through movies in list of movies + Find the sum of the integers in value for "rating" in the movie dict + If the input is an empty list, return 0.0 for average + Return the sum of movie ratings divided by the number of movies in input user_data dict + """ + sum_rating = 0 - # Create a new list of "watched" movies in user_data dict + movie_list = user_data["watched"] - # Iterate through movies in list of movies for movie in movie_list: - # Find the sum of the integers in value for "rating" in the movie dict sum_rating += movie["rating"] - # If the input is an empty list, return 0.0 for average if len(movie_list) == 0: return 0.0 else: - # Return the sum of movie ratings divided by the number of movies in input user_data dict return sum_rating / len(movie_list) def get_most_watched_genre(user_data): - # Create variable that is a list + """ + Create variable that is a list + Set variable to user's watched list + Loop through movies in user's watched list + Add movie genre to genre list + If genre list has 0 genres, then return None + Multimode returns most commonly occurring element in list + + """ genre_list = [] - # Set variable to user's watched list movie_list = user_data["watched"] - # Loop through movies in user's watched list + for movie in movie_list: - # Add movie genre to genre list genre_list.append(movie["genre"]) - # If genre list has 0 genres, then return None + if len(genre_list) == 0: return None else: - # Multimode returns most commonly occurring element in list return(multimode(genre_list)[0]) @@ -121,39 +130,44 @@ def get_most_watched_genre(user_data): # ----------------------------------------- def get_unique_watched(user_data): - # Get the list of watched movies from user + """ + Get the list of watched movies from user + Create variable of friends watched movies + Set variable to list of unique movies + Loop through friends + Adding friends watched movies to list friends_watched + Iterate through movies of user's watched list + Conditional that movie is not in friends watched and not in unique movies lists + Add that movie to unique movies list + """ user_watched = user_data["watched"] - # Create variable of friends watched movies friends_watched = [] - # Set variable to list of unique movies unique_movies = [] - # Loop through friends for friend in user_data["friends"]: - # Adding friends watched movies to list friends_watched friends_watched += friend["watched"] - # Iterate through movies of user's watched list for movie in user_watched: - # Conditional that movie is not in friends watched and not in unique movies lists if movie not in friends_watched and movie not in unique_movies: - # Add that movie to unique movies list unique_movies.append(movie) return unique_movies def get_friends_unique_watched(user_data): - # Get the list of watched movies from the user + """ + Get the list of watched movies from the user + Set up an empty list to store movies that the user's friends have watched + Iterate through each friend in the user's list of friends + Iterate through each movie that the friend has watched + Check if the user has watched the movie + If not, add the movie to the friends_unique_watched list + """ watched_movies = user_data["watched"] - # Set up an empty list to store movies that the user's friends have watched friends_unique_watched = [] - # Iterate through each friend in the user's list of friends + for friend in user_data["friends"]: - # Iterate through each movie that the friend has watched for movie in friend["watched"]: - # Check if the user has watched the movie if movie not in watched_movies and movie not in friends_unique_watched: - # If not, add the movie to the friends_unique_watched list friends_unique_watched.append(movie) return friends_unique_watched @@ -164,14 +178,16 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- def get_available_recs(user_data): + """ + Create empty list of recommended movies + Loop over movies watched by friend + Conditional if host is in subscriptions and in friends watched and movie not in recommendations list + If so, add to list of recommended movies + """ friend_unique_watched = get_friends_unique_watched(user_data) - # Create empty list of recommended movies recommendations = [] - # Loop over movies watched by friend for movie in friend_unique_watched: - # Conditional if host is in subscriptions and in friends watched and movie not in recommendations list if (movie["host"] in user_data["subscriptions"]) and (movie in friend_unique_watched) and (movie not in recommendations): - # If so, add to list of recommended movies recommendations.append(movie) return recommendations @@ -182,43 +198,47 @@ def get_available_recs(user_data): # ----------------------------------------- def get_new_rec_by_genre(user_data): - # Get most frequent genre + """ + Get most frequent genre + List of friends + List of movies user has watched + Create empty list of recommended movies + Loop over friends + List of movies watched by friend + Loop over movies watched by friend + Conditional if movie is favorite genre/user has not watched + If so, add to list of recommended movies + """ genre = get_most_watched_genre(user_data) - # List of friends friends = user_data["friends"] - # List of movies user has watched watched_movies = user_data["watched"] - # Create empty list of recommended movies recommended_movies = [] - # Loop over friends + for friend in friends: - # List of movies watched by friend friend_movies = friend["watched"] - # Loop over movies watched by friend for movie in friend_movies: - # Conditional if movie is favorite genre/user has not watched if (movie["genre"] == genre) and (movie not in watched_movies) and (movie not in recommended_movies): - # If so, add to list of recommended movies recommended_movies.append(movie) return recommended_movies def get_rec_from_favorites(user_data): - - # Set favorites to user's favorite movies + """ + Set favorites to user's favorite movies + Set unique watched variable to unique watched movies from function call + Set variable to an empty list + Iterate through favorite movies + Conditional if movie is in the unique watched list + Add movie to the recommendation list + """ favorites = user_data["favorites"] - # Set unique watched variable to unique watched movies from function call unique_watched = get_unique_watched(user_data) - # Set variable to an empty list reccomendation_list = [] - # Iterate through favorite movies for movie in favorites: - # Conditional if movie is in the unique watched list if movie in unique_watched: - # Add movie to the recommendation list reccomendation_list.append(movie) return reccomendation_list \ No newline at end of file From 929910a257464e4e44bd35f8235dd60aa3f60375 Mon Sep 17 00:00:00 2001 From: Jennifer Tam Date: Thu, 30 Mar 2023 16:05:05 -0700 Subject: [PATCH 40/40] edited docstrings --- viewing_party/party.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 9ec0fab29..49adb3f87 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,12 +1,13 @@ from statistics import multimode,mode # ------------- WAVE 1 -------------------- -# Create function to store movie def create_movie(title, genre, rating): - # Create empty dictionary to store the movie - movie = { "title": "", "genre" : "", "rating" : 0} + """Create function to store movie + Create empty dictionary to store the movie + Check for edge case of one item being none + """ - # Check for edge case of one item being none + movie = { "title": "", "genre" : "", "rating" : 0} if title is None or genre is None or rating is None: return None else: @@ -29,13 +30,15 @@ def add_to_watchlist(user_data, movie): return user_data def watch_movie(user_data, title): - - # Iterate through movies in user watchlist + """ + Iterate through movies in user watchlist + Conditional if title is in user movie in watched + Then remove the watched movie from watchlist + """ + for movie in user_data["watchlist"]: - # Conditional if title is in user movie in watched if title in movie["title"]: add_to_watched(user_data, movie) - # Then remove the watched movie from watchlist user_data["watchlist"].remove(movie) return user_data @@ -140,6 +143,7 @@ def get_unique_watched(user_data): Conditional that movie is not in friends watched and not in unique movies lists Add that movie to unique movies list """ + user_watched = user_data["watched"] friends_watched = [] unique_movies = [] @@ -162,6 +166,7 @@ def get_friends_unique_watched(user_data): Check if the user has watched the movie If not, add the movie to the friends_unique_watched list """ + watched_movies = user_data["watched"] friends_unique_watched = [] @@ -184,6 +189,7 @@ def get_available_recs(user_data): Conditional if host is in subscriptions and in friends watched and movie not in recommendations list If so, add to list of recommended movies """ + friend_unique_watched = get_friends_unique_watched(user_data) recommendations = [] for movie in friend_unique_watched: @@ -209,6 +215,7 @@ def get_new_rec_by_genre(user_data): Conditional if movie is favorite genre/user has not watched If so, add to list of recommended movies """ + genre = get_most_watched_genre(user_data) friends = user_data["friends"] watched_movies = user_data["watched"] @@ -233,6 +240,7 @@ def get_rec_from_favorites(user_data): Conditional if movie is in the unique watched list Add movie to the recommendation list """ + favorites = user_data["favorites"] unique_watched = get_unique_watched(user_data) reccomendation_list = []