Commit 1d84aa30 authored by Chen Chen's avatar Chen Chen Committed by A. Unique TensorFlower
Browse files

Allow to override a list/tuple in `base_config.Config` to empty list/tuple.

PiperOrigin-RevId: 342925872
parent 44cfd95e
......@@ -182,6 +182,8 @@ class Config(params_dict.ParamsDict):
self.__dict__[k] = self._import_config(v, subconfig_type)
else:
self.__dict__[k] = self._import_config(v, subconfig_type)
else:
self.__dict__[k] = self._import_config(v, subconfig_type)
def __setattr__(self, k, v):
if k not in self.RESERVED_ATTR:
......
......@@ -347,6 +347,15 @@ class BaseConfigTest(parameterized.TestCase, tf.test.TestCase):
self.assertIsInstance(config.y[1], DumpConfig4)
self.assertSameElements(config.z, ['a', 'b', 'c'])
def test_override_by_empty_sequence(self):
config = DummyConfig5()
config.override({
'y': [],
'z': (),
}, is_strict=True)
self.assertEmpty(config.y)
self.assertEmpty(config.z)
if __name__ == '__main__':
tf.test.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment