Skip to content

Commit

Permalink
[Input] Replace operator [] by AnyMap::at in Cython
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jun 30, 2020
1 parent e7fff99 commit cd0e93b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion interfaces/cython/cantera/_cantera.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ cdef extern from "cantera/base/AnyMap.h" namespace "Cantera":

cdef cppclass CxxAnyMap "Cantera::AnyMap":
CxxAnyMap()
CxxAnyValue& operator[](string) except +translate_exception
CxxAnyValue& at(string) except +translate_exception
string keys_str()

Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/reaction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ cdef class Reaction:
if kinetics is None:
raise ValueError("A Kinetics object is required.")
root = AnyMapFromYamlFile(stringify(filename))
cxx_reactions = CxxGetReactions(root[stringify(section)],
cxx_reactions = CxxGetReactions(root.at(stringify(section)),
deref(kinetics.kinetics))
else:
cxx_reactions = CxxGetReactions(deref(CxxGetXmlFile(stringify(filename))))
Expand Down Expand Up @@ -184,7 +184,7 @@ cdef class Reaction:
YAML string.
"""
root = AnyMapFromYamlString(stringify(text))
cxx_reactions = CxxGetReactions(root[stringify("items")],
cxx_reactions = CxxGetReactions(root.at(stringify("items")),
deref(kinetics.kinetics))
return [wrapReaction(r) for r in cxx_reactions]

Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/thermo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cdef class Species:
"""
if filename.lower().split('.')[-1] in ('yml', 'yaml'):
root = AnyMapFromYamlFile(stringify(filename))
cxx_species = CxxGetSpecies(root[stringify(section)])
cxx_species = CxxGetSpecies(root.at(stringify(section)))
else:
cxx_species = CxxGetSpecies(deref(CxxGetXmlFile(stringify(filename))))

Expand Down Expand Up @@ -201,7 +201,7 @@ cdef class Species:

# ``items`` is the pseudo-key used to access a list when it is at the
# top level of a YAML document
cxx_species = CxxGetSpecies(root[stringify(section or "items")])
cxx_species = CxxGetSpecies(root.at(stringify(section or "items")))
species = []
for a in cxx_species:
b = Species(init=False)
Expand Down

0 comments on commit cd0e93b

Please sign in to comment.