def test_evaluation(shape, r, niter=10):
    for _ in range(niter):
        elem = ManifoldElement.rand(shape, r)
        full = csr_matrix(elem.full_matrix())
        for percent in np.linspace(0.01, 1., 10):
            sigma = generate_sigma_set(shape, percent)
            temp = csr_matrix(coo_matrix((np.array(full[sigma]).ravel(), sigma), shape=shape))
            assert(np.allclose(temp.todense(), elem.evaluate(sigma).todense()))
def obvious_test(shape, r, niter=10):
    percent = 0.5
    sigma_set = generate_sigma_set(shape, percent)
    a_full = shape[1]*np.arange(shape[0])[:, None] + np.arange(shape[1])
    a_sparse = lil_matrix(shape)
    for (i, j) in zip(*sigma_set):
        a_sparse[i, j] = a_full[i, j]
    a_sparse = csr_matrix(a_sparse)
    x = ManifoldElement.rand(shape, r)
    grad = riemannian_grad_partial(x, a_sparse, sigma_set, manifold_elems=True)
    new_grad = vector_transport_base(x, x, grad)
    for elem, new_elem in zip(grad, new_grad):
        assert(np.allclose(elem.full_matrix(), new_elem.full_matrix()))