Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import matplotlib.pyplot as pl
from matplotlib import cm
from matplotlib.colors import Normalize
from matplotlib.widgets import Slider
def rescale(xs, ys, params, values):
"""
An example scaling_func that can be provided to interactive_collapse. This
scales the zombie data by the variables alphac, sigma, tau for curves at
import numpy as np
import matplotlib.pylab as pl
class Encirculator(object):
def __init__(self, image, cmap='bone', size=14, max_number_circles=100):
"""
A class which builds a matplotlib interface to facilitate the drawing
of circles on an image (typically to measure the sizes and positions of
objects). To create the circles, you label the edges with points via
mouse clicks, and a fitted circle is drawn over the image to guide
import os
import uuid
from celery import signals
from celery import Celery, Task
from celery.utils.log import get_task_logger
app = Celery('simple_celery')
logger = get_task_logger(__name__)
class Worker(object):
import pylab as pl
import numpy as np
from matplotlib.colors import Normalize
from matplotlib.collections import LineCollection
def plot_colored_curve(x, y, t=None, linewidth=2, drawpoints=False, cmap=pl.cm.copper):
"""
Plot a curve that is colored based on index or 'time' value at each point
in that curve. [x,y,t] are the values y(x, t) which will be plotted. They
import sys
import time
import numpy as np
#=============================================================================
# Progress bar
#=============================================================================
class ProgressBar(object):
def __init__(self, num, label='Progress', value=0, screen=79,
time_remaining=True, bar=True, bar_symbol='=', bar_caps='[]',
@mattbierbaum
mattbierbaum / Makefile
Created September 4, 2011 19:44
SWIG with C++ class example
# standard compile options for the c++ executable
FLAGS = -fPIC
# the python interface through swig
PYTHONI = -I/usr/include/python2.6/
PYTHONL = -Xlinker -export-dynamic
# default super-target
all:
g++ -fPIC -c kitty.cc -o kitty.o
@mattbierbaum
mattbierbaum / setup.py
Created September 2, 2011 20:39
Simple SWIG/numpy example
from distutils.core import setup, Extension
import numpy
import os
os.environ['CC'] = 'g++';
setup(name='matt_simple_test', version='1.0', ext_modules =[Extension('_simple',
['simple.cc', 'simple.i'], include_dirs = [numpy.get_include(),'.'])])