From af3e34ccb0862af2e717e676b12516157896d420 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 24 May 2015 19:45:26 -0400 Subject: [PATCH] [Python] Add repr functions to Species/Reaction classes --- interfaces/cython/cantera/reaction.pyx | 11 +++++++++++ interfaces/cython/cantera/thermo.pyx | 3 +++ 2 files changed, 14 insertions(+) diff --git a/interfaces/cython/cantera/reaction.pyx b/interfaces/cython/cantera/reaction.pyx index 36938cc61..7d335986a 100644 --- a/interfaces/cython/cantera/reaction.pyx +++ b/interfaces/cython/cantera/reaction.pyx @@ -224,6 +224,12 @@ cdef class Reaction: def __set__(self, allow): self.reaction.allow_negative_orders = allow + def __repr__(self): + return '<{}: {}>'.format(self.__class__.__name__, self.equation) + + def __str__(self): + return self.equation + cdef class Arrhenius: r""" @@ -268,6 +274,11 @@ cdef class Arrhenius: def __get__(self): return self.rate.activationEnergy_R() * gas_constant + def __repr__(self): + return 'Arrhenius(A={:g}, b={:g}, E={:g})'.format( + self.pre_exponential_factor, self.temperature_exponent, + self.activation_energy) + cdef wrapArrhenius(CxxArrhenius* rate, Reaction reaction): r = Arrhenius(init=False) diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 9427b4383..73462ec53 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -198,6 +198,9 @@ cdef class Species: def __set__(self, GasTransportData tran): self.species.transport = tran._data + def __repr__(self): + return ''.format(self.name) + cdef class ThermoPhase(_SolutionBase): """