From 54315d4472d0055fdd131e0789d8e708058dd66a Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 14 Dec 2011 01:47:40 +0000 Subject: [PATCH] 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. --- Cantera/python/Cantera/Func.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Cantera/python/Cantera/Func.py b/Cantera/python/Cantera/Func.py index 068dcd1c9..b9ebc3416 100644 --- a/Cantera/python/Cantera/Func.py +++ b/Cantera/python/Cantera/Func.py @@ -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):