-
-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YamlWriter / yaml2ck issues with 'note' field parsed as integer #1610
Comments
I am not convinced of this conclusion. Per discussion when YAML was first introduced, there should not be anything canonical in terms of reserved field names (the field The alternative would be to convert integers to a string in Just 2 cents of course ... |
I believe the original NASA spec for this format calls for the field in these positions to be a string. In that sense, the int conversion is an artifact of the YAML parser we use/the YAML specification when the file is loaded in the first place. I think the fix is to write that field out as a string always (that is, with explicit quotes in the YAML file) and explicitly cast to a string in the yaml2ck side. See also, putting quotes around major.minor semantic version numbers in YAML files, lest they be read as floats by a parser. Edit: based on your edit, I believe we agree @ischoegl 😀 |
@bryanwweber ... happy to agree! Fwiw, I had a really curious 'bug' in a YAML file once, where a git hash ended up being a valid integer (I guess I was pretty 'lucky'). So string round-trip conversion in YAML is not reliable - you can write out a string and get back an integer any time you don't use quotes. PS: this is exactly what happens in the example at the top. |
I added a (partial/band-aid) fix to #1616, which takes care of the exception, but not the inadvertent type conversion. One thing that is now clear to me is is that |
Removing ‘bug’ label as the band-aid fix prevents failures. |
Problem description
There are a pair of coupled problems with species'
note
fields in cases where that field could be (but should not be) interpreted as an integer, for example120186
, which if you're psychic you might guess is the date December 1, 1986. Or maybe January 12, 1986. Or maybe something else entirely. In any case, Cantera should just preserve this as a string.Steps to reproduce
In Python:
Looking at the resulting YAML file shows that this value has been converted to an integer:
which is inconsistent, but not necessarily a significant problem. However, trying to convert this to a Chemkin file:
fails with the error:
System information
Additional context
Originally reported on the Cantera Users' Group: https://groups.google.com/g/cantera-users/c/gn_TJt1gspc
The text was updated successfully, but these errors were encountered: