Closed singularitti closed 3 years ago
I think this is because the toml converter doesn't treat Nothing
as an empty field. In TOML, Nothing
is equivalent to empty collection.
I don't think I have time to fix it this week, so feel free to submit a PR, if you want to use it now.
OK after looking into this I believe the implementation is OK, but your definition is slightly wrong
to define empty table you need to let the default value be nothing
, TOML does not support null
type, thus the parser is not able to convert nothing
to a valid TOML type.
@option "fit" struct EosFittingConfig
fixed::Union{Pressures,Volumes}
trial_eos::Union{TrialEos,Nothing} = nothing
end
for from_toml
you misunderstood the meaning of a type alias, the correct TOML file should be
[fixed.pressures]
values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
unit = "GPa"
[trial_eos.trial_eos]
name = "bm3"
parameters = ["1m^3", "20GPa", 2.0, "3eV"]
Yeah, that's the strategy I'm using now. Thanks!
In TOML syntax, empty tables are allowed.
I am not sure how to write that. Consider I have the following code:
Here,
fixed
inEosFittingConfig
is a normal usage, which means you want to either putPressures
orVolumes
there. But fortrial_eos
you can either provide it or do nothing. In the current implementation, I can neither create oneEosFittingConfig
withnothing
astrial_eos
:nor load from a TOML file