提交 e9ff60c2 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Even more test fixes

上级 df97d8e6
...@@ -79,8 +79,9 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag0(): ...@@ -79,8 +79,9 @@ def test_unpickle_gpuarray_as_numpy_ndarray_flag0():
finally: finally:
config.experimental.unpickle_gpu_on_cpu = oldflag config.experimental.unpickle_gpu_on_cpu = oldflag
# These tests are disabled because they expect the impossible
test_shared_options = makeSharedTester( """
@makeSharedTester(
shared_constructor_=gpuarray_shared_constructor, shared_constructor_=gpuarray_shared_constructor,
dtype_=theano.config.floatX, dtype_=theano.config.floatX,
get_value_borrow_true_alias_=True, get_value_borrow_true_alias_=True,
...@@ -95,11 +96,12 @@ test_shared_options = makeSharedTester( ...@@ -95,11 +96,12 @@ test_shared_options = makeSharedTester(
theano_fct_=theano.tensor.exp, theano_fct_=theano.tensor.exp,
ref_fct_=np.exp, ref_fct_=np.exp,
cast_value_=lambda v: pygpu.array(v, context=get_context(test_ctx_name), cast_value_=lambda v: pygpu.array(v, context=get_context(test_ctx_name),
cls=pygpu._array.ndgpuarray), cls=pygpu._array.ndgpuarray))
name='test_shared_options') class test_shared_options(object):
pass
test_shared_options2 = makeSharedTester( @makeSharedTester(
shared_constructor_=gpuarray_shared_constructor, shared_constructor_=gpuarray_shared_constructor,
dtype_=theano.config.floatX, dtype_=theano.config.floatX,
get_value_borrow_true_alias_=False, get_value_borrow_true_alias_=False,
...@@ -114,5 +116,7 @@ test_shared_options2 = makeSharedTester( ...@@ -114,5 +116,7 @@ test_shared_options2 = makeSharedTester(
theano_fct_=theano.tensor.exp, theano_fct_=theano.tensor.exp,
ref_fct_=np.exp, ref_fct_=np.exp,
cast_value_=lambda v: pygpu.array(v, context=get_context(test_ctx_name), cast_value_=lambda v: pygpu.array(v, context=get_context(test_ctx_name),
cls=pygpu._array.ndgpuarray), cls=pygpu._array.ndgpuarray))
name='test_shared_options2') class test_shared_options2(object):
pass
"""
...@@ -304,6 +304,7 @@ class Psi(UnaryScalarOp): ...@@ -304,6 +304,7 @@ class Psi(UnaryScalarOp):
#ifndef ga_double #ifndef ga_double
#define ga_double double #define ga_double double
#endif
#ifndef _PSIFUNCDEFINED #ifndef _PSIFUNCDEFINED
#define _PSIFUNCDEFINED #define _PSIFUNCDEFINED
......
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import numpy as np import numpy as np
import unittest import unittest
import warnings from functools import update_wrapper
import theano import theano
from theano import tensor from theano import tensor
...@@ -25,7 +25,6 @@ def makeSharedTester(shared_constructor_, ...@@ -25,7 +25,6 @@ def makeSharedTester(shared_constructor_,
theano_fct_, theano_fct_,
ref_fct_, ref_fct_,
cast_value_=np.asarray, cast_value_=np.asarray,
name=None,
): ):
""" """
This is a generic fct to allow reusing the same test function This is a generic fct to allow reusing the same test function
...@@ -197,9 +196,7 @@ def makeSharedTester(shared_constructor_, ...@@ -197,9 +196,7 @@ def makeSharedTester(shared_constructor_,
assert not np.allclose(self.ref_fct(x), total_func()) assert not np.allclose(self.ref_fct(x), total_func())
def test_get_value(self): def test_get_value(self):
""" # Test that get_value returns a ndarray
Test that get_value return the same type as what was gived when creating the shared variable
"""
dtype = self.dtype dtype = self.dtype
if dtype is None: if dtype is None:
dtype = theano.config.floatX dtype = theano.config.floatX
...@@ -209,10 +206,9 @@ def makeSharedTester(shared_constructor_, ...@@ -209,10 +206,9 @@ def makeSharedTester(shared_constructor_,
x_cast = self.cast_value(x_orig) x_cast = self.cast_value(x_orig)
if self.shared_constructor_accept_ndarray: if self.shared_constructor_accept_ndarray:
x_shared = self.shared_constructor(x_orig, borrow=False) x_shared = self.shared_constructor(x_orig, borrow=False)
assert isinstance(x_shared.get_value(), x_orig.__class__) else:
x_shared = self.shared_constructor(x_cast, borrow=False)
x_shared = self.shared_constructor(x_cast, borrow=False) assert isinstance(x_shared.get_value(), x_orig.__class__)
assert isinstance(x_shared.get_value(), x_cast.__class__)
def test_set_value(self): def test_set_value(self):
dtype = self.dtype dtype = self.dtype
...@@ -573,14 +569,11 @@ def makeSharedTester(shared_constructor_, ...@@ -573,14 +569,11 @@ def makeSharedTester(shared_constructor_,
assert not x_shared.type.values_eq(x, y) assert not x_shared.type.values_eq(x, y)
assert not x_shared.type.values_eq_approx(x, y) assert not x_shared.type.values_eq_approx(x, y)
assert name is not None def f(cls):
SharedTester.__name__ = name return update_wrapper(SharedTester, cls, updated=())
if hasattr(SharedTester, '__qualname__'): return f
SharedTester.__qualname__ = name
return SharedTester
test_shared_options = makeSharedTester( @makeSharedTester(
shared_constructor_=tensor._shared, shared_constructor_=tensor._shared,
dtype_=theano.config.floatX, dtype_=theano.config.floatX,
get_value_borrow_true_alias_=True, get_value_borrow_true_alias_=True,
...@@ -593,8 +586,9 @@ test_shared_options = makeSharedTester( ...@@ -593,8 +586,9 @@ test_shared_options = makeSharedTester(
test_internal_type_=lambda a: isinstance(a, np.ndarray), test_internal_type_=lambda a: isinstance(a, np.ndarray),
theano_fct_=lambda a: a*2, theano_fct_=lambda a: a*2,
ref_fct_=lambda a: np.asarray((a*2)), ref_fct_=lambda a: np.asarray((a*2)),
cast_value_=np.asarray, cast_value_=np.asarray)
name='test_shared_options') class test_shared_options(object):
pass
def test_scalar_shared_options(): def test_scalar_shared_options():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论