Skip to content

Viewing Party: Sea Turtles - Hillary Smith #101

Open
hillaryhsmith wants to merge 2 commits into
ada-c17:masterfrom
hillaryhsmith:master
Open

Viewing Party: Sea Turtles - Hillary Smith #101
hillaryhsmith wants to merge 2 commits into
ada-c17:masterfrom
hillaryhsmith:master

Conversation

@hillaryhsmith
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

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

Nice job!

All your tests are passing, with reasonable additions where required, and your code is nicely structured, and makes good re-use of functions from earlier waves. Nice custom helper function as well!

We'll start looking more at performance and efficiency going ahead, so I included some thoughts there as well, mostly around avoiding in on lists when we might be able to use sets which have better membership lookup performance as long as we can figure out how to represent our data in an immutable way so it can be added to the set.

Well done!

Comment thread tests/test_wave_01.py
@@ -1,10 +1,11 @@
from turtle import up
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Be careful of VSCode importing stray libraries. When we autocomplete suggestions from VSCode, sometimes we accidentally pick a recommendation to use something not in our code (usually from a typo). When that happens, VSCode might think that it needs to import a library if the suggestion refers to a library not in our code. Even if we fix the typo, the imports will remain! So keep an eye on the import statements, and make sure to remove any that don't look familiar.

Comment thread tests/test_wave_01.py
Comment on lines +123 to +125
assert updated_data["watched"][0]["title"] is MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] is GENRE_1
assert updated_data["watched"][0]["rating"] is RATING_1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread tests/test_wave_01.py
# Assert
assert len(updated_data["watchlist"]) is 1
assert len(updated_data["watched"]) is 2
assert updated_data["watched"][1] is movie_to_watch
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread tests/test_wave_03.py

# Arrange
assert len(friends_unique_movies) == 3
assert friends_unique_movies[2] is INTRIGUE_3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We should double check what the other two movies are as well (what if INTRIGUE_3 made it into the results twice)? Also, since there's no strongly specified behavior about the order of the results, doing in checks might be preferred. The test should try to avoid making promises that the function implementation might not actually keep.

Comment thread tests/test_wave_05.py
Comment on lines +55 to +59
# Act
recommendations = get_new_rec_by_genre(sonyas_data)

# Assert
assert len(recommendations) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread viewing_party/party.py
friend_watched_movies.append(movie["title"])

for film in user_data["watched"]:
if film ["title"] not in friend_watched_movies:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great observation that we can use the title as a stand-in for the entire movie. Notice that a title (string) is also immutable, meaning we could store it in a set for improved in check performance, which is why I made the earlier comments about using a set instead (which we couldn't do if we tried to store an entire movie).

Comment thread viewing_party/party.py
Comment on lines +100 to +102
if movie["title"] not in users_watched_movies\
and movie not in friends_unique_movies:
friends_unique_movies.append(movie)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Generally, prefer using implicit line wrapping, which is allowed for any expression wrapped in parentheses. Also, because of the typical indentation of the wrapped line, I often add a blank line between the condition and its block to help visually separate them.

            if (movie["title"] not in users_watched_movies
                and movie not in friends_unique_movies):

                friends_unique_movies.append(movie)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider tracking a a helper set of the titles that have been added to the output list. We could use that to perform the uniqueness check rather than the result list itself, which would have greater efficiency at the cost of building an extra data structure.

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

def get_available_recs(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Similar comments as for get_friends_unique_watched apply here as well. Look for other places in the remainder of the project that they also might be useful!

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

def get_new_rec_by_genre(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread viewing_party/party.py
Comment on lines +142 to +144
for movies in user_data["friends"]:
for movie in movies["watched"]:
friends_watched_movies.append(movie["title"])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I was a little surprised that you didn't make a helper method for this operation similar to get_users_watched_movie_titles!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants