提交 95b4fec5 authored 作者: abergeron's avatar abergeron

Merge pull request #1906 from nouiz/tests

fix tests
......@@ -3,6 +3,7 @@ import unittest
import numpy
import theano
from theano.gof import graph
from theano.gof.graph import Variable, Apply, Constant
from theano.gof.type import Type
......@@ -192,9 +193,21 @@ def test_container_deepcopy():
This is a test to a work around a NumPy bug.
"""
t = theano.tensor.scalar()
v = numpy.asarray(0.)
# It seam that numpy.asarray(0.).astype(floatX) can return a numpy
# scalar with some NumPy Version. So we call numpy.asarray with
# the dtype parameter.
v = numpy.asarray(0., dtype=theano.config.floatX)
assert isinstance(v, numpy.ndarray), type(v)
for readonly in [True, False]:
c = Container(t, [v], readonly=readonly)
assert isinstance(c.storage[0], numpy.ndarray)
assert isinstance(c.storage[0], numpy.ndarray), (c.storage[0],
type(c.storage[0]))
assert c.storage[0].dtype == v.dtype, (c.storage[0].dtype, v.dtype)
assert c.storage[0].dtype == c.type.dtype, (c.storage[0].dtype,
c.type.dtype)
d = deepcopy(c)
assert isinstance(d.storage[0], numpy.ndarray)
assert isinstance(d.storage[0], numpy.ndarray), (d.storage[0],
type(d.storage[0]))
assert d.storage[0].dtype == v.dtype, (d.storage[0].dtype, v.dtype)
assert d.storage[0].dtype == c.type.dtype, (d.storage[0].dtype,
c.type.dtype)
......@@ -9,7 +9,6 @@ from theano.sandbox.cuda import cuda_available, GpuOp
if cuda_available:
from theano.sandbox.cuda import (basic_ops, CudaNdarrayType,
CudaNdarray)
import theano.misc.pycuda_init
from theano.misc.pycuda_init import pycuda_available
if pycuda_available:
import pycuda.gpuarray
......
......@@ -7,8 +7,14 @@ from theano.tests import unittest_tools as utt
# Skip tests if cuda_ndarray is not available.
from nose.plugins.skip import SkipTest
import theano.sandbox.cuda as cuda_ndarray
if cuda_ndarray.cuda_available == False:
raise SkipTest('Optional package cuda disabled')
if not cuda_ndarray.cuda_available:
raise SkipTest('Optional package cuda not available')
from theano.misc.pycuda_init import pycuda_available
if not pycuda_available:
raise SkipTest('Optional package pycuda not available')
from theano.sandbox.cuda.fftconv import scikits_cuda_available
if not scikits_cuda_available:
raise SkipTest('Optional package scikits.cuda not available')
from theano.sandbox.cuda import float32_shared_constructor as shared
import theano.sandbox.cuda.fftconv
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论