def test_multiple_fast_inverse_errors(): shape = (2, 2, 2) X = np.zeros(shape) with assert_raises(ValueError): multiple_fast_inverse(X) shape = (10, 20, 20) X = np.zeros(shape) with assert_raises(ValueError): multiple_fast_inverse(X)
def test_multiple_fast_inv(): shape = (10, 20, 20) X = np.random.randn(shape[0], shape[1], shape[2]) X_inv_ref = np.zeros(shape) for i in range(shape[0]): X[i] = np.dot(X[i], X[i].T) X_inv_ref[i] = spl.inv(X[i]) X_inv = multiple_fast_inverse(X) assert_almost_equal(X_inv_ref, X_inv)