提交 e814414d authored 作者: Benjamin Scellier's avatar Benjamin Scellier 提交者: Nicolas Ballas

file theano/gof/tests/test_op.py

上级 4507bc53
......@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
import unittest
from nose.plugins.skip import SkipTest
import numpy
import numpy as np
import theano
import theano.gof.op as op
......@@ -181,7 +181,7 @@ class TestMakeThunk(unittest.TestCase):
o.owner.op.c_code,
o.owner, 'o', ['x'], 'z', {'fail': ''})
storage_map = {i: [numpy.int32(3)],
storage_map = {i: [np.int32(3)],
o: [None]}
compute_map = {i: [True],
o: [False]}
......@@ -218,7 +218,7 @@ class TestMakeThunk(unittest.TestCase):
o.owner.op.perform,
o.owner, 0, [None])
storage_map = {i: [numpy.int32(3)],
storage_map = {i: [np.int32(3)],
o: [None]}
compute_map = {i: [True],
o: [False]}
......@@ -251,9 +251,9 @@ class TestMakeThunk(unittest.TestCase):
x_input = T.dmatrix('x_input')
f = theano.function([x_input], DoubleOp()(x_input))
inp = numpy.random.rand(5, 4)
inp = np.random.rand(5, 4)
out = f(inp)
assert numpy.allclose(inp * 2, out)
assert np.allclose(inp * 2, out)
def test_test_value_python_objects():
......@@ -262,33 +262,33 @@ def test_test_value_python_objects():
def test_test_value_ndarray():
x = numpy.zeros((5, 5))
x = np.zeros((5, 5))
v = op.get_test_value(x)
assert (v == x).all()
def test_test_value_constant():
x = T.as_tensor_variable(numpy.zeros((5, 5)))
x = T.as_tensor_variable(np.zeros((5, 5)))
v = op.get_test_value(x)
assert numpy.all(v == numpy.zeros((5, 5)))
assert np.all(v == np.zeros((5, 5)))
def test_test_value_shared():
x = shared(numpy.zeros((5, 5)))
x = shared(np.zeros((5, 5)))
v = op.get_test_value(x)
assert numpy.all(v == numpy.zeros((5, 5)))
assert np.all(v == np.zeros((5, 5)))
def test_test_value_op():
try:
prev_value = config.compute_test_value
config.compute_test_value = 'raise'
x = T.log(numpy.ones((5, 5)))
x = T.log(np.ones((5, 5)))
v = op.get_test_value(x)
assert numpy.allclose(v, numpy.zeros((5, 5)))
assert np.allclose(v, np.zeros((5, 5)))
finally:
config.compute_test_value = prev_value
......@@ -337,8 +337,8 @@ def test_get_debug_values_success():
config.compute_test_value = mode
x = T.vector()
x.tag.test_value = numpy.zeros((4,), dtype=config.floatX)
y = numpy.zeros((5, 5))
x.tag.test_value = np.zeros((4,), dtype=config.floatX)
y = np.zeros((5, 5))
iters = 0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论