How to use inf value in yaml
#2480
Answered
by
Jasha10
nicolas-dufour
asked this question in
Q&A
🐛 BugDescriptionWhen writing a yaml file, inf is not interprated as a float but as an str with foo: infwhen imported in python The doc however specify that inf type is supported Checklist
Expected BehaviorI would expect cfg.foo == float("inf") System information
|
Answered by
Jasha10
Nov 23, 2022
Replies: 1 comment 2 replies
|
Hi @nicolas-dufour, infinity: !!float .infHere it is in action: >>> cfg = OmegaConf.create("foo: !!float .inf")
>>> cfg.foo
infHydra uses infinity: .inf>>> cfg = OmegaConf.create("foo: .inf")
>>> cfg.foo
inf
>>> import math
>>> math.isfinite(cfg.foo)
False |
2 replies
Answer selected by
nicolas-dufour
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @nicolas-dufour,
See Example 10.7 from the yaml spec:
Here it is in action:
Hydra uses
pyyamlfor parsing, and it seems that with pyyaml you can omit the!!floatprefix: