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 theano.tensor as tensor | |
| from theano import function | |
| import numpy as np | |
| value = np.array([ 0.992827313923019039165751564724, | |
| 0.118152792712208978831434080803, | |
| -0.008531793400639134036800292904, | |
| 0.016157066691618496290239193058]) | |
| aa = tensor.vector('aa') | |
| bb = tensor.vector('bb') | |
| ee = tensor.scalar() |
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
| """Demo of how to pop up plots asynchronously using separate processes.""" | |
| from multiprocessing import Process | |
| import time | |
| import sys | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| def demo(): | |
| i = 0 | |
| processes = [] |
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 scipy as S | |
| def coo_submatrix_pull(matr, rows, cols): | |
| """ | |
| Pulls out an arbitrary i.e. non-contiguous submatrix out of | |
| a sparse.coo_matrix. | |
| """ | |
| if type(matr) != S.sparse.coo_matrix: | |
| raise TypeError('Matrix must be sparse COOrdinate format') | |
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
| """Make some plots for our 2010 NAR Web Server paper.""" | |
| import sys | |
| import numpy as np | |
| import matplotlib as mpl | |
| mpl.use('Agg') # Don't pop up figures, just render in memory | |
| import matplotlib.pyplot as plt | |
| # Empty dictionaries | |
| bp = {} |
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
| """ | |
| Simple implementation of ROC curve plotting with NumPy and matplotlib. | |
| No bells and whistles, no fancy data structures, just one function and | |
| a (hopefully) very gentle learning curve. | |
| """ | |
| __author__ = "David Warde-Farley <dwf AT cs.toronto.edu>" | |
| __copyright__ = "(c) 2010 David Warde-Farley" | |
| __license__ = "3-clause BSD license" |
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
| def kaprekar(s, t=4): | |
| """ | |
| Demonstrate Kaprekar's procedure and its convergence to Kaprekar's constant. | |
| """ | |
| s = str(s) | |
| # t = 3 or 4 will converge; otherwise all bets are off. | |
| assert len(s) <= t | |
| if len(s) < t: | |
| s = ('0' * (t - len(s))) + s | |
| print s |
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
| --- iplib.bak 2010-07-08 22:30:10.000000000 -0400 | |
| +++ iplib.py 2010-07-08 22:31:09.000000000 -0400 | |
| @@ -1684,6 +1684,14 @@ | |
| if Debugger.has_pydb: | |
| from pydb import pm | |
| else: | |
| + try: | |
| + import pudb | |
| + pudb.post_mortem((sys.last_type, | |
| + sys.last_value, |
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
| class Node(object): | |
| def __init__(self, value): | |
| self.value = value | |
| self.next = None | |
| def __str__(self): | |
| """Return a string representation of the list starting here.""" | |
| values = [] | |
| curr = self | |
| while curr is not None: |
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 os | |
| import numpy as np | |
| import scipy.ndimage as ndimage | |
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| def frac_eq_to(image, value=0): | |
| return (image == value).sum() / float(np.prod(image.shape)) | |
| def extract_patches(image, patchshape, overlap_allowed=0.5, cropvalue=None, |
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
| #!/bin/bash | |
| # screencap2dropbox.sh -- Takes a screenshot with Mac OS X's | |
| # 'screencapture' utility, places the output in a publicly accessible | |
| # Dropbox folder ( http://www.dropbox.com/ for more information ) | |
| # and then copies the URL to the clipboard. | |
| # | |
| # By David Warde-Farley, March 18, 2010. Inspired by an earlier Automator | |
| # version by Andrew Louis. | |
| # |