// This case shouldn't happen, based on what I see in Subscript
// This case shouldn't happen, based on what I see in Subscript
// but just in case it happens sometime in the future
// but just in case it happens sometime in the future
PyErr_Format(PyExc_RuntimeError,"__getitem__ must return a CudaNdarray that refers to the original CudaNdarray, not a copy. rval.base=%p o.base=%p o=%p",
PyErr_Format(PyExc_RuntimeError,
"__getitem__ must return a CudaNdarray that refers to"
" the original CudaNdarray, not a copy. rval.base=%p"
if(verbose)fprintf(stderr,"CudaNdarray_setitem dest is a CudaNdarray and value is a ndarray\n");
if(verbose)
fprintf(stderr,
"CudaNdarray_setitem dest is a CudaNdarray and"
" value is a ndarray\n");
inttypenum=PyArray_TYPE(value);
inttypenum=PyArray_TYPE(value);
if(typenum!=REAL_TYPENUM){
if(typenum!=REAL_TYPENUM){
PyErr_SetString(PyExc_TypeError,"CudaNdarray.__setitem__: can only copy from float32 arrays");
PyErr_SetString(PyExc_TypeError,
"CudaNdarray.__setitem__: can only copy from"
" float32 arrays");
Py_XDECREF(rval);
Py_XDECREF(rval);
return-1;
return-1;
}
}
if(!CudaNdarray_is_c_contiguous(rval)){
if(!CudaNdarray_is_c_contiguous(rval)){
PyErr_SetString(PyExc_NotImplementedError,"CudaNdarray.__setitem__: When the new value is an ndarray the part where we copy it to must be c contiguous.");
PyErr_SetString(PyExc_NotImplementedError,
"CudaNdarray.__setitem__: When the new value is"
" an ndarray the part where we copy it to must be"
" c contiguous.");
Py_XDECREF(rval);
Py_XDECREF(rval);
return-1;
return-1;
}
}
if(rval->nd!=((PyArrayObject*)value)->nd){
if(rval->nd!=((PyArrayObject*)value)->nd){
PyErr_Format(PyExc_NotImplementedError,"CudaNdarray.__setitem__: need same number of dims. destination nd=%d, source nd=%d. broadcasting implemented only for zeroing values from python scalar.",
PyErr_Format(PyExc_NotImplementedError,
"CudaNdarray.__setitem__: need same number of dims."
PyErr_SetString(PyExc_TypeError,"CudaNdarray.__setitem__: left must be a CudaNdarrays and right must be a CudaNdarrays, an ndarray or a python scalar of value 0.");
PyErr_SetString(PyExc_TypeError,
"CudaNdarray.__setitem__: left must be a CudaNdarrays and right"
" must be a CudaNdarrays, an ndarray or a python scalar of value 0.");
return-1;
return-1;
}
}
if(verbose)fprintf(stderr,"CudaNdarray_setitem dest and value are CudaNdarray\n");
if(verbose)
fprintf(stderr,"CudaNdarray_setitem dest and value are CudaNdarray\n");
if(cnda_copy_structure_to_device(rval))
if(cnda_copy_structure_to_device(rval))
{
{
PyErr_SetString(PyExc_RuntimeError,"CudaNdarray.__setitem__: syncing structure to device failed");
PyErr_SetString(PyExc_RuntimeError,
"CudaNdarray.__setitem__: syncing structure to device failed");