[SciPy-user] numpy weave problems resolved

Christian Kristukat ckkart at hoc.net
Sat Feb 18 09:36:02 CST 2006


Hi,
some weeks ago I reported problems with the new numpy/weave when using the
automatic type conversion. I finally boiled it down to some few lines which
demonstrate the problem:

import scipy.weave as weave
from scipy.weave import converters
import numpy
code = """
double c = a2(ind(2),0);
"""
ind = numpy.array([0,3,2])
#ind = numpy.array([0,3,2],'i')
a2 = numpy.arange(9)
a2 = numpy.reshape(a2,(3,3))
weave.inline(code, ['a2','ind'], type_converters=converters.blitz)

I found out that you cannot use the elements of an integer array to index
another array if the former is not explicitly set to dtype='i'. Thus, if you
uncomment the second array intialization above, the code compiles and runs. Once
compiled, however, you can remove the dtype argument again. Apparently the types
are compatible during runtime, but the compiler is checking compatibility more
strictly. I'd prefer a relaxed type checking, if possible.

Regards, Christian



More information about the SciPy-user mailing list