import numpy as np

def null(a, rtol=1e-05):
    u, s, v = np.linalg.svd(a)
rank = (s > rtol * s[0]).sum()
a simple, matlab-like way of finding the null space of a small matrix in numpy (and number formatting)