import numpy as np


def as_row(x):
    return x.ravel()[np.newaxis, :]


def as_col(x):
    return as_row(x).T


def days_between(now, then):
    try:
        return (now - then).days
    except AttributeError:
        return np.nan


@@ -228,8 +228,252 @@
 np.nan%0A%0A
+%0Adef check_grad(f, x0, eps=1e-8):%0A    f0 = f(x0)%0A    n = x0.size%0A    g = np.zeros_like(x0)%0A    for i in range(n):%0A        dt = np.zeros_like(x0)%0A        dt%5Bi%5D += eps%0A        f1 = f(x0 + dt)%0A        g%5Bi%5D = (f1 - f0) / eps%0A        %0A    return g%0A%0A

Add check_grad function.