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

Minimum is numpy 1.9.1

上级 0f4be8d9
...@@ -575,12 +575,6 @@ class BinCountOp(theano.Op): ...@@ -575,12 +575,6 @@ class BinCountOp(theano.Op):
def __init__(self, minlength=None): def __init__(self, minlength=None):
self.minlength = minlength self.minlength = minlength
if minlength is not None:
numpy_ver = [int(n) for n in numpy.__version__.split('.')[:2]]
if not bool(numpy_ver >= [1, 6]):
raise NotImplementedError(
"BinCountOp with minlength attribute"
" requires NumPy 1.6 or higher.")
def make_node(self, x, weights): def make_node(self, x, weights):
warnings.warn(( warnings.warn((
......
...@@ -826,6 +826,7 @@ class T_reduce_dtype(unittest.TestCase): ...@@ -826,6 +826,7 @@ class T_reduce_dtype(unittest.TestCase):
uint8='uint64', uint8='uint64',
uint16='uint64', uint16='uint64',
uint32='uint64', uint32='uint64',
float16='float32',
float32='float64', float32='float64',
complex64='complex128', complex64='complex128',
).get(dtype, dtype) ).get(dtype, dtype)
...@@ -967,7 +968,7 @@ class T_mean_dtype(unittest.TestCase): ...@@ -967,7 +968,7 @@ class T_mean_dtype(unittest.TestCase):
pass pass
else: else:
# Executed if no TypeError was raised # Executed if no TypeError was raised
if sum_dtype in tensor.discrete_dtypes and axis != []: if sum_dtype in tensor.discrete_dtypes:
assert mean_var.dtype == 'float64', ( assert mean_var.dtype == 'float64', (
(mean_var.dtype, sum_dtype)) (mean_var.dtype, sum_dtype))
else: else:
......
...@@ -18,9 +18,6 @@ from theano import tensor as T ...@@ -18,9 +18,6 @@ from theano import tensor as T
from theano import config, tensor, function from theano import config, tensor, function
from theano.tests.unittest_tools import attr from theano.tests.unittest_tools import attr
numpy_ver = [int(n) for n in numpy.__version__.split('.')[:2]]
numpy_16 = bool(numpy_ver >= [1, 6])
def test_cpu_contiguous(): def test_cpu_contiguous():
a = T.fmatrix('a') a = T.fmatrix('a')
...@@ -290,8 +287,6 @@ class TestBinCountOp(utt.InferShapeTester): ...@@ -290,8 +287,6 @@ class TestBinCountOp(utt.InferShapeTester):
assert (np.bincount(a) == f1(a)).all() assert (np.bincount(a) == f1(a)).all()
assert np.allclose(np.bincount(a, weights=weights), assert np.allclose(np.bincount(a, weights=weights),
f2(a, weights)) f2(a, weights))
if not numpy_16:
continue
f3 = theano.function([x], BinCountOp(minlength=23)(x, weights=None)) f3 = theano.function([x], BinCountOp(minlength=23)(x, weights=None))
f4 = theano.function([x], BinCountOp(minlength=5)(x, weights=None)) f4 = theano.function([x], BinCountOp(minlength=5)(x, weights=None))
assert (np.bincount(a, minlength=23) == f3(a)).all() assert (np.bincount(a, minlength=23) == f3(a)).all()
...@@ -327,8 +322,6 @@ class TestBinCountOp(utt.InferShapeTester): ...@@ -327,8 +322,6 @@ class TestBinCountOp(utt.InferShapeTester):
1, 51, size=(25,)).astype(dtype)], 1, 51, size=(25,)).astype(dtype)],
self.op_class) self.op_class)
if not numpy_16:
continue
self._compile_and_check([x], self._compile_and_check([x],
[BinCountOp(minlength=60)(x, weights=weights)], [BinCountOp(minlength=60)(x, weights=weights)],
[np.random.randint( [np.random.randint(
...@@ -798,13 +791,11 @@ class test_Unique(utt.InferShapeTester): ...@@ -798,13 +791,11 @@ class test_Unique(utt.InferShapeTester):
self.ops = [Unique(), self.ops = [Unique(),
Unique(True), Unique(True),
Unique(False, True), Unique(False, True),
Unique(True, True)] Unique(True, True),
if bool(numpy_ver >= [1, 9]): Unique(False, False, True),
self.ops.extend([ Unique(True, False, True),
Unique(False, False, True), Unique(False, True, True),
Unique(True, False, True), Unique(True, True, True)]
Unique(False, True, True),
Unique(True, True, True)])
def test_basic_vector(self): def test_basic_vector(self):
""" """
...@@ -816,13 +807,11 @@ class test_Unique(utt.InferShapeTester): ...@@ -816,13 +807,11 @@ class test_Unique(utt.InferShapeTester):
list_outs_expected = [[np.unique(inp)], list_outs_expected = [[np.unique(inp)],
np.unique(inp, True), np.unique(inp, True),
np.unique(inp, False, True), np.unique(inp, False, True),
np.unique(inp, True, True)] np.unique(inp, True, True),
if bool(numpy_ver >= [1, 9]): np.unique(inp, False, False, True),
list_outs_expected.extend([ np.unique(inp, True, False, True),
np.unique(inp, False, False, True), np.unique(inp, False, True, True),
np.unique(inp, True, False, True), np.unique(inp, True, True, True)]
np.unique(inp, False, True, True),
np.unique(inp, True, True, True)])
for op, outs_expected in zip(self.ops, list_outs_expected): for op, outs_expected in zip(self.ops, list_outs_expected):
f = theano.function(inputs=[x], outputs=op(x, return_list=True)) f = theano.function(inputs=[x], outputs=op(x, return_list=True))
outs = f(inp) outs = f(inp)
...@@ -839,13 +828,11 @@ class test_Unique(utt.InferShapeTester): ...@@ -839,13 +828,11 @@ class test_Unique(utt.InferShapeTester):
list_outs_expected = [[np.unique(inp)], list_outs_expected = [[np.unique(inp)],
np.unique(inp, True), np.unique(inp, True),
np.unique(inp, False, True), np.unique(inp, False, True),
np.unique(inp, True, True)] np.unique(inp, True, True),
if bool(numpy_ver >= [1, 9]): np.unique(inp, False, False, True),
list_outs_expected.extend([ np.unique(inp, True, False, True),
np.unique(inp, False, False, True), np.unique(inp, False, True, True),
np.unique(inp, True, False, True), np.unique(inp, True, True, True)]
np.unique(inp, False, True, True),
np.unique(inp, True, True, True)])
for op, outs_expected in zip(self.ops, list_outs_expected): for op, outs_expected in zip(self.ops, list_outs_expected):
f = theano.function(inputs=[x], outputs=op(x, return_list=True)) f = theano.function(inputs=[x], outputs=op(x, return_list=True))
outs = f(inp) outs = f(inp)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论