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

hyperpyyaml sometimes loads scientific e notation as string #12

Closed
larsrgit opened this issue Nov 16, 2021 · 2 comments · Fixed by #17
Closed

hyperpyyaml sometimes loads scientific e notation as string #12

larsrgit opened this issue Nov 16, 2021 · 2 comments · Fixed by #17

Comments

@larsrgit
Copy link

larsrgit commented Nov 16, 2021

When calling hparams=load_hyperpyyaml("a: 1e-6"), hparams["a"] is a string. This can be avoided by calling hparams=load_hyperpyyaml("a: 1.0e-6") instead.

This would not be much of an issue, but when using operations on references in the yaml such as

hparams=load_hyperpyyaml(
"""
a: 0.0001
b: 10.0
c: !ref <a> / <b>
"""
)

which results in hparams["c"]='1e-5' being a string, the user has no control. Hyperpyyaml resolves the references and the devision as 1e-5 and not 1.0e-5 which results in a string and not a float.

@Gastron
Copy link
Contributor

Gastron commented Nov 16, 2021

Yes, this is the same issue as discussed in #8 . See that issue for an explanation - basically it comes from the underlying PyYAML parser.

@larsrgit
Copy link
Author

Thanks. I answered with a possible fix in the other issue and will close this one.

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 a pull request may close this issue.

2 participants