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

"SHARKS Raha MR" #102

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

"SHARKS Raha MR" #102

wants to merge 9 commits into from

Conversation

Ramora6627
Copy link

No description provided.

Copy link

@audreyandoy audreyandoy left a comment

Choose a reason for hiding this comment

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

Great work Raha! You hit all the learning goals for this project and all tests are passing. You have earned a well-deserved 🟢 grade on this project 🦈✨

I added comments to your PR primarily on ways to refactor your code, improve tests, and improve the readability of your code. In the future, I'd like to see more docstrings in your functions. Docstrings are a great way of leaving notes to your future self about your approach to writing these functions.

In future projects, I'd like to see you use more for in loops when iterating through the values of a list and to use more descriptive variable names.

Feel free to refactor and improve on this project and do let me know if you want me to take another look for fun 😄

Keep up the great work! ✨

Comment on lines +121 to +122
assert updated_data["watched"][0]["title"] is MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] is GENRE_1
Copy link

@audreyandoy audreyandoy Mar 31, 2022

Choose a reason for hiding this comment

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

This is a much-needed change in our tests but our test asserts should use == instead of is.`

== checks for value equality while is checks for reference equality (if both references point to the same object in memory).

is is typically used when we check whether a value equates to None i.e. "if user_data is None".

Choose a reason for hiding this comment

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

So in this case the assert should look like:

Suggested change
assert updated_data["watched"][0]["title"] is MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] is GENRE_1
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] == GENRE_1

Comment on lines +145 to +146
assert updated_data["watched"][1]is HORROR_1
assert updated_data["watched"][0]is FANTASY_2

Choose a reason for hiding this comment

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

It's also more pythonic to have spaces between expressions, keywords, and operators:

    assert updated_data["watched"][1] == HORROR_1
    assert updated_data["watched"][0] == FANTASY_2

Comment on lines +57 to +60
assert INTRIGUE_3 in friends_unique_movies
assert HORROR_1 in friends_unique_movies
assert FANTASY_4 in friends_unique_movies
assert FANTASY_2 not in friends_unique_movies

Choose a reason for hiding this comment

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

👍

Comment on lines +55 to +59
# Act
recommendations = get_new_rec_by_genre(sonyas_data)

# Assert
assert len(recommendations) == 0

Choose a reason for hiding this comment

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

👍

Comment on lines +5 to +11
movie_table = {}

if title and genre and rating:
movie_table["title"] = title
movie_table["genre"] = genre
movie_table["rating"] = rating
return movie_table

Choose a reason for hiding this comment

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

Great work Raha! I like how you added key-value pairs by first checking for truthiness.

Another way to write this function is by using a guard clause and building the dictionary directly in the return statement. This allows your function to exit early when falsy values are passed in and reduces the amount of nested code we have, allowing the primary purpose of the function to be slightly easier to read.

def create_movie(title, genre, rating):
   if not title or not genre or not rating:
       return None
       
   return { 
           "title": title, 
           "genre": genre, 
           "rating": rating 
       }

Comment on lines +138 to +139
favorite = Counter(genre)
fave_max = max(favorite, key=favorite.get)

Choose a reason for hiding this comment

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

The Counter collection is handy but we could use get_most_watched_genre() as a helper function.

fave_max = max(favorite, key=favorite.get)
results = []

for i in range(len(list(friends_watched[0]["watched"]))):

Choose a reason for hiding this comment

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

Loop variables should also be descriptive names. i is too generic. Having descriptive names improves readability and helps us understand our code when we revisit it in months or years later.

return []
favorites = user_data["favorites"]

all = []

Choose a reason for hiding this comment

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

all can also be mistaken as the all() function. Perhaps all_movies_list or all_movies would be a good name for this scenario?

Comment on lines +158 to +160
for a in range(len(friends_watched)):
for b in range(len(friends_watched[a]["watched"])):
all.append(friends_watched[a]["watched"][b]["title"])

Choose a reason for hiding this comment

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

How might this look with a for in loop/

Comment on lines +168 to +170
c = [x for x in favorites if x not in mutual]

return c

Choose a reason for hiding this comment

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

Great list comprehension but what does c represent?

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