diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index b443e59e4..d083810d9 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -7,6 +7,8 @@ from cpython cimport bool as pybool import numpy as np cimport numpy as np +ctypedef stdmap[string,double] Composition + cdef extern from "cantera/base/xml.h" namespace "Cantera": cdef cppclass XML_Node: XML_Node* findByName(string) @@ -56,11 +58,11 @@ cdef extern from "cantera/thermo/SpeciesThermoFactory.h": cdef extern from "cantera/thermo/Species.h" namespace "Cantera": cdef cppclass CxxSpecies "Cantera::Species": CxxSpecies() - CxxSpecies(string, stdmap[string,double]) + CxxSpecies(string, Composition) shared_ptr[CxxSpeciesThermo] thermo string name - stdmap[string,double] composition + Composition composition double charge double size @@ -120,17 +122,17 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera": # composition void setMassFractionsByName(string) except + - void setMassFractionsByName(stdmap[string,double]&) except + + void setMassFractionsByName(Composition&) except + void setMassFractions_NoNorm(double*) except + - stdmap[string,double] getMassFractionsByName(double) + Composition getMassFractionsByName(double) double massFraction(size_t) except + double massFraction(string) except + void setMoleFractionsByName(string) except + - void setMoleFractionsByName(stdmap[string,double]&) except + + void setMoleFractionsByName(Composition&) except + void setMoleFractions_NoNorm(double*) except + void getMoleFractions(double*) except + - stdmap[string,double] getMoleFractionsByName(double) + Composition getMoleFractionsByName(double) double moleFraction(size_t) except + double moleFraction(string) except + diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 61dd4490e..b4f8b41ac 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -5,13 +5,13 @@ cdef enum Thermasis: molar_basis = 1 -cdef stdmap[string,double] comp_map(dict X) except *: - cdef stdmap[string,double] m +cdef Composition comp_map(dict X) except *: + cdef Composition m for species,value in X.items(): m[stringify(species)] = value return m -cdef comp_map_to_dict(stdmap[string,double] m): +cdef comp_map_to_dict(Composition m): return {pystr(species):value for species,value in m.items()}