def fill_diagonal(a, val):
    if a.ndim < 2:
        raise ValueError("array must be at least 2-d")
    if a.ndim == 2:
        # Explicit, fast formula for the common case.  For 2-d arrays, we
        # accept rectangular ones.
        step = a.shape[1] + 1
    else:
        # For more than d=2, the strided formula is only valid for arrays with
        # all dimensions equal, so we check first.
        if not np.alltrue(np.diff(a.shape) == 0):
            raise ValueError("All dimensions of input must be of equal length")
        step = np.cumprod((1,) + a.shape[:-1]).sum()

    # Write the value out into the diagonal.
    a.flat[::step] = val
Calling :func:`calculate_base_branch` with a version that isn't a
dataset/ETHPy150Open nipy/nitime/nitime/utils.py/fill_diagonal--crossover with--dataset/ETHPy150Open ClusterHQ/flocker/admin/test/test_release.py/CalculateBaseBranchTests.test_calculate_base_branch_for_non_release_fails