-
Notifications
You must be signed in to change notification settings - Fork 16
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
Python 3 + 2 fixes #10
Open
mscuthbert
wants to merge
3
commits into
TheUpshot:master
Choose a base branch
from
mscuthbert:py3fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
*.py[cod] | ||
__pycache__/ | ||
__pycache__ | ||
|
||
# OSX | ||
.DS_Store | ||
|
||
# Eclipse | ||
.project | ||
.pydevproject | ||
/.settings | ||
|
||
# Do not commit data files | ||
/data/*.csv | ||
/models/*.pkl | ||
/models/*.npy | ||
|
||
# generally do not commit node_modules (controversial...) | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ The Armchair Analysis data is *not free*. It costs $49 (one-time) to gain access | |
data from the 2000-2014 NFL seasons. There is also a professional package that will provide | ||
weekly updates. Without the Armchair Analysis data, you will not be able to use much of this code. | ||
|
||
This code currently requires Python 2.7 and is not Python 3 compliant to our knowledge. Questions about the Python code can be directed to [Trey Causey](mailto:[email protected]). | ||
This code currently requires Python 2.7 and or Python 3.4+. | ||
Questions about the Python code can be directed to [Trey Causey](mailto:[email protected]). | ||
|
||
Please note that none of the file operations are supported on Windows. | ||
|
||
|
@@ -27,6 +28,10 @@ NOTE: If you are unable to purchase the Armchair Analysis data, [Ben Dilday](htt | |
- pandas | ||
- scikit-learn | ||
|
||
## Node.js package requirements | ||
|
||
- underscore | ||
|
||
## Usage | ||
|
||
Unzip the play-by-play data into a directory. Run the following code from the directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,12 @@ | |
|
||
import winprob as wp | ||
|
||
try: | ||
raw_input | ||
except NameError: | ||
raw_input = input # python3 | ||
|
||
import sys | ||
|
||
def load_data(): | ||
click.echo('Loading data and setting up model.') | ||
|
@@ -27,9 +33,14 @@ def load_data(): | |
return data, model | ||
|
||
def fg_make_prob(situation): | ||
args = ' '.join("--%s=%r" % (key,val) for (key,val) in situation.iteritems()) | ||
if sys.version_info[0] >= 3: | ||
args = ' '.join("--%s=%r" % (key,val) for (key,val) in situation.items()) | ||
else: | ||
args = ' '.join("--%s=%r" % (key,val) for (key,val) in situation.iteritems()) | ||
model_fg = muterun_js('model-fg/model-fg.js', args) | ||
return model_fg.stdout.split()[-1] | ||
stdoutResults = model_fg.stdout | ||
stdoutSplit = stdoutResults.split() | ||
return stdoutSplit[-1] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry about splitting this line into three -- I separated them for debugging (in order to figure out where some Py3 incorrect behavior was coming from) and forgot to restore to one line. |
||
@click.command() | ||
def run_bot(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this useful given that these are already enumerated in
package.json
(and will be installed onnpm install
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought is that parallels the list of python requirements above (which are listed in
requirements.txt
and installed onpip install
) -- it wasn't clear to me from the code and the "This code currently requires Python 2.7" note above thatNode.js
was required to be installed in order to run -- since Python uses.json
also now and there are no.js
files in the main directory. But I could be persuaded.