From 6188893ca3c63f344c0ba3d6a4ae7263e28c5b76 Mon Sep 17 00:00:00 2001 From: Patrick Labatut <60359573+patricklabatut@users.noreply.github.com> Date: Thu, 23 Apr 2020 22:47:11 +0200 Subject: [PATCH] Fix handling maps with integer keys (#41) * Trivial fix to not fail on integer keys. * Extend example with dynamic map with integer keys. --- example/config.py | 2 ++ example/config.yaml | 4 ++++ yacs/config.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/example/config.py b/example/config.py index 1eade47..b0eac80 100644 --- a/example/config.py +++ b/example/config.py @@ -10,4 +10,6 @@ _C.TRAIN.HYPERPARAMETER_1 = 0.1 _C.TRAIN.SCALES = (2, 4, 8, 16) +_C.DATASETS = CN(new_allowed=True) + cfg = _C diff --git a/example/config.yaml b/example/config.yaml index d1e9fdd..a352f21 100644 --- a/example/config.yaml +++ b/example/config.yaml @@ -2,3 +2,7 @@ SYSTEM: NUM_GPUS: 2 TRAIN: SCALES: (1, 2) +DATASETS: + train_2017: + 17: 1 + 18: 1 diff --git a/yacs/config.py b/yacs/config.py index e39898d..54bec35 100644 --- a/yacs/config.py +++ b/yacs/config.py @@ -129,7 +129,7 @@ def _create_config_tree_from_dict(cls, dic, key_list): _assert_with_logging( _valid_type(v, allow_cfg_node=False), "Key {} with value {} is not a valid type; valid types: {}".format( - ".".join(key_list + [k]), type(v), _VALID_TYPES + ".".join(key_list + [str(k)]), type(v), _VALID_TYPES ), ) return dic