[Python] ThermoPhase.species() returns all Species objects
This commit is contained in:
parent
808f088ffd
commit
859aee18ef
2 changed files with 13 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue