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

nfl.schedule.Game.result return win/loss/tie/unknown correctly #246

Merged
merged 5 commits into from
Nov 18, 2019
Merged

nfl.schedule.Game.result return win/loss/tie/unknown correctly #246

merged 5 commits into from
Nov 18, 2019

Conversation

DavidLiuGit
Copy link
Contributor

  1. Add a constant TIE to represent NFL games that can end in a tie, at the end of overtime.
  2. in schedule.Game.result, consider all possible outcomes of an NFL game, instead of returning WIN indiscriminately if the if-statement does not evaluate to true. Check whether the result is l/w/t and return the corresponding constant. If none of the above match, return None

closes #245

@roclark roclark self-requested a review November 13, 2019 01:24
@roclark roclark added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Nov 13, 2019
Copy link
Owner

@roclark roclark left a comment

Choose a reason for hiding this comment

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

This looks good to me! This is a great addition, and is very nicely implemented. One item I noticed is that the checks I created weren't run on this PR. This should be something on my end that I need to fix as I believe they trigger only on a branch push to the repository, but not on a PR create. Since this branch is in your personal fork, the checks weren't triggered as the repo only sees a PR creation. This is something I need to fix on my end and I would like to merge it prior to this update so the checks are properly run. Is that fair?

Also, one thing we might run into with the checks is a drop in testing coverage. I don't believe my current testing suite covers ties or games that haven't been played yet, so it would be good to test those scenarios too. Would you be able to add some unit tests to cover these scenarios? Let me know if you would like any help.

Thanks again for creating this! Once I fix the checks and the other items I mentioned get knocked out, I will be happy to merge this! 😃

@@ -282,11 +283,19 @@ def datetime(self):
def result(self):
"""
Returns a ``string`` constant indicating whether the team won or lost
the game.
the game.
NFL games may end in a tie if the score is even at the end of OT.
Copy link
Owner

Choose a reason for hiding this comment

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

This is a bit of a nit-pick, but would it be possible to wrap this text with the previous line? So, something like:

"""
Returns a ``string`` constant …
the game. NFL games may end in a …
"""

I've had issues in the past with the auto-documentation with a singular newline like this, and found it's easiest to just wrap together for another sentence. Let me know if you have any issues with this though! Also, looks like this sentence could use a period after the end after None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, didn't know about the auto-doc issue. I will update this

@roclark roclark added this to the Release 0.4.7 milestone Nov 13, 2019
@roclark roclark added bug Something isn't working and removed bug Something isn't working labels Nov 13, 2019
@DavidLiuGit
Copy link
Contributor Author

I'll have a look at the unit tests and add the new cases this weekend. Although I foresee a potential issue writing tests for unplayed games, since those games will eventually get played. Do you have any advice?

@roclark
Copy link
Owner

roclark commented Nov 14, 2019

Hey @DavidLiuGit, great point! I ran into this issue when I first devised the testing suite, also knowing that certain aspects like career stats will change as well. To get around this, I replace a call to a live page on sports-reference.com with a call to read a copy of a HTML page stored in the tests directory for each component. That way, regardless of what day it is, or what games have been played, the tests will always be run against the same data. Of course, there are some flaws with this as it doesn't always catch any changes that happen on the website, but I've been working on a secondary testing suite which runs tests against live data. I won't be able to test the actual values against known results with this secondary suite, but it will at least let me know if the algorithms will successfully run.

On a more relevant note for this update, these tests would likely live in the TestNFLSchedule unit test module. You can find an example for the wins and losses here. I would recommend copying the template of these two functions, and add one function for a tie, and one for if the result is empty.

Again, let me know if you have any questions or concerns with this and I will be happy to help! With your other PR merged, the testing suite should now run automatically on an update.

Thanks again!

@DavidLiuGit
Copy link
Contributor Author

I added unit tests for tied games and games with no results, and updated the function description. Let me know if there's any other changes needed!

@roclark
Copy link
Owner

roclark commented Nov 18, 2019

Hey @DavidLiuGit, this looks good to me! The tests are passing and the new code you added is being covered by the unit tests you created, so I'm happy with this! Let me know if you are planning on any further updates, otherwise I will accept this!

@DavidLiuGit
Copy link
Contributor Author

I'm all done with this

@roclark roclark merged commit 3ee7803 into roclark:master Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants