(A Creative Blog Name Here)

Code, math, and other things I find useful

Embedded gist appearance

Some of the posts on this blog include embedded gists to display code. Apparently GitHub has changed something about gists and now the syntax highlighting is all messed up. Hopefully there will be a fix in the near future, but in the mean time we're just going to have ...

Building octopress blog with rake

If you experience the symptoms in octopress issue #759, i.e. rake generate breaks because ffi tries to load lib.dylib, you should check that the shell you are trying to build your blog from

  1. is not running a tmux session (the wrong ruby will be used)
  2. does not have ...

Extracting keys from Python dict into interpreter namespace

I run a lot of experiments in ipython, the results of which I pickle and save to disk. When I reload the results with pickle I end up with a dict whose keys are the variable names that I saved. It is tedious to have to reference these values through ...

Cython and GSL made easy

I just found CythonGSL on Github that wraps the GSL library for use with Cython. Installation is simple

$ git clone git://github.com/twiecki/CythonGSL.git 
$ cd CythonGSL
$ python setup.py build
$ python setup.py install

I have also added this to my behemoth instructions on setting up python.

Python build targets

While writing the code for my last post on Cython I encountered something strange regarding distutils. The code linked to the GSL library which on my machine (running OSX) is a unversal library containing both 32- and 64-bit versions. When I run

$ python setup.py build_ext --inplace

distutils attempts to ...

Cythonizing instance methods

A large amount of my work involves writing MCMC samplers. The models I work with have a lot of parameters and the samplers require a lot of state to be recorded. Normally, I stuff all of the parameters and state into a Python class and implement the different steps of ...

Using syntastic with vim (and a vim bug on OSX)

Syntastic is a syntax checking plugin for vim that supports many different languages. I decided to give it a try in my current vim setup for my current projects written in python. Additionally, I decided to try out flake8, a wrapper for pyflakes, pep8 and mccabe.

Setting up flake8 is ...

IPython parallel

When I start IPython the first two commands I run are

%load_ext autoreload
%autoreload 2

which forces IPython to reload code before running it so that the newest version is always used. However, when developing code to run in parallel with the IPython.parallel module on a cluster started with ...

Setting up python in virtualenv for data analysis on OSX

I have decided to use python for my research code as I have become fed up with needing an internet connection to work with Matlab and not being able to check out a license for toolboxes I need (e.g. the statistics toolbox) right before a paper deadline. I have ...