提交 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 re
......@@ -12,5 +13,5 @@ class FunctionName(unittest.TestCase):
x = tensor.vector('x')
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)
......@@ -21,7 +21,7 @@ import numpy
from six.moves import xrange
import theano
from theano.compat import PY3, imap, izip
from theano.compat import imap, izip
from theano import gof, printing
from theano.gof import (Op, utils, Variable, Constant, Type, Apply,
FunctionGraph)
......@@ -604,12 +604,11 @@ class _scalar_py_operators:
def __mul__(self, other):
return mul(self, other)
if PY3:
def __truediv__(self, other):
return div_proxy(self, other)
else:
def __div__(self, other):
return div_proxy(self, other)
def __truediv__(self, other):
return div_proxy(self, other)
def __div__(self, other):
return div_proxy(self, other)
def __floordiv__(self, other):
return int_div(self, other)
......
......@@ -9,6 +9,8 @@ If you do want to rewrite these tests, bear in mind:
* FunctionGraph and DualLinker are old, use compile.function instead.
"""
from __future__ import absolute_import, print_function, division
import unittest
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 shutil
import sys
......
from __future__ import absolute_import, print_function, division
import numpy
from theano.tensor.elemwise import Elemwise
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论