summaryrefslogtreecommitdiff
path: root/scipy/weave/standard_array_spec.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2005-10-26 04:52:01 +0000
committerTravis Oliphant <oliphant@enthought.com>2005-10-26 04:52:01 +0000
commit146140cce09b455477d56c06df22aafe647ae6c6 (patch)
treed9b2a77d1787a3ef33abf571bfc0260b4f9f1954 /scipy/weave/standard_array_spec.py
parent98830f76c36d104d8bd18d2c794500f51ba645b2 (diff)
downloadnumpy-146140cce09b455477d56c06df22aafe647ae6c6.tar.gz
Added more types to weave.
Diffstat (limited to 'scipy/weave/standard_array_spec.py')
-rw-r--r--scipy/weave/standard_array_spec.py67
1 files changed, 39 insertions, 28 deletions
diff --git a/scipy/weave/standard_array_spec.py b/scipy/weave/standard_array_spec.py
index 261aeb3a5..927425301 100644
--- a/scipy/weave/standard_array_spec.py
+++ b/scipy/weave/standard_array_spec.py
@@ -6,17 +6,23 @@ import os
num_typecode = {}
-num_typecode['b'] = 'PyArray_SBYTE'
+num_typecode['?'] = 'PyArray_BOOL'
+num_typecode['b'] = 'PyArray_BYTE'
num_typecode['B'] = 'PyArray_UBYTE'
num_typecode['h'] = 'PyArray_SHORT'
num_typecode['H'] = 'PyArray_USHORT'
-num_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??
+num_typecode['i'] = 'PyArray_INT'
num_typecode['I'] = 'PyArray_UINT'
num_typecode['l'] = 'PyArray_LONG'
+num_typecode['L'] = 'PyArray_ULONG'
+num_typecode['q'] = 'PyArray_LONGLONG'
+num_typecode['Q'] = 'PyArray_ULONGLONG'
num_typecode['f'] = 'PyArray_FLOAT'
num_typecode['d'] = 'PyArray_DOUBLE'
+num_typecode['g'] = 'PyArray_LONGDOUBLE'
num_typecode['F'] = 'PyArray_CFLOAT'
num_typecode['D'] = 'PyArray_CDOUBLE'
+num_typecode['G'] = 'PyArray_CLONGDOUBLE'
type_check_code = \
"""
@@ -27,24 +33,26 @@ public:
const char* name)
{
// Make sure input has correct numeric type.
- // allow character and byte to match
- // also allow int and long to match
int arr_type = arr_obj->descr->type_num;
- if ( arr_type != numeric_type &&
- !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&
- !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&
- !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&
- !(numeric_type == PyArray_LONG && arr_type == PyArray_INT))
+ if (PyTypeNum_ISEXTENDED(numeric_type))
{
-
- char* type_names[20] = {"char","unsigned byte","byte", "short", "unsigned short",
- "int", "unsigned int", "long", "float", "double",
- "complex float","complex double", "object","ntype",
- "unkown"};
- char msg[500];
- sprintf(msg,"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'",
- type_names[arr_type],type_names[numeric_type],name);
- throw_error(PyExc_TypeError,msg);
+ char msg[80];
+ sprintf(msg, "Conversion Error: extended types not supported for variable '%s'",
+ name);
+ throw_error(PyExc_TypeError, msg);
+ }
+ if (!PyArray_EquivalentTypenums(arr_type, numeric_type))
+ {
+
+ char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort",
+ "int", "uint", "long", "ulong", "longlong", "ulonglong",
+ "float", "double", "longdouble", "cfloat", "cdouble",
+ "clongdouble", "object", "string", "unicode", "void", "ntype",
+ "unkown"};
+ char msg[500];
+ sprintf(msg,"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'",
+ type_names[arr_type],type_names[numeric_type],name);
+ throw_error(PyExc_TypeError,msg);
}
}
@@ -52,17 +60,20 @@ public:
{
// Make sure input has correct numeric type.
int arr_type = arr_obj->descr->type_num;
- if ( arr_type != numeric_type &&
- !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&
- !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&
- !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&
- !(numeric_type == PyArray_LONG && arr_type == PyArray_INT))
+ if (PyTypeNum_ISEXTENDED(numeric_type))
{
- char* type_names[20] = {"char","unsigned byte","byte", "short",
- "unsigned short", "int", "unsigned int",
- "long", "float", "double",
- "complex float", "complex double",
- "object","ntype","unkown"};
+ char msg[80];
+ sprintf(msg, "Conversion Error: extended types not supported for variable '%s'",
+ name);
+ throw_error(PyExc_TypeError, msg);
+ }
+ if (!PyArray_EquivalentTypenums(arr_type, numeric_type))
+ {
+ char* type_names[23] = {"bool", "byte", "ubyte","short", "ushort",
+ "int", "uint", "long", "ulong", "longlong", "ulonglong",
+ "float", "double", "longdouble", "cfloat", "cdouble",
+ "clongdouble", "object", "string", "unicode", "void", "ntype",
+ "unkown"};
char msg[500];
sprintf(msg,"received '%s' typed array instead of '%s' typed array for variable '%s'",
type_names[arr_type],type_names[numeric_type],name);