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
version: 0.1 | |
phases: | |
install: | |
commands: | |
- pip install --upgrade pip | |
- pip install -r requirements.txt | |
pre_build: | |
commands: | |
- echo Pre-build phase... |
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
#Parse a log and yield ONLY one line | |
def parse_log(path): | |
with open("logfile.txt") as myfile: | |
res = myfile.readlines() | |
for line in res: | |
yield line | |
#generator pipeline | |
stream = parse_log("logfile.txt") # step 1 | |
split_it = (line.split() for line in stream) #step 2 |
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
pylint --disable=W0622,W0611,F0401,R0914,W0221,W0222,W0142,F0010,W0703,R0911 -f parseable heroku | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
(.myrepo) ➜ myrepo git:(master) ✗ make lint | |
pylint --disable=R,C myrepolib cli web | |
No config file found, using default configuration | |
-------------------------------------------------------------------- | |
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00) |
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
(.myrepo) ➜ myrepo git:(master) ✗ make test | |
python -m pytest -vv --cov=myrepolib tests/*.py | |
============================================================ test session starts ============================================================ | |
platform darwin -- Python 3.6.4, pytest-3.3.0, py-1.5.2, pluggy-0.6.0 -- /Users/noahgift/.myrepo/bin/python | |
cachedir: .cache | |
rootdir: /Users/noahgift/src/myrepo, inifile: | |
plugins: cov-2.5.1, nbval-0.7 | |
collected 1 item | |
tests/test_myrepo.py::test_func PASSED [100%] |
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
for i in range(1,10): | |
print(f"I like sharing python code this way up to {i} times") | |
print(f"Ok, tired now") |
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
#Python quick and dirty debugging | |
#1. PDB or IPDB | |
#this is the most powerful debugging technique | |
#Can also use ipdb: https://pypi.org/project/ipdb/ | |
def stuff(): | |
#import pdb;pdb.set_trace() | |
x = 1 | |
y = 2 |
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
In [107]: from sklearn.linear_model import LogisticRegressionCV | |
In [108]: model_cv = LogisticRegressionCV(10) | |
In [109]: model_cv.fit(X_train, y_train) | |
Out[109]: LogisticRegressionCV(Cs=10, class_weight=None, cv=None, dual=False, fit_intercept=True, intercept_scaling=1.0, max_iter=100, multi_class='ovr', n_jobs=1, penalty='l2', random_state=None, refit=True, scoring=None, solver='lbfgs', tol=0.0001, verbose=0) |