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

Use semeio for parameter parsing, make nesting explicit #102

Merged
merged 1 commit into from
Oct 5, 2021

Conversation

berland
Copy link
Collaborator

@berland berland commented Sep 28, 2021

The nesting of parameters dictionary is specific to fmu-dataio. Make it more explicit
by putting it in a different function

@berland berland force-pushed the semeio-paramparsing branch 3 times, most recently from d8e99db to a8036aa Compare September 28, 2021 11:08
The nesting of parameters dictionary is specific to fmu-dataio. Make it more explicit
by putting it in a different function

ptext = "tests/data/drogon/ertrun1/realization-0/iter-0/parameters_justified.txt"

res = _utils.read_parameters_txt(ptext)
res = _utils.nested_parameters_dict(_utils.read_parameters_txt(ptext))

assert res["SENSNAME"] == "rms_seed"
assert res["GLOBVAR"]["VOLON_PERMH_CHANNEL"] == 1100
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further up the form is now res["GLOBVAR:VOLON_PERMH_CHANNEL"]. Put here is res["GLOBVAR"]["VOLON_PERMH_CHANNEL"]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is what the nested_parameters_dict() function does, splitting by colons.

Copy link
Collaborator

@jcrivenaes jcrivenaes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@berland
Copy link
Collaborator Author

berland commented Sep 29, 2021

This PR maybe changes some behaviour of dict ordering, as the previous code used OrderedDict. This was apparently not tested. Is that an important feature to be conserved?

@jcrivenaes
Copy link
Collaborator

This PR maybe changes some behaviour of dict ordering, as the previous code used OrderedDict. This was apparently not tested. Is that an important feature to be conserved?

There may actually be no need for OrderedDict() when >= python 3.6. cf. https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/

@perolavsvendsen
Copy link
Member

This PR maybe changes some behaviour of dict ordering, as the previous code used OrderedDict. This was apparently not tested. Is that an important feature to be conserved?

There may actually be no need for OrderedDict() when >= python 3.6. cf. https://softwaremaniacs.org/blog/2020/02/05/dicts-ordered/

Regardless, I cannot see that dict ordering should be important to preserve, other than for readability.

@berland berland merged commit 080d221 into equinor:main Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants