提交 fe4f7eb4 authored 作者: Tanjay94's avatar Tanjay94

Added test to check for wrong shape in power function.

上级 76eac264
...@@ -5023,5 +5023,5 @@ def ptp(a, axis=None): ...@@ -5023,5 +5023,5 @@ def ptp(a, axis=None):
return out return out
def power(x,y): def power(x, y):
return x**y return x**y
...@@ -6896,10 +6896,17 @@ class T_Power(): ...@@ -6896,10 +6896,17 @@ class T_Power():
def test_multiple_power(self): def test_multiple_power(self):
x = tensor.matrix() x = tensor.matrix()
y = [1, 2, 3] y = [1, 2, 3]
z = power(x,y) z = power(x, y)
f = function([x], z) f = function([x], z)
assert allclose(f([1, 2, 3]), [1, 4, 27]) assert allclose(f([1, 2, 3]), [1, 4, 27])
def test_wrong_shape(self):
x = tensor.matrix()
y = [1, 2, 3]
z = power(x, y)
f = function([x], z)
self.assertRaise(ValueError, f, [1, 2, 3, 4])
""" """
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论