Skip to content
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

child is always associated in get_value even if requested section is missing #110

Closed
lewisfish opened this issue Sep 9, 2022 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@lewisfish
Copy link

Hi,
Using the Accessing nested tables tutorial as a base, I'm trying to understand how call get_value child variable works when the requested section is missing.
When editing the example toml file for the above tutorial to rename the hamiltonian section to something else (eg. [foobar.dftb]) the code runs with out displaying the expected error message "No hamiltonian section found in input file". Is there a bug in get_value and child is always associated? Or am I just misunderstaning how the tutorial code works?

@awvwgk awvwgk added the documentation Improvements or additions to documentation label Sep 9, 2022
@awvwgk
Copy link
Member

awvwgk commented Sep 9, 2022

The get_value interface will eagerly create missing child tables in the root table unless the requested=.false. option is provided, i.e. requested defaults to .true. if not provided. In this (default) case the child table is only not associated if the key is associated with something else than a table, like

hamiltonian = "dftb"

[analysis]
calculate-forces = true

The get_value interface can distinguish between success (table present or table created) and failure (non-table value) by association status in this case.

If requested=.false. is set as for the second part of the recipe, the child pointer will only be associated to a table if it was previously present. Note that this will fail with a non-zero stat value for the provided example

analysis = ["calculate-forces"]

[hamiltonian.dftb]
scc = {}
skf.format = "mio-1-1/{}-{}.skf"

In this case the child pointer will be unassociated as well, however we have three possible states, success and pointer associated (table present), success and pointer unassociated (table absent) and failure and pointer unassociated (non-table value).


If this explanation helps I can incorporate it with the recipe in the docs.

@lewisfish
Copy link
Author

Thanks for your quick reply! That clears things up for me. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants