def test_on_real_input(self): x = dvector() rng = np.random.RandomState(23) xval = rng.randn(10) np.all(0 == aesara.function([x], imag(x))(xval)) np.all(xval == aesara.function([x], real(x))(xval)) x = imatrix() xval = np.asarray(rng.randn(3, 3) * 100, dtype="int32") np.all(0 == aesara.function([x], imag(x))(xval)) np.all(xval == aesara.function([x], real(x))(xval))
def test_basic(self): x = zvector() rng = np.random.RandomState(23) xval = np.asarray( list(np.complex(rng.randn(), rng.randn()) for i in range(10))) assert np.all(xval.real == aesara.function([x], real(x))(xval)) assert np.all(xval.imag == aesara.function([x], imag(x))(xval))
def test_complex(self): rng = np.random.RandomState(2333) m = fmatrix() c = complex(m[0], m[1]) assert c.type == cvector r, i = [real(c), imag(c)] assert r.type == fvector assert i.type == fvector f = aesara.function([m], [r, i]) mval = np.asarray(rng.randn(2, 5), dtype="float32") rval, ival = f(mval) assert np.all(rval == mval[0]), (rval, mval[0]) assert np.all(ival == mval[1]), (ival, mval[1])
def f(m): c = complex(m[0], m[1]) return 0.5 * real(c) + 0.9 * imag(c)
def f(m): c = complex_from_polar(abs(m[0]), m[1]) return 0.5 * real(c) + 0.9 * imag(c)