From 46ef7300c76024c130fd8122cd9c4206ec53fb8c Mon Sep 17 00:00:00 2001 From: jim <459633157@qq.com> Date: Sun, 6 Nov 2022 15:10:16 +0800 Subject: [PATCH] fix unexpected ValueError When value is a numpy array, comparing a numpy array with None object will give another numpy array. Then a ValueError will be raised, says: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(). For example, you can test this funtion with value = numpy.array([1,2,3]), and default=None. --- mmf/common/registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmf/common/registry.py b/mmf/common/registry.py index 3c82d51fa..d0ceec915 100644 --- a/mmf/common/registry.py +++ b/mmf/common/registry.py @@ -632,8 +632,8 @@ def get(cls, name, default=None, no_warning=False): if ( "writer" in cls.mapping["state"] - and value == default and no_warning is False + and type(value) == type(default) and value == default ): cls.mapping["state"]["writer"].warning( "Key {} is not present in registry, returning default value "