diff --git a/src/base/AnyMap.cpp b/src/base/AnyMap.cpp index f6de2bb8e1..6088faeb75 100644 --- a/src/base/AnyMap.cpp +++ b/src/base/AnyMap.cpp @@ -259,6 +259,9 @@ struct convert { static bool decode(const Node& node, Cantera::AnyMap& target) { target.setLoc(node.Mark().line, node.Mark().column); + if (node.Style() == YAML::EmitterStyle::Flow) { + target.setFlowStyle(); + } if (node.IsSequence()) { // Convert a top-level list to a map with the key "items" target["items"] = node.as(); diff --git a/test/python/test_composite.py b/test/python/test_composite.py index 9678724b51..4cca846c66 100644 --- a/test/python/test_composite.py +++ b/test/python/test_composite.py @@ -2,6 +2,7 @@ import numpy as np import pickle +import re import pytest from .utilities import allow_deprecated @@ -1238,8 +1239,9 @@ def test_yaml_strings(self): gas.species(3).update_user_data({"note": note3}) gas.species(4).update_user_data({"note": note4}) - gas.write_yaml(self.test_work_path / "h2o2-generated-user-header.yaml") - gas2 = ct.Solution(self.test_work_path / "h2o2-generated-user-header.yaml") + generated_file = self.test_work_path / "h2o2-generated-user-header.yaml" + gas.write_yaml(generated_file) + gas2 = ct.Solution(generated_file) # Ideally, multi-line YAML emitter would indicate stripping of the final newline # (element annotated with '|-' instead of just '|') but this doesn't seem to be @@ -1254,6 +1256,11 @@ def test_yaml_strings(self): assert gas2.input_data["extra"]["key1"] == "1.0" assert gas2.input_data["extra"]["key2"] == 2.0 + # User-defined input in flow style should remain in flow style + yaml_gen = generated_file.read_text() + assert re.search("extra:.*key1.*key2", yaml_gen) + + def test_duplicate_reactions(self): gas = ct.Solution('h2o2.yaml', transport_model=None)