Commit c6146d73 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 859f94a2
...@@ -180,6 +180,8 @@ class Config(params_dict.ParamsDict): ...@@ -180,6 +180,8 @@ class Config(params_dict.ParamsDict):
'the list/tuple is determined by the type annotation and ' 'the list/tuple is determined by the type annotation and '
'values provided. This is error-prone.') 'values provided. This is error-prone.')
self.__dict__[k] = self._import_config(v, subconfig_type) self.__dict__[k] = self._import_config(v, subconfig_type)
else:
self.__dict__[k] = self._import_config(v, subconfig_type)
else: else:
self.__dict__[k] = self._import_config(v, subconfig_type) self.__dict__[k] = self._import_config(v, subconfig_type)
......
...@@ -347,6 +347,15 @@ class BaseConfigTest(parameterized.TestCase, tf.test.TestCase): ...@@ -347,6 +347,15 @@ class BaseConfigTest(parameterized.TestCase, tf.test.TestCase):
self.assertIsInstance(config.y[1], DumpConfig4) self.assertIsInstance(config.y[1], DumpConfig4)
self.assertSameElements(config.z, ['a', 'b', 'c']) 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__': if __name__ == '__main__':
tf.test.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