Add the ability to have longs in yaml decks
Created by: bathmatt
Moving email thread to github
Currently if I have a param in a yaml deck
foo: 1234567890 it errors out. Here is a discussion from Paul Lin and @ibaned and @rppawlo
My preferred solution is to see if it is > INT_MAX and then read it as a long and then let me grab it that way and use a filter for the long/int stuff.
Thoughts
Yuck. I don’t like any of the solutions. Least favorite is the string thing – it feels like a hack and will probably confuse users. I like the tag better than the string, but then we need to again train users on something that feels hackish. For the INT_MAX solution, we do have a validator object that we can tell it the numeric types to accept and then it automatically converts it to the right type. So we could allow for int, long and long long types and the validator can convert automagically to long long. I feel uneasy about this but after 14 years of PL use and this being the first time this issue crops up probably means it won’t happen much. This might be one question to take to the larger community?
Matt – any preference since EMPIRE is the code in question?
Roger
From: "Ibanez, Daniel Alejandro" <daibane@sandia.gov>
Date: Monday, April 9, 2018 at 9:40 AM
To: Roger Pawlowski <rppawlo@sandia.gov>, Paul Lin <ptlin@sandia.gov>
Subject: Re: Teuchos ParameterLists should not have any trouble with type long (64-bit integer) ?
Yea, 64-bit integers definitely have use cases in our input files…
Without changing the code, you can make it a string type by putting single or double quotes around the value.
Count: ‘2467430400’
I could change the code so the type will be “long long” if the value is bigger than INT_MAX, but then the type depends on the value
I could also add something like int64 as a tag name:
Count: !!int64 2467430400
Let me know what you think,
Dan
From: "Pawlowski, Roger P" <rppawlo@sandia.gov>
Date: Monday, April 9, 2018 at 5:49 AM
To: "Lin, Paul" <ptlin@sandia.gov>
Cc: "Ibanez, Daniel Alejandro" <daibane@sandia.gov>
Subject: Re: Teuchos ParameterLists should not have any trouble with type long (64-bit integer) ?
Looks like the yaml language doesn’t support the concept of long. They suggest using a string in the link below. You will have to explicitly tell the yaml parser the type in the input file.
https://stackoverflow.com/questions/36191276/yaml-how-to-cast-value-to-long-in-yaml-fil?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
http://yaml.org/type/int.html
Also pinging Dan for his recommendation.
Roger
From: Paul Lin <ptlin@sandia.gov>
Date: Monday, April 9, 2018 at 7:35 AM
To: Roger Pawlowski <rppawlo@sandia.gov>
Cc: Paul Lin <ptlin@sandia.gov>
Subject: Re: Teuchos ParameterLists should not have any trouble with type long (64-bit integer) ?
Hello Roger,
Actually I didn't use decimal notation; I gave "Count" an integer:
Initial Particle Conditions:
Electrons:
All: # Fill the full domain
Fill Pattern: Random in Element
Type: e-
Temperature: 1150000.0
Count: 2467430400
Density: 1e16
But it assumed it was a decimal.
I'll play around with it myself so that you need not waste your time.
I'll look at the yaml parser again.
thanks
-paul