Skip to content
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

Tigers - Lindsey B. #156

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Viewing Party
# Viewing Party Lindsey Butler Tigers

## Skills Assessed

Expand Down
6 changes: 1 addition & 5 deletions tests/test_wave_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()
def test_create_successful_movie():
# Arrange
movie_title = MOVIE_TITLE_1
Expand All @@ -19,7 +18,6 @@ def test_create_successful_movie():
assert new_movie["genre"] == GENRE_1
assert new_movie["rating"] == pytest.approx(RATING_1)

@pytest.mark.skip()
def test_create_no_title_movie():
# Arrange
movie_title = None
Expand All @@ -32,7 +30,6 @@ def test_create_no_title_movie():
# Assert
assert new_movie is None

@pytest.mark.skip()
def test_create_no_genre_movie():
# Arrange
movie_title = "Title A"
Expand All @@ -45,7 +42,6 @@ def test_create_no_genre_movie():
# Assert
assert new_movie is None

@pytest.mark.skip()
def test_create_no_rating_movie():
# Arrange
movie_title = "Title A"
Expand All @@ -57,7 +53,7 @@ def test_create_no_rating_movie():

# Assert
assert new_movie is None

@pytest.mark.skip()
chimerror marked this conversation as resolved.
Show resolved Hide resolved
def test_adds_movie_to_user_watched():
# Arrange
Expand Down
7 changes: 3 additions & 4 deletions tests/test_wave_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()

def test_calculates_watched_average_rating():
# Arrange
janes_data = clean_wave_2_data()
Expand All @@ -14,7 +14,6 @@ def test_calculates_watched_average_rating():
assert average == pytest.approx(3.58333)
assert janes_data == clean_wave_2_data()

