diff --git a/interfaces/cython/cantera/base.pyx b/interfaces/cython/cantera/base.pyx index dfc14c85e..d1a3021c0 100644 --- a/interfaces/cython/cantera/base.pyx +++ b/interfaces/cython/cantera/base.pyx @@ -70,7 +70,7 @@ cdef class _SolutionBase: def __get__(self): return list(self._selectedSpecies) def __set__(self, species): - if isinstance(species, (str, int)): + if isinstance(species, (str, unicode, int)): species = (species,) self._selectedSpecies.resize(len(species)) for i,spec in enumerate(species): diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index 636cd8103..b37a619da 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -178,7 +178,7 @@ cdef class Boundary1D(Domain1D): """ Species mole fractions at this boundary. """ def __set__(self, X): cdef np.ndarray[np.double_t, ndim=1] data - if isinstance(X, str): + if isinstance(X, (str, unicode)): self.boundary.setMoleFractions(stringify(X)) else: data = np.ascontiguousarray(X, dtype=np.double) @@ -457,7 +457,7 @@ cdef class Sim1D: def _get_indices(self, dom, comp): idom = self.domainIndex(dom) dom = self.domains[idom] - if isinstance(comp, str): + if isinstance(comp, (str, unicode)): kcomp = dom.componentIndex(comp) else: kcomp = comp diff --git a/interfaces/cython/cantera/reactor.pyx b/interfaces/cython/cantera/reactor.pyx index bf2db02c8..febc42a9b 100644 --- a/interfaces/cython/cantera/reactor.pyx +++ b/interfaces/cython/cantera/reactor.pyx @@ -774,7 +774,7 @@ cdef class ReactorNet: def sensitivity(self, species, int p, int r=0): if isinstance(species, int): return self.net.sensitivity(species,p) - elif isinstance(species, str): + elif isinstance(species, (str, unicode)): return self.net.sensitivity(stringify(species), p, r) def sensitivities(self): diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index c863ab8e3..63d6991eb 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -146,7 +146,7 @@ cdef class ThermoPhase(_SolutionBase): an integer. In the latter case, the index is checked for validity and returned. If no such element is present, an exception is thrown. """ - if isinstance(element, str): + if isinstance(element, (str, unicode)): index = self.thermo.elementIndex(stringify(element)) elif isinstance(element, (int, float)): index = element @@ -191,7 +191,7 @@ cdef class ThermoPhase(_SolutionBase): an integer. In the latter case, the index is checked for validity and returned. If no such species is present, an exception is thrown. """ - if isinstance(species, str): + if isinstance(species, (str, unicode)): index = self.thermo.speciesIndex(stringify(species)) elif isinstance(species, (int, float)): index = species @@ -253,7 +253,7 @@ cdef class ThermoPhase(_SolutionBase): def __get__(self): return self._getArray1(thermo_getMassFractions) def __set__(self, Y): - if isinstance(Y, str): + if isinstance(Y, (str, unicode)): self.thermo.setMassFractionsByName(stringify(Y)) else: self._setArray1(thermo_setMassFractions, Y) @@ -272,7 +272,7 @@ cdef class ThermoPhase(_SolutionBase): def __get__(self): return self._getArray1(thermo_getMoleFractions) def __set__(self, X): - if isinstance(X, str): + if isinstance(X, (str, unicode)): self.thermo.setMoleFractionsByName(stringify(X)) else: self._setArray1(thermo_setMoleFractions, X)