[Python] Return 'None' if thermo or transport are undefined
This commit is contained in:
parent
a4252480aa
commit
658ce5d73b
2 changed files with 13 additions and 4 deletions
|
|
@ -682,6 +682,9 @@ class TestSpecies(utilities.CanteraTest):
|
|||
self.assertEqual(s.size, 1.0)
|
||||
self.assertEqual(s.charge, 0.0)
|
||||
|
||||
self.assertIsNone(s.thermo)
|
||||
self.assertIsNone(s.transport)
|
||||
|
||||
def test_index_accessor(self):
|
||||
for k in range(self.gas.n_species):
|
||||
s = self.gas.species(k)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,10 @@ cdef class Species:
|
|||
of class `SpeciesThermo`.
|
||||
"""
|
||||
def __get__(self):
|
||||
return wrapSpeciesThermo(self.species.thermo)
|
||||
if self.species.thermo.get() != NULL:
|
||||
return wrapSpeciesThermo(self.species.thermo)
|
||||
else:
|
||||
return None
|
||||
|
||||
def __set__(self, SpeciesThermo spthermo):
|
||||
self.species.thermo = spthermo._spthermo
|
||||
|
|
@ -164,9 +167,12 @@ cdef class Species:
|
|||
`GasTransportData`.
|
||||
"""
|
||||
def __get__(self):
|
||||
data = GasTransportData(init=False)
|
||||
data._assign(self.species.transport)
|
||||
return data
|
||||
if self.species.transport.get() != NULL:
|
||||
data = GasTransportData(init=False)
|
||||
data._assign(self.species.transport)
|
||||
return data
|
||||
else:
|
||||
return None
|
||||
def __set__(self, GasTransportData tran):
|
||||
self.species.transport = tran._data
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue