提交 0bde212b authored 作者: Mohammad Pezeshki's avatar Mohammad Pezeshki

mod added. tests are more complex.

上级 71a44de8
...@@ -2175,6 +2175,7 @@ pprint.assign(neg, printing.OperatorPrinter('-', 0, 'either')) ...@@ -2175,6 +2175,7 @@ pprint.assign(neg, printing.OperatorPrinter('-', 0, 'either'))
pprint.assign(true_div, printing.OperatorPrinter('/', -1, 'left')) pprint.assign(true_div, printing.OperatorPrinter('/', -1, 'left'))
pprint.assign(int_div, printing.OperatorPrinter('//', -1, 'left')) pprint.assign(int_div, printing.OperatorPrinter('//', -1, 'left'))
pprint.assign(pow, printing.OperatorPrinter('**', 1, 'right')) pprint.assign(pow, printing.OperatorPrinter('**', 1, 'right'))
pprint.assign(mod, printing.OperatorPrinter('%', -1, 'lef'))
class Inv(UnaryScalarOp): class Inv(UnaryScalarOp):
""" multiplicative inverse. Also called reciprocal""" """ multiplicative inverse. Also called reciprocal"""
......
...@@ -151,11 +151,22 @@ class test_composite(unittest.TestCase): ...@@ -151,11 +151,22 @@ class test_composite(unittest.TestCase):
e0 = x + y + z e0 = x + y + z
e1 = x + y * z e1 = x + y * z
e2 = x / y e2 = x / y
C = Composite([x, y, z], [e0, e1, e2]) e3 = x // 5
e4 = -x
e5 = x - y
e6 = x ** y + (-z)
e7 = x % 3
C = Composite([x, y, z], [e0, e1, e2, e3, e4, e5, e6, e7])
c = C.make_node(x, y, z) c = C.make_node(x, y, z)
g = FunctionGraph([x, y, z], c.outputs) g = FunctionGraph([x, y, z], c.outputs)
fn = gof.DualLinker().accept(g).make_function() fn = gof.DualLinker().accept(g).make_function()
assert str(g) == '[*1 -> Composite{((i0 + i1) + i2), (i0 + (i1 * i2)), (i0 / i1)}(x, y, z), *1::1, *1::2]'
assert str(g) == ('[*1 -> Composite{((i0 + i1) + i2),'
' (i0 + (i1 * i2)), (i0 / i1), '
'(i0 // Constant{5}), '
'(-i0), (i0 - i1), ((i0 ** i1) + (-i2)),'
' (i0 % Constant{3})}(x, y, z), '
'*1::1, *1::2, *1::3, *1::4, *1::5, *1::6, *1::7]')
def test_make_node_continue_graph(self): def test_make_node_continue_graph(self):
# This is a test for a bug (now fixed) that disabled the # This is a test for a bug (now fixed) that disabled the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论