Skip to content

Ocelots - Larissa A.#18

Open
ctlaultdel wants to merge 10 commits into
ada-ac2:masterfrom
ctlaultdel:master
Open

Ocelots - Larissa A.#18
ctlaultdel wants to merge 10 commits into
ada-ac2:masterfrom
ctlaultdel:master

Conversation

@ctlaultdel

Copy link
Copy Markdown

No description provided.

Comment thread viewing_party/party.py

def create_movie(title, genre, rating):
pass
def create_movie(title=None, genre=None, rating=None):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really excellent use of comments to describe your functions!

Comment thread tests/test_wave_01.py
# *******************************************************************************************

@pytest.mark.skip()
# Added assertions to test if correct movie was added to "watched"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good addition of the test. And for completeness, we could test the other attributes as well ("genre", "rating")

Comment thread viewing_party/party.py
# create dictionary with movie details
new_movie = {}
keys = ["title", "genre", "rating"]
for key, det in zip(keys, dets):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of zip!

Comment thread viewing_party/party.py
for key, det in zip(keys, dets):
new_movie[key] = det
# handle missing movie details
if any(x == None for x in dets):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nice concise use of any() and this list checking syntax!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could this check have occurred earlier in the function, in order to be more efficient and skip unused code?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, good check for None; other cases to validate could include a blank string, ""

Comment thread viewing_party/party.py
# copy user data
updated_data = janes_data.copy()
# iterate through watchlist movies
for movie in updated_data['watchlist']:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This code passes the tests, but as an aside it contains an "anti-pattern" that is important to be aware of. An element of the list that is being iterated over is being removed inside the for loop. This is generally considered bad practice and can leave you open to problems in more complex code. One solution could be to copy the data you get from "movie in updated_data['watchlist']" into a variable that's not going to change as you modify updated_data.

Comment thread viewing_party/party.py
ratings = []
for movie in janes_data['watched']:
ratings.append(movie['rating'])
if len(ratings) == 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.

good avoidance of div by zero

Comment thread viewing_party/party.py
if len(genres) == 0:
return None
# collect highest frequency movie genre
popular_genre = statistics.mode(genres)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of an established specialized library function

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


def get_unique_watched(amandas_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.

Good solution! Can you think of how sets might be used for an even simpler implementation? Though, I do think it's useful to have gone through the foundations and understanding what might be going on behind the scenes with sets.

Comment thread viewing_party/party.py
return amandas_unique_movies


def get_friends_unique_watched(amandas_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.

Again, sets might help :)

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