diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 023df57b7..58c0dc980 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -693,6 +693,10 @@ class TestSpecies(utilities.CanteraTest): for m,n in s.composition.items(): self.assertEqual(n, self.gas.n_atoms(k,m)) + def test_species_noargs(self): + for k,s in enumerate(self.gas.species()): + self.assertEqual(s.name, self.gas.species_name(k)) + def test_name_accessor(self): for name in self.gas.species_names: s = self.gas.species(name) diff --git a/interfaces/cython/cantera/thermo.pyx b/interfaces/cython/cantera/thermo.pyx index 8d46eef15..e2c391592 100644 --- a/interfaces/cython/cantera/thermo.pyx +++ b/interfaces/cython/cantera/thermo.pyx @@ -425,7 +425,15 @@ cdef class ThermoPhase(_SolutionBase): return index - def species(self, k): + def species(self, k=None): + """ + Return the `Species` object for species *k*, where *k* is either the + species index or the species name. If *k* is not specified, a list of + all species objects is returned. + """ + if k is None: + return [self.species(i) for i in range(self.n_species)] + s = Species(init=False) if isinstance(k, (str, unicode, bytes)): s._assign(self.thermo.species(stringify(k)))