[Base] use FutureWarning for deprecated keywords
This commit is contained in:
parent
fef352b9d5
commit
af04f97d0e
3 changed files with 18 additions and 20 deletions
|
|
@ -14,9 +14,8 @@ cdef class _SolutionBase:
|
|||
if phase is not '':
|
||||
raise AttributeError('duplicate specification of phase name')
|
||||
|
||||
warnings.warn("To be removed after Cantera 2.5. "
|
||||
"Keyword `phaseid` is replaced by `phase`",
|
||||
DeprecationWarning)
|
||||
warnings.warn("Keyword `phase` replaces `phaseid`",
|
||||
FutureWarning)
|
||||
phase = kwargs['phaseid']
|
||||
|
||||
if 'phases' in kwargs:
|
||||
|
|
@ -24,9 +23,8 @@ cdef class _SolutionBase:
|
|||
raise AttributeError(
|
||||
'duplicate specification of adjacent phases')
|
||||
|
||||
warnings.warn("To be removed after Cantera 2.5. "
|
||||
"Keyword `phases` is replaced by `adjacent`",
|
||||
DeprecationWarning)
|
||||
warnings.warn("Keyword `adjacent` replaces `phases`",
|
||||
FutureWarning)
|
||||
adjacent = kwargs['phases']
|
||||
|
||||
# Shallow copy of an existing Solution (for slicing support)
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ class Solution(ThermoPhase, Kinetics, Transport):
|
|||
The most common way to instantiate `Solution` objects is by using a phase
|
||||
definition, species and reactions defined in an input file::
|
||||
|
||||
gas = ct.Solution('gri30.cti')
|
||||
gas = ct.Solution('gri30.yaml')
|
||||
|
||||
If an input file defines multiple phases, the phase *name* (in CTI), *id*
|
||||
(in XML) or *phases* entry (in YAML) can be used to specify the desired
|
||||
If an input file defines multiple phases, the *phases* entry (in YAML),
|
||||
*name* (in CTI), or *id* (in XML) can be used to specify the desired
|
||||
phase via the ``phase`` keyword argument of the constructor::
|
||||
|
||||
gas = ct.Solution('diamond.cti', phase='gas')
|
||||
diamond = ct.Solution('diamond.cti', phase='diamond')
|
||||
gas = ct.Solution('diamond.yaml', phase='gas')
|
||||
diamond = ct.Solution('diamond.yaml', phase='diamond')
|
||||
|
||||
The name of the `Solution` object needs to be unique and defaults to the
|
||||
*phase* specified in the input file. If another object using the same
|
||||
|
|
@ -44,14 +44,14 @@ class Solution(ThermoPhase, Kinetics, Transport):
|
|||
by a suffix. A custom name can be set via the ``name`` keyword argument of
|
||||
the constructor, i.e.::
|
||||
|
||||
gas = ct.Solution('gri30.cti', name='my_custom_name')
|
||||
gas = ct.Solution('gri30.yaml', name='my_custom_name')
|
||||
|
||||
`Solution` objects can also be constructed using `Species` and `Reaction`
|
||||
objects which can themselves either be imported from input files or defined
|
||||
directly in Python::
|
||||
|
||||
spec = ct.Species.listFromFile('gri30.cti')
|
||||
rxns = ct.Reaction.listFromFile('gri30.cti')
|
||||
spec = ct.Species.listFromFile('gri30.yaml')
|
||||
rxns = ct.Reaction.listFromFile('gri30.yaml')
|
||||
gas = ct.Solution(thermo='IdealGas', kinetics='GasKinetics',
|
||||
species=spec, reactions=rxns)
|
||||
|
||||
|
|
@ -95,9 +95,9 @@ class Interface(InterfacePhase, InterfaceKinetics):
|
|||
in reactions need to be created and then passed in as a list in the
|
||||
``adjacent`` argument to the constructor::
|
||||
|
||||
gas = ct.Solution('diamond.cti', phase='gas')
|
||||
diamond = ct.Solution('diamond.cti', phase='diamond')
|
||||
diamond_surf = ct.Interface('diamond.cti', phase='diamond_100',
|
||||
gas = ct.Solution('diamond.yaml', phase='gas')
|
||||
diamond = ct.Solution('diamond.yaml', phase='diamond')
|
||||
diamond_surf = ct.Interface('diamond.yaml', phase='diamond_100',
|
||||
adjacent=[gas, diamond])
|
||||
"""
|
||||
__slots__ = ('_phase_indices',)
|
||||
|
|
@ -322,7 +322,7 @@ class SolutionArray:
|
|||
with shapes described in the same way as Numpy arrays. All of the states
|
||||
can be set in a single call::
|
||||
|
||||
>>> gas = ct.Solution('gri30.cti')
|
||||
>>> gas = ct.Solution('gri30.yaml')
|
||||
>>> states = ct.SolutionArray(gas, (6, 10))
|
||||
>>> T = np.linspace(300, 1000, 10) # row vector
|
||||
>>> P = ct.one_atm * np.linspace(0.1, 5.0, 6)[:,np.newaxis] # column vector
|
||||
|
|
|
|||
|
|
@ -346,8 +346,8 @@ class TestThermoPhase(utilities.CanteraTest):
|
|||
with warnings.catch_warnings(record=True) as w:
|
||||
gas = ct.Solution('h2o2.cti', phaseid='ohmech')
|
||||
self.assertTrue(len(w) == 1)
|
||||
self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
|
||||
self.assertTrue("To be removed after Cantera 2.5. "
|
||||
self.assertTrue(issubclass(w[-1].category, FutureWarning))
|
||||
self.assertTrue("Keyword `phase` replaces `phaseid`"
|
||||
in str(w[-1].message))
|
||||
|
||||
def test_badLength(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue