Skip to content

How to use inf value in yaml #2480

Answered by Jasha10
nicolas-dufour asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @nicolas-dufour,
See Example 10.7 from the yaml spec:

infinity: !!float .inf

Here it is in action:

>>> cfg = OmegaConf.create("foo: !!float .inf")
>>> cfg.foo
inf

Hydra uses pyyaml for parsing, and it seems that with pyyaml you can omit the !!float prefix:

infinity: .inf
>>> cfg = OmegaConf.create("foo: .inf")
>>> cfg.foo
inf
>>> import math
>>> math.isfinite(cfg.foo)
False

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nicolas-dufour
Comment options

Answer selected by nicolas-dufour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Hydra usage question
2 participants
Converted from issue

This discussion was converted from issue #2478 on November 23, 2022 23:32.