This file contains hidden or 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
from cvxopt import matrix, sparse, spmatrix | |
import cvxopt.lapack | |
import picos | |
class MarkovChain(): | |
def __init__(self, columns, target): | |
n = len(target) | |
l = len(columns) |
This file contains hidden or 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
from sys import argv | |
def fast(): | |
from numpy.random import uniform | |
return uniform(0.0, 1.0, 1000000) | |
def slow(): | |
from random import uniform |
This file contains hidden or 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
"""Allow {}-style logging on python 2 and 3 | |
Provide everything the "logging" module does, the only difference is that when | |
getLogger(name) instantiates a logger that logger uses {}-style formatting. | |
It can be named logging if it is inside a package (e.g. foo.logging), otherwise | |
name it any way you like. | |
It requires special hacks for python 2.6 due to logging.Logger being an old- | |
style class and having no loggerClass attribute. |
This file contains hidden or 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
import csv | |
from collections import Counter | |
from operator import itemgetter | |
from matplotlib import rcParams | |
import matplotlib.pyplot as plt | |
rcParams.update({'figure.autolayout': True}) | |
answers_2013 = {"written_python2": (4660, 119), |
This file contains hidden or 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
import ctypes | |
import ctypes.util | |
class GioURI(object): | |
"""Use gio URI function g_file_get_uri. Paths must be utf-8 encoded. | |
""" | |
name = "GIO" | |
def __init__(self): |
This file contains hidden or 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
#!/usr/bin/env python3 | |
from collections import defaultdict | |
import random | |
FINAL_STATE = 'FINAL_STATE' | |
FINAL_STATE_SPACED = ' {} '.format(FINAL_STATE) | |
def get_corpus(): |