From 695b6b126619b64a94fea12a93e045006313e055 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 26 Dec 2012 23:55:54 +0000 Subject: [PATCH] [Cython] Skip sensitivity-related tests when Sundials is not present --- interfaces/cython/cantera/__init__.py | 2 +- interfaces/cython/cantera/_cantera.pxd | 2 ++ interfaces/cython/cantera/test/test_reactor.py | 3 +++ interfaces/cython/cantera/utils.pyx | 3 +++ interfaces/cython/cantera/wrappers.h | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/__init__.py b/interfaces/cython/cantera/__init__.py index a70076b18..d5b796035 100644 --- a/interfaces/cython/cantera/__init__.py +++ b/interfaces/cython/cantera/__init__.py @@ -1,5 +1,5 @@ from ._cantera import * -from ._cantera import __version__ +from ._cantera import __version__, _have_sundials from .liquidvapor import * import os as _os diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 8e26bda34..5400e15b2 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -426,6 +426,8 @@ cdef extern from "cantera/oneD/Sim1D.h": cdef extern from "wrappers.h": # config definitions cdef string get_cantera_version() + cdef int get_sundials_version() + # ThermoPhase composition cdef void thermo_getMassFractions(CxxThermoPhase*, double*) except + cdef void thermo_setMassFractions(CxxThermoPhase*, double*) except + diff --git a/interfaces/cython/cantera/test/test_reactor.py b/interfaces/cython/cantera/test/test_reactor.py index d53c0444a..76e5bae3f 100644 --- a/interfaces/cython/cantera/test/test_reactor.py +++ b/interfaces/cython/cantera/test/test_reactor.py @@ -1,4 +1,5 @@ import numpy as np +import unittest import re import cantera as ct @@ -530,6 +531,8 @@ class TestWallKinetics(utilities.CanteraTest): self.assertArrayNear(C_left, C_right) +@unittest.skipUnless(ct._have_sundials(), + "Sensitivity calculations require Sundials") class TestReactorSensitivities(utilities.CanteraTest): def test_sensitivities1(self): net = ct.ReactorNet() diff --git a/interfaces/cython/cantera/utils.pyx b/interfaces/cython/cantera/utils.pyx index 1650ee623..634181c2e 100644 --- a/interfaces/cython/cantera/utils.pyx +++ b/interfaces/cython/cantera/utils.pyx @@ -19,4 +19,7 @@ cdef pystr(string x): def addDirectory(directory): CxxAddDirectory(stringify(directory)) +def _have_sundials(): + return bool(get_sundials_version()) + __version__ = pystr(get_cantera_version()) diff --git a/interfaces/cython/cantera/wrappers.h b/interfaces/cython/cantera/wrappers.h index 5a90bcf47..c844ac242 100644 --- a/interfaces/cython/cantera/wrappers.h +++ b/interfaces/cython/cantera/wrappers.h @@ -8,6 +8,11 @@ std::string get_cantera_version() return std::string(CANTERA_VERSION); } +int get_sundials_version() +{ + return SUNDIALS_VERSION; +} + // Function which populates a 1D array #define ARRAY_FUNC(PREFIX, CLASS_NAME, FUNC_NAME) \ void PREFIX ## _ ## FUNC_NAME(Cantera::CLASS_NAME* object, double* data) \