@pytest.mark.skip()
def test_empty_watched_average_rating_is_zero():
# Arrange
janes_data = {
Expand All @@ -27,7 +26,7 @@ def test_empty_watched_average_rating_is_zero():
# Assert
assert average == pytest.approx(0.0)

@pytest.mark.skip()

def test_most_watched_genre():
# Arrange
janes_data = clean_wave_2_data()
Expand All @@ -38,7 +37,7 @@ def test_most_watched_genre():
# Assert
assert popular_genre == "Fantasy"
assert janes_data == clean_wave_2_data()

@pytest.mark.skip()
def test_genre_is_None_if_empty_watched():
# Arrange
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wave_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from viewing_party.party import *
from tests.test_constants import *

@pytest.mark.skip()

def test_my_unique_movies():
# Arrange
amandas_data = clean_wave_3_data()
Expand Down
133 changes: 131 additions & 2 deletions viewing_party/party.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,152 @@
# ------------- WAVE 1 --------------------

#from tkinter.tix import InputOnly

Choose a reason for hiding this comment

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

Looks like an import statement that ended up not being used. Just a small style thing, it's usually worth removing these before submission to keep the code clean.

Choose a reason for hiding this comment

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

Still here after resubmission, but not really something major, so it's fine.


def create_movie(title, genre, rating):
pass

# -----------------------------------------
new_movie = {}

Choose a reason for hiding this comment

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

Minor style thing about where you declare variables. Since we only use this new_movie variable in the if title and genre and rating block, we can move its declaration there. In this case it only saves the very minor memory allocation of an empty dictionary, but that's still worth keeping in mind.

In general, I look to delay my variable declarations to the last possible moment, which both avoids unnecessary allocations if the function exits early, and tends to make the variable declaration be as close as possible to where it is used, which means less scrolling if you need to check the declaration to understand what's happening later on.

if title and genre and rating:
new_movie["title"] = title
new_movie["genre"]= genre
new_movie["rating"]= rating
return new_movie
else:
return None

def add_to_watched(user_data, movie):
watched_movies = []

user_data.append(movie)
chimerror marked this conversation as resolved.
Show resolved Hide resolved

return user_data

def add_to_watched_list(user_data, movie):
chimerror marked this conversation as resolved.
Show resolved Hide resolved
watchlist = []

Choose a reason for hiding this comment

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

Nanoscopic style nitpick: Watch out for unneeded blank lines. Sometimes multiple blank lines are used as a style method for better separating, say functions, but that doesn't seem to be the case here.

Choose a reason for hiding this comment

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

Obviously not going to point out every instance of this.

user_data.append(movie)
chimerror marked this conversation as resolved.
Show resolved Hide resolved

return user_data

def watch_movie(user_data, title):

for items in user_data["watchlist"]:
if title in user_data["watchlist"]:
user_data["watched"].append(user_data["watchlist"][0])
user_data["watchlist"].pop(0)
return user_data
chimerror marked this conversation as resolved.
Show resolved Hide resolved

# def add_to_watched(user_data, movie):
chimerror marked this conversation as resolved.
Show resolved Hide resolved
# movies_watched = []
# updated_data = []

# for items in len(user_data)["movie"]:
# if movie not in user_data:
# user_data["watched"].append(updated_data[movies_watched])
# return updated_data





# make a dictionary with these keys above
#title:title, genre:genre, rating:rating

Choose a reason for hiding this comment

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

Probably don't need to keep these comments around, I guess they were scaffolding comments, and once done with them, you can remove them.


#-----------------------------------------
# ------------- WAVE 2 --------------------
# -----------------------------------------


#THIS TEST PASSED AND THEN STOPPED PASSING_ I"M NOT SURE WHY< BUT I DID NOT HAVE TIME TO FIX IT
def get_watched_avg_rating(user_data):
ratings = []
ratings_sum = 0
if(len(user_data["watched"])) is 0:
chimerror marked this conversation as resolved.
Show resolved Hide resolved
ratings_average = 0.0
else:
for i in range(len(user_data["watched"])):
chimerror marked this conversation as resolved.
Show resolved Hide resolved
ratings.append((user_data["watched"][i]["rating"]))
i+=1
chimerror marked this conversation as resolved.
Show resolved Hide resolved
for rating in ratings:
ratings_sum += rating
chimerror marked this conversation as resolved.
Show resolved Hide resolved
ratings_average = ratings_sum / len(ratings)
return ratings_average

def get_watched_avg_rating(user_data):
ratings = []
ratings_sum = 0
if(len(user_data["watched"])) is 0:
ratings_average = 0.0
return ratings_average
chimerror marked this conversation as resolved.
Show resolved Hide resolved

def get_most_watched_genre(user_data):
genre_list = []
genre_dictionary = {}

if (len(user_data["watched"])) is 0:
popular_genre = None
else:
for i in range(len(user_data["watched"])):
genre_list.append((user_data["watched"][i] ["genre"]))
i+=1

Choose a reason for hiding this comment

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

Like the increment statement above, this increment statement will throw off your loop, causing every other item to be skipped.

Choose a reason for hiding this comment

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

This still applies in the updated code, which will definitely cause a bug.


for genre in genre_list:
count = genre_list.count(genre)
genre_dictionary[genre] = count

Choose a reason for hiding this comment

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

This works, but there is a small performance hit. Even though we hadn't covered time complexity at the time you wrote this, it will be helpful to understand what's going on.

When calling genre_list.count(genre), it will be an O(n) operation because it will go through every item in genre_list to get the count. However, since we are going through every genre in genre_list in our loop, that is also going to be an O(n) operation causing the entire loop to end up O(n^2).

While count is an incredibly useful method here, we can get this loop down to O(n) by managing genre_dictionary ourselves:

for genre in genre_list:
    if genre in genre_dictionary.keys():
        genre_dictionary[genre] += 1
    else
        genre_dictionary[genre] = 1

Choose a reason for hiding this comment

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

While the updated does use genre_dictionary note that we still hit the O(n^2) performance issue that I pointed out last time due to calling genre_list.count(genre) during each iteration of for genre in genre_list. But it's progress, so it's not too concerning.


popular_genre = max(genre_dictionary, key=genre_dictionary.get)
return(popular_genre)


# -----------------------------------------
# ------------- WAVE 3 --------------------
# -----------------------------------------


def get_unique_watched(user_data):


watched = user_data["watched"]
friends = user_data["friends"]
unique_movies = []
# movies_user_watched = watched(user_data)
# movies_friend_watched = friends(user_data)


watched.set(watched)
friends.set(friends)

for movie in watched:
if movie == (movie["title"], movie["genre"]):
chimerror marked this conversation as resolved.
Show resolved Hide resolved
unique_movies.append(movie)

return unique_movies

def get_unique_friends_watched(user_data):
friends_unique_movies = []

friends_unique_movies




# -----------------------------------------
# ------------- WAVE 4 --------------------
# -----------------------------------------

def get_available_recs(user_data):
chimerror marked this conversation as resolved.
Show resolved Hide resolved



# -----------------------------------------
# ------------- WAVE 5 --------------------
# -----------------------------------------


def get_new_rec_by_genre(user_data):





def get_rec_from_favorites(user_data):