From aba0c68744443f55e8c133343f23d0a9f62e4a0c Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Fri, 2 Jun 2006 06:52:33 +0000 Subject: Improve registered ufuncs so that they can coerce data to and from user-defined data-types. Clean-up _SOFFSET_ macro. Make sure that user-defined types always succeed in CanCastSafely. This is a hack but there is currently no way to record this information. --- numpy/core/src/arrayobject.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'numpy/core/src/arrayobject.c') diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 9fbffb3c3..5b51b5c15 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -1118,7 +1118,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) } } else { - destptr = _SOFFSET_(obj, type_num); + destptr = _SOFFSET_(obj); } /* copyswap for OBJECT increments the reference count */ copyswap(destptr, data, swap, base); @@ -7186,6 +7186,12 @@ PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to) stringified value of the object. */ } + if (!ret && (PyTypeNum_ISUSERDEF(fromtype) || \ + PyTypeNum_ISUSERDEF(totype))) { + /* don't restrict casting to and from + additional data-types */ + return TRUE; + } return ret; } -- cgit v1.2.1