Skip to content

Instantly share code, notes, and snippets.

View jcrist's full-sized avatar

Jim Crist-Harif jcrist

View GitHub Profile
@jcrist
jcrist / tdigest.c
Created December 28, 2016 00:01
Bad code generated from tdigest.pyx
This file has been truncated, but you can view the full file.
/* Generated by Cython 0.25.2 */
/* BEGIN: Cython Metadata
{
"distutils": {
"depends": [
"C:\\Users\\builder\\Miniconda2\\envs\\crick\\lib\\site-packages\\numpy\\core\\include\\numpy\\arrayobject.h",
"C:\\Users\\builder\\Miniconda2\\envs\\crick\\lib\\site-packages\\numpy\\core\\include\\numpy\\npy_math.h",
"C:\\Users\\builder\\Miniconda2\\envs\\crick\\lib\\site-packages\\numpy\\core\\include\\numpy\\ufuncobject.h",
"crick\\tdigest_stubs.c"
@jcrist
jcrist / bench.py
Created April 26, 2017 21:37
Benchmark distributed joblib for random forests
from __future__ import division, print_function
from time import time
import numpy as np
from sklearn.datasets import fetch_covtype
from sklearn.ensemble import RandomForestClassifier, ExtraTreesClassifier
from sklearn.metrics import zero_one_loss
from sklearn.utils import check_array
@jcrist
jcrist / set_cell.py
Last active May 26, 2017 06:45
Solution to Joe Jevnik's awful puzzle
import platform
import ctypes
print("Implementation: %s" % platform.python_implementation())
def cell_set(cell, target):
offset = 2 if platform.python_implementation() == 'PyPy' else 4
def inner():
@jcrist
jcrist / bench.py
Created July 26, 2017 22:15
Benchmark Blackscholes
import argparse
from timeit import default_timer
from collections import namedtuple
import numpy as np
import dask.array as da
from dask.threaded import get
from scipy.special import erf
@jcrist
jcrist / switch.py
Created September 22, 2017 16:50
switch-case
_cache = {}
def case(x):
if x not in _cache:
_cache[x] = type("Case", (Exception,), {})
return _cache[x]
def switch(x):
import datetime
import dask
from dask.multiprocessing import get as mp_get
from dask import delayed
from lxml import etree
from multiprocessing import Pool
N = 10000
num_workers = 4
@jcrist
jcrist / github-remote-add.sh
Created April 30, 2019 21:12
Add a remote github user account for the current repo
function github-remote-add () {
case $1 in
""|--help|-h)
echo "Usage: github-remote-add USERNAME"
return 1
;;
esac
local root=`git rev-parse --show-toplevel`;
if [ $? -ne 0 ]; then
echo "Not in a git directory"
@jcrist
jcrist / Dockerfile
Last active May 6, 2019 17:29
Hadoop Pseudodistributed Skein debugging
FROM ubuntu:xenial
RUN apt-get update && \
apt-get install -y -q curl bzip2 git && \
rm -rf /var/lib/apt/lists/*
# Install CDH5 in a single node: Pseudo Distributed
# Docs: https://www.cloudera.com/documentation/enterprise/5-6-x/topics/cdh_qs_yarn_pseudo.html
ADD cloudera.pref /etc/apt/preferences.d/cloudera.pref
RUN curl -s https://archive.cloudera.com/cdh5/ubuntu/xenial/amd64/cdh/archive.key | apt-key add - && \
@jcrist
jcrist / matmul.ipynb
Created August 16, 2019 15:39
Benchmarking matmul implementations on small matrices
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / fresnel.py
Created April 3, 2020 00:08
Overload fresnel
import ctypes
import numpy as np
from numba.extending import get_cython_function_address, overload, intrinsic
from numba.errors import TypingError
from numba import cgutils, types
import scipy.special