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
from numpy import * | |
from scipy import optimize | |
def n_gaussians(parameters): | |
""" | |
Returns a summed gaussian function with the given parameters, | |
so parameters is a list with repeated motif [height, center_x, center_y, a, b, c] | |
for each gaussian. So, two gaussians would be defined by a length-12 list. | |
Guided by: http://code.google.com/p/agpy/source/browse/trunk/agpy/gaussfitter.py |
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
class RepeatingTimer(object): | |
""" | |
USAGE: | |
from time import sleep | |
def myFunction(inputArgument): | |
print(inputArgument) | |
r = RepeatingTimer(0.5, myFunction, "hello") | |
r.start(); sleep(2); r.interval = 0.05; sleep(2); r.stop() | |
""" |
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
class Kalman: | |
""" | |
USAGE: | |
# e.g., tracking an (x,y) point over time | |
k = Kalman(state_dim = 6, obs_dim = 2) | |
# when you get a new observation — | |
someNewPoint = np.r_[1,2] | |
k.update(someNewPoint) |
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 SimpleCV as scv | |
import scipy.ndimage as ndimage | |
radius = 5 | |
# Grab a little blobby image from the interwebs (it's a picture of a mouse, taken with the Microsoft Kinect) | |
scv_img = scv.Image("http://i.imgur.com/mGg0V.png") | |
# Grab a grayscale layer of the image | |
img = scv_img.getNumpy()[:,:,0] |
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 numpy as np | |
import cPickle as pickle | |
import joblib | |
from moseq.train import ARHMM, train_model | |
from moseq.train.util import whiten_all | |
from collections import OrderedDict | |
from syllables import analysis | |
# Load the data | |
with open("/data/efs/drugs/alldoses/dataset.pkl","r") as f: |
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
====================================================================== | |
ERROR: test_eye_complex64 (test_linalg.test_linalg) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/home/dattalab/Downloads/scikits.cuda/tests/test_linalg.py", line 21, in setUp | |
linalg.init() | |
File "/home/dattalab/Downloads/scikits.cuda/scikits/cuda/misc.py", line 136, in init | |
cublas.cublasInit() | |
File "/home/dattalab/Downloads/scikits.cuda/scikits/cuda/cublas.py", line 235, in cublasInit | |
_libcublas_ctx = cublasCreate() |
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 f(x): | |
assert x != 0, 'Do not pass zero!' | |
return x * x |
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 f(n): | |
z = [] | |
# We ask you to tell us the element dtype of the list | |
autograph.set_element_type(z, tf.int32) | |
for i in range(n): | |
z.append(i) | |
# when you're done with the list, stack it | |
# (this is just like np.stack) | |
return autograph.stack(z) |
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 f(n): | |
if n >= 0: | |
while n < 5: | |
n += 1 | |
print(n) | |
return n |
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 collatz(a): | |
counter = 0 | |
while a != 1: | |
if a % 2 == 0: | |
a = a // 2 | |
else: | |
a = 3 * a + 1 | |
counter = counter + 1 | |
return counter |
NewerOlder