Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Fixed
<https://github.com/omni-us/jsonargparse/pull/771>`__).
- Misleading error message when a namespace is used in a list comprehension
(`#772 <https://github.com/omni-us/jsonargparse/pull/772>`__).
- ``omegaconf+`` parser mode failing when there are ``inf``, ``-inf`` or ``nan``
values (`#773 <https://github.com/omni-us/jsonargparse/pull/773>`__).


v4.41.0 (2025-09-04)
Expand Down
4 changes: 1 addition & 3 deletions jsonargparse/_optionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ def omegaconf_apply(parser, cfg):
from ._common import parser_context

with parser_context(path_dump_preserve_relative=True):
cfg_dict = parser.dump(
cfg, format="json_compact", skip_validation=True, skip_none=False, skip_link_targets=False
)
cfg_dict = parser.dump(cfg, skip_validation=True, skip_none=False, skip_link_targets=False)
cfg_omegaconf = OmegaConf.create(cfg_dict)
cfg_dict = OmegaConf.to_container(cfg_omegaconf, resolve=True)
return parser._apply_actions(cfg_dict)
Expand Down
17 changes: 17 additions & 0 deletions jsonargparse_tests/test_omegaconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,20 @@ def test_omegaconf_global_path_preserve_relative(parser, tmp_cwd):
with parser_context(path_dump_preserve_relative=True):
dump = yaml.safe_load(parser.dump(cfg))["nested"]["path"]
assert dump == {"relative": "file", "cwd": str(tmp_cwd / subdir)}


@skip_if_omegaconf_unavailable
def test_omegaconf_inf_nan(parser):
parser.parser_mode = "omegaconf+"
parser.add_argument("--a", type=float, default=0.0)
parser.add_argument("--b", type=float, default=1.0)
parser.add_argument("--c", type=float, default=float("nan"))
parser.add_argument("--d", type=float, default=float("inf"))
parser.add_argument("--e", type=float, default=float("-inf"))

cfg = parser.parse_args(["--a=2.5", "--b=${a}"])
assert cfg.a == 2.5
assert cfg.b == 2.5
assert math.isnan(cfg.c)
assert cfg.d == float("inf")
assert cfg.e == float("-inf")