make ck2cti more deterministic in it's output #497
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A few simple fixes (sorting of dictionary items) to ensure that ck2cti's output is more deterministic.
The context of this is I have a test mechanism I have in chemkin format, and a (hopefully) identical mechanism in cantera format.
In pyJac we have our own interpreter that can parse either format, so we have unit tests that
1.) Ensure that our own internal data representations of both the parsed chemkin and cantera mechanisms are identical.
2.) Test that converting the chemkin model to cantera format produces the same mechanism as we have stored in our repository -- this is easiest to accomplish via difflib or the like (rather than writing equality functions for Cantera reaction/species classes, although that might be a worthwhile endeavor at some point)
The current issue I'm facing is that often we see different outputs from ck2cti, for example
vs.
IMO the (minor) performance hit of sorting the dictionaries based on the items (effectively, sorting based on the key) is worth having consistent deterministic output :)