def test_eigvalsh_grad(): rng = np.random.default_rng(utt.fetch_seed()) a = rng.standard_normal((5, 5)) a = a + a.T b = 10 * np.eye(5, 5) + rng.standard_normal((5, 5)) utt.verify_grad(lambda a, b: eigvalsh(a, b).dot([1, 2, 3, 4, 5]), [a, b], rng=np.random)
def test_eigvalsh_grad(): pytest.importorskip("scipy") rng = np.random.RandomState(utt.fetch_seed()) a = rng.randn(5, 5) a = a + a.T b = 10 * np.eye(5, 5) + rng.randn(5, 5) utt.verify_grad( lambda a, b: eigvalsh(a, b).dot([1, 2, 3, 4, 5]), [a, b], rng=np.random )
def test_eigvalsh(): A = dmatrix("a") B = dmatrix("b") f = function([A, B], eigvalsh(A, B)) rng = np.random.default_rng(utt.fetch_seed()) a = rng.standard_normal((5, 5)) a = a + a.T for b in [10 * np.eye(5, 5) + rng.standard_normal((5, 5))]: w = f(a, b) refw = scipy.linalg.eigvalsh(a, b) np.testing.assert_array_almost_equal(w, refw) # We need to test None separately, as otherwise DebugMode will # complain, as this isn't a valid ndarray. b = None B = aet.NoneConst f = function([A], eigvalsh(A, B)) w = f(a) refw = scipy.linalg.eigvalsh(a, b) np.testing.assert_array_almost_equal(w, refw)
def test_eigvalsh(): scipy = pytest.importorskip("scipy") A = dmatrix("a") B = dmatrix("b") f = function([A, B], eigvalsh(A, B)) rng = np.random.RandomState(utt.fetch_seed()) a = rng.randn(5, 5) a = a + a.T for b in [10 * np.eye(5, 5) + rng.randn(5, 5)]: w = f(a, b) refw = scipy.linalg.eigvalsh(a, b) np.testing.assert_array_almost_equal(w, refw) # We need to test None separatly, as otherwise DebugMode will # complain, as this isn't a valid ndarray. b = None B = aet.NoneConst f = function([A], eigvalsh(A, B)) w = f(a) refw = scipy.linalg.eigvalsh(a, b) np.testing.assert_array_almost_equal(w, refw)