diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-03-17 09:48:17 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-03-17 09:48:17 +0000 |
commit | 116482559bc3a3856022b0a7b25429605d351c02 (patch) | |
tree | 9d15e961ae5f141342a6c07d6341c16592e6eb18 /numpy/core/src/arrayobject.c | |
parent | 178049619a9ae83860977e8cec27ecb281569a28 (diff) | |
download | numpy-116482559bc3a3856022b0a7b25429605d351c02.tar.gz |
Add coercion test for scalar objects.
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r-- | numpy/core/src/arrayobject.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 859a4d79e..cf14b350e 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -6711,6 +6711,21 @@ PyArray_CanCastTo(PyArray_Descr *from, PyArray_Descr *to) return ret; } +/*OBJECT_API + See if array scalars can be cast. + */ +static Bool +PyArray_CanCastScalar(PyTypeObject *from, PyTypeObject *to) +{ + int fromtype; + int totype; + + fromtype = _typenum_fromtypeobj((PyObject *)from, 0); + totype = _typenum_fromtypeobj((PyObject *)to, 0); + if (fromtype == PyArray_NOTYPE || totype == PyArray_NOTYPE) + return FALSE; + return (Bool) PyArray_CanCastSafely(fromtype, totype); +} /*********************** Element-wise Array Iterator ***********************/ |