installing LLVM-Py and Numba on Ubuntu 14.04

First, you need a custom compilation of LLVM 3.2 (as of July 2014). As of July 2014, LLVM-Py will NOT work with the default LLVM 3.4 in Ubuntu 14.04.

Note, these commands are NOT sudo/root. I choose to install LLVM 3.2 to ~/LLVM32.
the -j2 option is to use 2 CPU cores, you can increase this if you know you have more CPU cores.

cd ~/Downloads
tar xvfz llvm-3.2.src.tar.gz
cd ~/Downloads/llvm-3.2*
./configure --enable-optimized --prefix=$HOME/LLVM32
REQUIRES_RTTI=1 make -j2 install

After 15 minutes or so the LLVM 3.2 compilation & installation completes
Now we install LLVM-Py:

cd ~/Downloads
git clone
cd llvmpy
sudo LLVM_CONFIG_PATH=$HOME/LLVM32/bin/llvm-config python install

Now you can run the tests by pasting into Terminal (NOT from the LLVMPY directory you just installed from):

cd ~
python -c "import llvm; llvm.test()"

Fixing SSH Access Denied for Github

Github suggests that you use the SSH Agent, but even that may not work when you have a lot of SSH keys. You need to setup your ~/.ssh/config file so that SSH to uses the correct SSH Public Key the first time. Here’s how.

nano ~/.ssh/config

and add the lines

        User git
        Port 22 
        IdentitiesOnly yes
        PubKeyAuthentication yes
        IdentityFile ~/.ssh/MyGithubKey

where MyGitHubKey is the key you created following the process (without ssh-agent)

Then switch your remote URL to SSH

Very pleased with Lenovo warranty service

My corporate X220 had the space bar get slightly intermittent after 4 years of hard use and abuse. Naturally the corporation had the maximum warranty coverage, but I didn’t want to have someone manhandling my computer.

Instead, a few minutes on the phone with their Atlanta, Georgia tech support center saw me getting a Next-Day Early Morning express shipped keyboard to my office, so I can change it myself. That is excellent. It probably cost Lenovo more to ship the keyboard than the keyboard itself costs them.

10 years ago I bought my last Dell computer, a nearly $3000 laptop, and the speakers failed after about two months of use, and they sneered at me as if I was blasting death metal music instead of teleconferences. I have heard more recent reports of the same Dell attitude on speakers.
OK different problem, but entirely different attitude from Lenovo tech support.

Although I build my desktops myself, when it comes to laptops I’ll still be looking to Lenovo.

upgrading to Scipy 0.14 via pip

you may first need to do

sudo apt-get install liblapack-dev libatlas-dev


sudo pip install --upgrade scipy


Spyder 2.3 missing rope for Python3

The just-released Spyder 2.3 (on Ubuntu, get by typing)

sudo pip3 install spyder

but it’s missing rope. To get rope, type

sudo pip3 install rope_py3k

for great online help

Autoscaling imagesc() plot and imshow() plots

Octave 3.8 has default axis scaling that scales x and y axes proportionally to the axes values. So if one axis values span a much wider range than the other axis, the smaller span axis gets very thin.

You can simply insert the line
axis(‘normal’) after imagesc()

In Matplotlib 1.3, the same issue occurs, which can be covercome with the option aspect=’auto’

Using P.C. Hansen’s AIRtools and ReguTools in Python using Oct2Py

For those working with real-world inverse problems, P.C. Hansen’s AIRtools and ReguTools are great ways to quickly try out inverse methods.

As in general in Python and Matlab, you need to be sure that your column vector of observations “b” is actually passed into the functions as a column vector. I’ll illustrate the issue by example.

Assume you have ill-conditioned problem Ax = b, with dimensions:
A: 256 x 10
x: 10 x 1
b: 256 x 1

so to use the ReguTools function maxent.m from Python, implementing the Berg Maximum Entropy method, your file would look like:

import oct2py
import numpy as np

def myinv(A,b,maxentLambda):
    oc = oct2py.Oct2Py(oned_as='column')
    xhat = oc.maxent(A,b,maxentLambda)
    return xhat

When I originally wrote this post with Oct2Py 1.5.0, you could only pass 1-D vectors as row vectors. As noted below the author promptly added the “oned_as” option noted above.

from oct2py import octave
import numpy as np
def myinv(A,b,maxentLambda):
xhat = octave.maxent(A,b[...,np.newaxis],maxentLambda)
return xhat
The np.newaxis is required under Oct2Py 1.5.0 to pass “b” as column vector, else it will be passed as a row vector, which will not work properly.
You can verify this by looking at the .mat file created in your /tmp directory, you’ll see it contains A__, B__,C__ which are the three argument passed into octave.maxent(). B__ will only be a column vector if you pass in b[...,np.newaxis]

I have also slowly started porting the PC Hansen AIRtools and Regutools that I use into Python in:

I have noted this issue to Oct2Py github as issue #49

Update: The Oct2Py author has already changed the code to allow specifying 1-D vectors are columns. Here’s a minimal working example, with the beta 1.6.0 code (perhaps already released by the time you read this).

import numpy as np
import oct2py
oc = oct2py.Oct2Py(oned_as='column')
x = np.array([1,2,3,4,5])

gives you the answer: array([[5., 1.]])

Matlab R2014a Fortran MEX on Ubuntu 14.04

0) in terminal:
cp /usr/local/MATLAB/R2014a/extern/examples/refbook/* /tmp/
1) in matlab:
mex -setup FORTRAN
2) in matlab:

>> mex /tmp/timestwo.F
Building with 'gfortran'.
MEX completed successfully

3) in matlab:
ans =

HDF5 in Labview 2013

There is steady development of the h5labview package, allowing use of many common HDF5 read/write features from Matlab.

0) install VI package manager
1) download and install the latest SHARED HDF5 library from
get the appropriate operating system and 32 or 64 bits according to your Labview install 32/64 bits, not the OS.
2) copy the files hdf5.dll, szip.dll, zlib.dll from
c:\Program Files\HDF_Group\HDF5\1.8.13\bin to
c:\Program Files\National Instruments\LabVIEW 2013\resource

3) download latest .vip file from
this will open in VI Package Manager

If you get an error upon installation complaining about, try rebooting once.


Matplotlib in Cygwin 64-bit for Python 3 and Python 2.7

It is pretty simple to install matplotlib for Python 3 and Python 2.7 in Cygwin.

pkg-config ghostscript libfreetype-devel libpng-devel python-gtk2.0 libgtk2.0-devel gcc-g++ git

git clone git://
cd matplotlib
python install

or for python 3, do:
python3 install

$ python
Python 2.7.5 (default, Oct 2 2013, 22:34:09)
[GCC 4.8.1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__

$ python3
Python 3.2.5 (default, Oct 2 2013, 22:58:11)
[GCC 4.8.1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__

Note: to actually use matplotlib to create a visible figure, you need a basic X11 system running (install xinit, etc in Cygwin) and type
and then start python from inside X11 terminal.