提交 99de36c8 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3999 from Sentient07/cont-pull#3983

extension of #3983
import unittest from __future__ import absolute_import, print_function, division
import unittest
import os import os
import re import re
...@@ -12,5 +13,5 @@ class FunctionName(unittest.TestCase): ...@@ -12,5 +13,5 @@ class FunctionName(unittest.TestCase):
x = tensor.vector('x') x = tensor.vector('x')
func = theano.function([x], x + 1.) func = theano.function([x], x + 1.)
regex = re.compile(os.path.basename('.*test_function_name.pyc?:13')) regex = re.compile(os.path.basename('.*test_function_name.pyc?:14'))
assert(regex.match(func.name) is not None) assert(regex.match(func.name) is not None)
...@@ -21,7 +21,7 @@ import numpy ...@@ -21,7 +21,7 @@ import numpy
from six.moves import xrange from six.moves import xrange
import theano import theano
from theano.compat import PY3, imap, izip from theano.compat import imap, izip
from theano import gof, printing from theano import gof, printing
from theano.gof import (Op, utils, Variable, Constant, Type, Apply, from theano.gof import (Op, utils, Variable, Constant, Type, Apply,
FunctionGraph) FunctionGraph)
...@@ -604,10 +604,9 @@ class _scalar_py_operators: ...@@ -604,10 +604,9 @@ class _scalar_py_operators:
def __mul__(self, other): def __mul__(self, other):
return mul(self, other) return mul(self, other)
if PY3:
def __truediv__(self, other): def __truediv__(self, other):
return div_proxy(self, other) return div_proxy(self, other)
else:
def __div__(self, other): def __div__(self, other):
return div_proxy(self, other) return div_proxy(self, other)
......
...@@ -9,6 +9,8 @@ If you do want to rewrite these tests, bear in mind: ...@@ -9,6 +9,8 @@ If you do want to rewrite these tests, bear in mind:
* FunctionGraph and DualLinker are old, use compile.function instead. * FunctionGraph and DualLinker are old, use compile.function instead.
""" """
from __future__ import absolute_import, print_function, division
import unittest import unittest
import numpy as np import numpy as np
......
from __future__ import division
import theano
import theano.tensor as T
import unittest
class test_FutureDiv(unittest.TestCase):
def test_divide_floats(self):
a = T.dscalar('a')
b = T.dscalar('b')
c = theano.function([a, b], b / a)
d = theano.function([a, b], b // a)
assert c(6, 3) == 0.5
assert d(6, 3) == 0.0
import theano
import theano.tensor as T
import unittest
class test_FutureDiv(unittest.TestCase):
def test_divide_floats(self):
a = T.dscalar('a')
b = T.dscalar('b')
c = theano.function([a, b], b / a)
d = theano.function([a, b], b // a)
assert c(6, 3) == 0.5
assert d(6, 3) == 0.0
from __future__ import print_function from __future__ import absolute_import, print_function, division
import os import os
import shutil import shutil
import sys import sys
......
from __future__ import absolute_import, print_function, division
import numpy import numpy
from theano.tensor.elemwise import Elemwise from theano.tensor.elemwise import Elemwise
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论