diff options
author | Eric Jones <eric@enthought.com> | 2002-07-19 07:21:47 +0000 |
---|---|---|
committer | Eric Jones <eric@enthought.com> | 2002-07-19 07:21:47 +0000 |
commit | 5cddedde399c88527e44b14bb34b629e929e045e (patch) | |
tree | 4c7e691e424443a0086e01ddfc037f378087926a /weave/standard_array_spec.py | |
parent | c74893465cedbbab2a8d665990364c4ee71a0ea9 (diff) | |
download | numpy-5cddedde399c88527e44b14bb34b629e929e045e.tar.gz |
standard array conversions were not checking the array type. As a result,
code compiled for a float array would execute even if handed a int array.
bad. bad. bad. Type checks on standard array conversions are now done.
Note, though, that standard array conversions don't check for array shape,
so a 2D array handed into code originally compiled for a 3D array will
execute just fine. This is desired in some cases and not in others. Its
currently up to the user to protect against the undesired cases.
Diffstat (limited to 'weave/standard_array_spec.py')
-rw-r--r-- | weave/standard_array_spec.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/weave/standard_array_spec.py b/weave/standard_array_spec.py index 3c3ae55e2..181b72f18 100644 --- a/weave/standard_array_spec.py +++ b/weave/standard_array_spec.py @@ -30,10 +30,12 @@ class array_converter(base_converter): def inline_decl_code(self): type = numeric_to_c_type_mapping[self.numeric_type] name = self.name + #dims = self.dims var_name = self.retrieve_py_variable(inline=1) templ = '// %(name)s array declaration\n' \ 'py_%(name)s= %(var_name)s;\n' \ 'PyArrayObject* %(name)s = convert_to_numpy(py_%(name)s,"%(name)s");\n' \ + 'conversion_numpy_check_type(%(name)s,py_type<%(type)s>::code,"%(name)s");\n' \ 'int* _N%(name)s = %(name)s->dimensions;\n' \ 'int* _S%(name)s = %(name)s->strides;\n' \ 'int _D%(name)s = %(name)s->nd;\n' \ @@ -46,6 +48,7 @@ class array_converter(base_converter): name = self.name templ = '// %(name)s array declaration\n' \ 'PyArrayObject* %(name)s = convert_to_numpy(py_%(name)s,"%(name)s");\n' \ + 'conversion_numpy_check_type(%(name)s,py_type<%(type)s>::code,"%(name)s");\n' \ 'int* _N%(name)s = %(name)s->dimensions;\n' \ 'int* _S%(name)s = %(name)s->strides;\n' \ 'int _D%(name)s = %(name)s->nd;\n' \ |