提交 595871eb authored 作者: Frederic Bastien's avatar Frederic Bastien

changed Error type to be the same as numpy or more meaningfull.

上级 b0bf8695
...@@ -2137,7 +2137,7 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self, CudaNdarray * other, boo ...@@ -2137,7 +2137,7 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self, CudaNdarray * other, boo
} }
if (self->nd != other->nd) if (self->nd != other->nd)
{ {
PyErr_Format(PyExc_TypeError, "need same number of dims. destination nd=%d, source nd=%d", self->nd, other->nd); PyErr_Format(PyExc_NotImplementedError, "need same number of dims. destination nd=%d, source nd=%d. No broadcasting implemented.", self->nd, other->nd);
return -1; return -1;
} }
//standard elemwise dim checks (also compute total size) //standard elemwise dim checks (also compute total size)
...@@ -2148,7 +2148,7 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self, CudaNdarray * other, boo ...@@ -2148,7 +2148,7 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self, CudaNdarray * other, boo
if ((CudaNdarray_HOST_DIMS(self)[i] != CudaNdarray_HOST_DIMS(other)[i]) if ((CudaNdarray_HOST_DIMS(self)[i] != CudaNdarray_HOST_DIMS(other)[i])
&& (1!=CudaNdarray_HOST_DIMS(other)[i] || !unbroadcast) ) && (1!=CudaNdarray_HOST_DIMS(other)[i] || !unbroadcast) )
{ {
PyErr_Format(PyExc_TypeError, "need same dimensions for dim %d, destination=%d, source=%d", PyErr_Format(PyExc_ValueError, "need same dimensions for dim %d, destination=%d, source=%d",
i, CudaNdarray_HOST_DIMS(self)[i], CudaNdarray_HOST_DIMS(other)[i]); i, CudaNdarray_HOST_DIMS(self)[i], CudaNdarray_HOST_DIMS(other)[i]);
return -1; return -1;
} }
......
...@@ -426,7 +426,7 @@ def test_setitem_matrix_bad_shape(): ...@@ -426,7 +426,7 @@ def test_setitem_matrix_bad_shape():
# attempt to assign the ndarray b with setitem # attempt to assign the ndarray b with setitem
_a[:,:,1] = _b _a[:,:,1] = _b
assert False assert False
except TypeError, e: except ValueError, e:
#print e #print e
assert True assert True
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论