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
#! /usr/bin/env python | |
""" | |
Author: Jeremy M. Stober | |
Program: ERROR.PY | |
Date: Thursday, August 2 2012 | |
Description: Example of how sparse matrix operations may fail. | |
""" | |
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
Show hidden characters
{ | |
"cmd": ["bash $file"], | |
"shell": true, | |
"selector": "source.shell" | |
} |
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
def consumer(func): | |
""" | |
See: http://www.dabeaz.com/generators/ | |
""" | |
def start(*args,**kwargs): | |
c = func(*args,**kwargs) | |
c.next() | |
return c | |
return start |
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
#!/lusr/bin/python | |
""" | |
Author: Jeremy M. Stober | |
Program: PERCEPTRON.PY | |
Date: Friday, April 4 2008 | |
Description: A simple Perceptron implementation. | |
""" | |
import os, sys, getopt, pdb | |
from numpy import * |
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
#!/usr/bin/python | |
""" | |
Author: Jeremy M. Stober | |
Program: MULTILAYER.PY | |
Date: Monday, April 14 2008 | |
Description: A simple implementation of a feed-forward multilayer network with back-propagation. | |
""" | |
import os, sys, getopt, pdb | |
from numpy import * |
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
#! /usr/bin/env python | |
""" | |
Author: Jeremy M. Stober | |
Program: AXLINE.PY | |
Date: Wednesday, May 23 2012 | |
Description: Plot arbitrary lines. | |
""" | |
import pylab |
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
import heapq as hq | |
import itertools | |
class pqueue: | |
""" | |
A priority queue with fast member checking and variable tie | |
breaking (LIFO or FIFO). Updated using the recipe from the heapq | |
documentation. | |
""" |
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
import pickle | |
def loader(fp): | |
# a load iter | |
while True: | |
try: | |
yield pickle.load(fp) | |
except EOFError: | |
raise StopIteration |
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
import cPickle as pickle | |
import bz2 | |
def load_or_compute(method, filename, recompute=False): | |
try: | |
if recompute: raise Exception | |
fp = bz2.BZ2File(filename) | |
return pickle.load(fp) | |
fp.close() |
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
import matplotlib.pyplot as plt | |
def save_show_no(plotfunc): | |
# A function decorator that adds the option to save or show a plot | |
# depending on whether a filename option is set. | |
def decorate(*args,**kwargs): | |
ax = plotfunc(*args) |