Skip to content

Instantly share code, notes, and snippets.

View cicdw's full-sized avatar

Chris White cicdw

View GitHub Profile
@cicdw
cicdw / dask_blog_image_creation.ipynb
Created March 18, 2017 01:45
Generate blog post images
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cicdw
cicdw / single_update_async_admm.ipynb
Last active March 27, 2017 20:21
experiments and analysis of asynchronous admm with dask
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cicdw
cicdw / async_logistic.ipynb
Created March 28, 2017 23:27
Async ADMM for Logistic Regression
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cicdw
cicdw / accuracy_tests.ipynb
Created March 30, 2017 01:15
Trying to move towards better testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cicdw
cicdw / hangman_coroutine.py
Created October 17, 2017 19:17
Hangman implemented w/ a recursive coroutine
def game(word, max_guesses=10):
'''Given a word and a guess limit, returns a
coroutine for playing hangman. Guess letters
by sending messages to the coroutine. Returns
True if you win, False otherwise.
Example
>>> g = game('jazz', 10)
>>> next(g) # prime the coroutine
>>> g.send('e') # guess 'e'
@cicdw
cicdw / predict_over_time.py
Last active November 10, 2017 15:59
Code Snippets for Medium blog post
def predict_over_time(x, y, z, overlay=False):
"Predicts a quantity at times = 0, 1, ... 14"
out = np.zeros((x.shape[0], 15))
for t in range(15):
out[:, t] = t * x ** 2 + y - 2 * z - 2 * t
adj = 1.5 if overlay else 1.0
return adj * out
@cicdw
cicdw / numba_jit_example.py
Last active November 10, 2017 16:37
Code Snippets for Medium blog post
from numba import jit
@jit
def jitted_func(x, y, z, overlay=False):
"Predicts a quantity at times = 0, 1, ... 14"
out = np.zeros((x.shape[0], 15))
for t in range(15):
out[:, t] = t * x ** 2 + y - 2 * z - 2 * t
adj = 1.5 if overlay else 1.0
@cicdw
cicdw / numba_guvectorize_example.py
Created November 10, 2017 16:06
Code snippets for Medium blog post
from numba import guvectorize
@guvectorize('i8, f8, f8, b1, f8[:], f8[:]',
'(), (), (), (), (s) -> (s)')
def fast_predict_over_time(x, y, z, overlay, _, out):
adj = 1.5 if overlay else 1.0
for t in range(len(out)):
out[t] = adj * (t * x ** 2 + y - 2 * z - 2 * t)
@cicdw
cicdw / calling_guvectorize.py
Created November 10, 2017 16:07
Code snippets for Medium blog post
res = np.zeros((n, 15))
%%timeit -n 100
_ = fast_predict_over_time(x, y, z, False, res) # 100 loops, best of 3: 575 µs per loop