def test_param_strict(self):
a = tensor.dvector()
b = shared(7)
out = a + b
f = pfunc([In(a, strict=False)], [out])
# works, rand generates float64 by default
f(numpy.random.rand(8))
# works, casting is allowed
f(numpy.array([1, 2, 3, 4], dtype='int32'))
f = pfunc([In(a, strict=True)], [out])
try:
# fails, f expects float64
f(numpy.array([1, 2, 3, 4], dtype='int32'))
except TypeError:
pass
评论列表
文章目录