Fixed segfault in Func module when using numpy

The C++ py_func_new function assumes it's being passed a 1-dimensional
array, but numpy generates 0-dimensional arrays for scalar inputs to
array / asarray, e.g. when using Func.Sin.
This commit is contained in:
Ray Speth 2011-12-14 01:47:40 +00:00
parent 5e81697129
commit 54315d4472

View file

@ -43,7 +43,10 @@ class Func1:
self._own = 1
self._func_id = 0
self._typ = typ
self.coeffs = asarray(coeffs,'d')
if _cantera.nummod == 'numpy':
self.coeffs = array(coeffs, dtype=float, ndmin=1)
else:
self.coeffs = asarray(coeffs,'d')
self._func_id = _cantera.func_new(typ, n, self.coeffs)
def __del__(self):