Skip to content

Instantly share code, notes, and snippets.

View stefanv's full-sized avatar

Stefan van der Walt stefanv

View GitHub Profile
@stefanv
stefanv / reasoning_l1.py
Created March 27, 2012 06:14
PGM course: compute P(L1)
import numpy as np
P_D = np.array([0.6, 0.4])
P_I = np.array([0.7, 0.3])
P_G_ID = np.array([
[[0.3, 0.05],
[0.9, 0.5]],
[[0.4, 0.25],
@stefanv
stefanv / octave magic.ipynb
Created June 4, 2012 07:25
IPython Octave Magics Example Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanv
stefanv / paramap.py
Created June 25, 2012 23:54
paraview colormaps
_para1 = {'red': ((0.0, 0.019390722, 0.019390722), (0.125, 0.355334722,
0.355334722), (0.25, 0.565570631, 0.565570631), (0.375,
0.76583663, 0.76583663), (0.5, 0.966006412, 0.966006412),
(0.625, 0.953403586, 0.953403586), (0.75, 0.906621393,
0.906621393), (0.875, 0.831556904, 0.831556904), (1.0,
0.732691891, 0.732691891)),
'green': ((0.0, 0.390501895, 0.390501895), (0.125, 0.524474908,
0.524474908), (0.25, 0.665714642, 0.665714642), (0.375,
0.813150205, 0.813150205), (0.5, 0.96603773, 0.96603773),
@stefanv
stefanv / cell.py
Created September 21, 2012 20:45
Cell detection
from skimage import io, filter, morphology, segmentation, measure, img_as_float
import os
# Download the image
if not os.path.exists('cell.png'):
print "Downloading snowflakes image..."
import urllib2
u = urllib2.urlopen('http://people.sc.fsu.edu/~jburkardt/data/tif/cell.png')
@stefanv
stefanv / jazz.net
Created September 27, 2012 23:10
Modularity
*Vertddices 198
*Arcs
*Edges
1 8 1
1 24 1
1 35 1
1 42 1
1 46 1
1 60 1
1 74 1
@stefanv
stefanv / nose.ipynb
Created November 1, 2012 21:09
Executing Nose in the notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanv
stefanv / ip_consolas.patch
Created November 5, 2012 01:33
IPython with Consolas
$ git diff -w notebook.css
diff --git a/IPython/frontend/html/notebook/static/css/notebook.css b/IPython/frontend
index 9396bf7..55e3a64 100644
--- a/IPython/frontend/html/notebook/static/css/notebook.css
+++ b/IPython/frontend/html/notebook/static/css/notebook.css
@@ -311,6 +311,7 @@ div.text_cell_render {
.CodeMirror {
line-height: 1.231; /* Changed from 1em to our global default */
+ font-family: Consolas;
@stefanv
stefanv / boxplot.py
Created November 8, 2012 01:04
Better boxplot
def my_boxplot(ax, positions, values, width=None, color=None, label=None):
"""Custom box plot to work around some of matplotlib's quirks.
Parameters
----------
ax : matplotlib axis
Target axis.
positions : (M,) ndarray of float
Where to positions boxes on the x-axis.
values : (M, N) ndarray of float
@stefanv
stefanv / hint.ipynb
Created November 12, 2012 19:50
Hints in the notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stefanv
stefanv / dictionaries.ipynb
Created November 15, 2012 18:45
Dictionary exercise
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.