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: inf when imported in python The doc however specify that inf type is supported Checklist
Expected BehaviorI would expect cfg.foo == float("inf") System information
|
Beta Was this translation helpful? Give feedback.
Answered by
Jasha10
Nov 23, 2022
Replies: 1 comment 1 reply
-
Hi @nicolas-dufour, infinity: !!float .inf Here it is in action: >>> cfg = OmegaConf.create("foo: !!float .inf")
>>> cfg.foo
inf Hydra uses infinity: .inf >>> cfg = OmegaConf.create("foo: .inf")
>>> cfg.foo
inf
>>> import math
>>> math.isfinite(cfg.foo)
False |
Beta Was this translation helpful? Give feedback.
1 reply
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
pyyaml
for parsing, and it seems that with pyyaml you can omit the!!float
prefix: