提交 c5549375 authored 作者: James Bergstra's avatar James Bergstra

AdvIncSubtensor1 - better error message in make_node when incrementing a…

AdvIncSubtensor1 - better error message in make_node when incrementing a selection of lower rank, and test of that error condition
上级 e829f389
......@@ -4919,7 +4919,10 @@ class AdvancedIncSubtensor1(Op):
if x_.type.ndim == 0:
raise TypeError('cannot index into a scalar')
if y_.type.ndim > x_.type.ndim:
raise TypeError('cannot reduce dimensionality of y')
opname = 'increment'
raise TypeError('cannot %s x subtensor with ndim=%s'
' by y with ndim=%s to x subtensor with ndim=%s '%(
opname, x_.type.ndim, y_.type.ndim ))
return Apply(self, [x_, y_, ilist_], [x_.type()])
......
......@@ -2426,6 +2426,9 @@ class TestIncSubtensor1(unittest.TestCase):
aval = f([.4, .9, .1], [1,2])
assert numpy.allclose(aval, [.4, 3.9, 3.1])
def test_assigning_matrix_to_vector_selection(self):
self.assertRaises(TypeError,
lambda : inc_subtensor(self.v[self.adv1q], fmatrix()))
class T_Join_and_Split(unittest.TestCase):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论