Skip to content

Commit

Permalink
Use FutureWarning for deprecated keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingmar Schoegl committed Aug 18, 2019
1 parent b5ca2bf commit 0c51834
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
10 changes: 4 additions & 6 deletions interfaces/cython/cantera/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ 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:
if len(adjacent)>0:
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)
Expand Down
24 changes: 12 additions & 12 deletions interfaces/cython/cantera/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ 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
constituting information already exists, the name is automatically appended
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)
Expand Down Expand Up @@ -89,9 +89,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',)
Expand Down Expand Up @@ -316,7 +316,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
Expand Down

0 comments on commit 0c51834

Please sign in to comment.